Merge branch 'main' into enhancement/search-bar

This commit is contained in:
Pedro Galhardo 2022-06-29 17:15:02 +01:00
commit 13f12121ba
No known key found for this signature in database
GPG key ID: 4740524CD85770A9
22 changed files with 569 additions and 593 deletions

View file

@ -68,6 +68,10 @@ Vue.component("sidebar-library-item", {
required: false,
default: "",
},
svgIconName: {
type: String,
required: false
},
cdClick: {
type: Function,
required: false,

View file

@ -832,6 +832,10 @@ const app = new Vue({
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
ipcRenderer.on('setStoreValue', (e, key, value) => {
app.cfg[key] = value
})
ipcRenderer.on('theme-update', async (event, arg) => {
await less.refresh(true, true, true)
self.setTheme(self.cfg.visual.theme, true)
@ -4423,37 +4427,6 @@ const app = new Vue({
}
app.modals.settings = true
},
LastFMDeauthorize() {
ipcRenderer.invoke('setStoreValue', 'lastfm.enabled', false).catch((e) => console.error(e));
ipcRenderer.invoke('setStoreValue', 'lastfm.auth_token', '').catch((e) => console.error(e));
app.cfg.lastfm.auth_token = "";
app.cfg.lastfm.enabled = false;
const element = document.getElementById('lfmConnect');
element.innerHTML = app.getLz('term.connect');
element.onclick = app.LastFMAuthenticate;
},
LastFMAuthenticate() {
console.log("[LastFM] Received LastFM authentication callback")
const element = document.getElementById('lfmConnect');
// new key : f9986d12aab5a0fe66193c559435ede3
window.open('https://www.last.fm/api/auth?api_key=f9986d12aab5a0fe66193c559435ede3&cb=cider://auth/lastfm');
element.innerText = app.getLz('term.connecting') + '...';
/* Just a timeout for the button */
setTimeout(() => {
if (element.innerText === app.getLz('term.connecting') + '...') {
element.innerText = app.getLz('term.connect');
console.warn('[LastFM] Attempted connection timed out.');
}
}, 20000);
ipcRenderer.on('LastfmAuthenticated', function (_event, lfmAuthKey) {
app.cfg.lastfm.auth_token = lfmAuthKey;
app.cfg.lastfm.enabled = true;
element.innerHTML = `${app.getLz('term.disconnect')}\n<p style="font-size: 8px"><i>(${app.getLz('term.authed')}: ${lfmAuthKey})</i></p>`;
element.onclick = app.LastFMDeauthorize;
});
},
fullscreen(flag) {
this.fullscreenState = flag;
if (flag) {

View file

@ -198,13 +198,13 @@
</div>
<div class="app-chrome-item" v-else>
<div class="top-nav-group">
<sidebar-library-item :name="$root.getLz('home.title')" svg-icon="./assets/feather/home.svg" page="home">
<sidebar-library-item :name="$root.getLz('home.title')" svg-icon="./assets/feather/home.svg" svg-icon-name="home" page="home">
</sidebar-library-item>
<sidebar-library-item :name="$root.getLz('term.listenNow')" svg-icon="./assets/feather/play-circle.svg"
<sidebar-library-item :name="$root.getLz('term.listenNow')" svg-icon="./assets/feather/play-circle.svg" svg-icon-name="listenNow"
page="listen_now"></sidebar-library-item>
<sidebar-library-item :name="$root.getLz('term.browse')" svg-icon="./assets/feather/globe.svg" page="browse">
<sidebar-library-item :name="$root.getLz('term.browse')" svg-icon="./assets/feather/globe.svg" svg-icon-name="browse" page="browse">
</sidebar-library-item>
<sidebar-library-item :name="$root.getLz('term.radio')" svg-icon="./assets/feather/radio.svg" page="radio">
<sidebar-library-item :name="$root.getLz('term.radio')" svg-icon="./assets/feather/radio.svg" svg-icon-name="radio" page="radio">
</sidebar-library-item>
</div>
</div>

View file

@ -51,6 +51,7 @@
<sidebar-library-item
:name="$root.getLz('home.title')"
svg-icon="./assets/feather/home.svg"
svg-icon-name="home"
page="home"
>
</sidebar-library-item>
@ -67,17 +68,20 @@
<sidebar-library-item
:name="$root.getLz('term.listenNow')"
svg-icon="./assets/feather/play-circle.svg"
svg-icon-name="listenNow"
page="listen_now"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.browse')"
svg-icon="./assets/feather/globe.svg"
svg-icon-name="browse"
page="browse"
>
</sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.radio')"
svg-icon="./assets/feather/radio.svg"
svg-icon-name="radio"
page="radio"
></sidebar-library-item>
</template>
@ -94,36 +98,42 @@
<sidebar-library-item
:name="$root.getLz('term.recentlyAdded')"
svg-icon="./assets/feather/plus-circle.svg"
svg-icon-name="recentlyAdded"
v-if="cfg.general.sidebarItems.recentlyAdded"
page="library-recentlyadded"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.songs')"
svg-icon="./assets/feather/music.svg"
svg-icon-name="songs"
v-if="cfg.general.sidebarItems.songs"
page="library-songs"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.albums')"
svg-icon="./assets/feather/disc.svg"
svg-icon-name="albums"
v-if="cfg.general.sidebarItems.albums"
page="library-albums"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.artists')"
svg-icon="./assets/feather/user.svg"
svg-icon-name="artists"
v-if="cfg.general.sidebarItems.artists"
page="library-artists"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.videos')"
svg-icon="./assets/feather/video.svg"
svg-icon-name="videos"
v-if="cfg.general.sidebarItems.videos"
page="library-videos"
></sidebar-library-item>
<sidebar-library-item
:name="$root.getLz('term.podcasts')"
svg-icon="./assets/feather/mic.svg"
svg-icon-name="podcasts"
v-if="cfg.general.sidebarItems.podcasts"
page="podcasts"
>

View file

@ -994,18 +994,18 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.enabled" switch />
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.enabled" switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clientName')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<select class="md-select" v-model="app.cfg.general.discordrpc.client">
<select class="md-select" v-model="app.cfg.connectivity.discord_rpc.client">
<option value="Cider">{{$root.getLz('app.name')}}</option>
<option value="AppleMusic">{{$root.getLz('term.appleMusic')}}
</option>
@ -1014,40 +1014,40 @@
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clearOnPause')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.clear_on_pause" switch />
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.clear_on_pause" switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.hideButtons')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.hide_buttons" switch />
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.hide_buttons" switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.hideTimestamp')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.hide_timestamp" switch />
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.hide_timestamp" switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.detailsFormat')}}<br />
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1055,12 +1055,12 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discordrpc.details_format" />
<input type="text" v-model="app.cfg.connectivity.discord_rpc.details_format" />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.stateFormat')}}
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1068,12 +1068,12 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discordrpc.state_format" />
<input type="text" v-model="app.cfg.connectivity.discord_rpc.state_format" />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.reload')}}
</div>
@ -1089,51 +1089,55 @@
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<button class="md-btn" id="lfmConnect" ref="lfmConnect"
@click="app.LastFMAuthenticate()">
{{$root.getLz('term.connect')}}
<div class="md-option-segment md-option-segment_auto" >
<button class="md-btn" id="lfmConnect" @click="app.cfg.connectivity.lastfm.enabled ? lfmDisconnect() : lfmAuthorize()">
{{$root.getLz(`term.${$root.cfg.connectivity.lastfm.enabled ? "disconnect" : "connect"}`)}}<br>
<small>{{app.cfg.connectivity.lastfm.enabled ? `${$root.getLz('term.authed')}: ${$root.cfg.connectivity.lastfm.secrets.username}` : '' }}</small>
</button>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-line" v-show="lastfmConnecting">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.manualToken')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<form @submit.prevent="submitToken">
<input type="text" autofocus id="lfmToken" />
<input type="submit" class="md-btn" @value="$root.getLz('action.submit')" />
</form>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.delay')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="number" min="50" max="100" v-model="app.cfg.lastfm.scrobble_after" />
<input type="number" min="50" max="100" v-model="app.cfg.connectivity.lastfm.scrobble_after"/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.nowPlaying')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.NowPlaying" switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.removeFeatured')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.enabledRemoveFeaturingArtists"
switch />
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterLoop')}}
<small>{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterLoop.description')}}</small>
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.filterLoop" switch />
<input type="checkbox" v-model="app.cfg.connectivity.lastfm.filter_loop" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterTypes')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" @change="filterChange" value="song">{{$root.getLz('term.songs')}}<br>
<input type="checkbox" @change="filterChange" value="musicVideo">{{$root.getLz('term.musicVideos')}}<br>
</label>
</div>
</div>
@ -1421,7 +1425,8 @@
app: this.$root,
themes: ipcRenderer.sendSync("get-themes"),
tabIndex: 0,
canChangeHash: false
canChangeHash: false,
lastfmConnecting: false
}
}, watch: {
tabIndex: function (val) {
@ -1430,15 +1435,6 @@
}
}
},
mounted: function () {
if (app.cfg.lastfm.enabled) {
const element = document.getElementById('lfmConnect');
if (element) {
element.innerHTML = `Disconnect\n<p style="font-size: 8px"><i>(Authed: ${app.cfg.lastfm.auth_token})</i></p>`;
element.onclick = app.LastFMDeauthorize;
}
}
},
methods: {
close() {
this.$root.modals.settings = false
@ -1554,6 +1550,41 @@
},
reloadDiscordRPC() {
ipcRenderer.send('reloadRPC')
},
lfmDisconnect() {
this.$root.cfg.connectivity.lastfm.enabled = false;
this.$root.cfg.connectivity.lastfm.secrets.username = "";
this.$root.cfg.connectivity.lastfm.secrets.key = "";
ipcRenderer.send('lastfm:disconnect');
},
async lfmAuthorize() {
this.lastfmConnecting = true;
window.open(await ipcRenderer.invoke('lastfm:url'));
app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connecting'));
/* Just a timeout for the button */
setTimeout(() => {
if (!this.$root.cfg.connectivity.lastfm.enabled) {
app.notyf.error(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectError'));
console.warn('[lastfm:authorize] Last.fm authorization timed out.');
this.lastfmConnecting = false;
}
}, 20000);
ipcRenderer.once('lastfm:authenticated', (_e, session) => {
this.$root.cfg.connectivity.lastfm.secrets.username = session.username
this.$root.cfg.connectivity.lastfm.secrets.key = session.key
this.$root.cfg.connectivity.lastfm.enabled = true
this.lastfmConnecting = false;
app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectSuccess'));
})
},
filterChange(e) {
this.$root.cfg.connectivity.lastfm.filter_types[e.target.value] = e.target.checked;
},
submitToken() {
const token = document.getElementById('lfmToken').value;
ipcRenderer.send('lastfm:auth', token);
}
}
})

View file

@ -9,7 +9,7 @@
:href="item.href"
@click='clickEvent()'>
<template v-if="!renaming">
<svg-icon :url="icon"/> {{ item.attributes.name }}
<svg-icon :url="icon" name="sidebar-playlist"/> {{ item.attributes.name }}
<small class="presentNotice" v-if="hasRelatedMediaItems">(Track present)</small>
</template>
<input type="text" v-model="item.attributes.name" class="pl-rename-field" @blur="rename()" @keydown.enter="rename()" v-else>

View file

@ -123,7 +123,7 @@
<script type="text/x-template" id="sidebar-library-item">
<button class="app-sidebar-item"
:class="$parent.getSidebarItemClass(page)" @click="$root.setWindowHash(page)">
<svg-icon :url="svgIconData" v-if="svgIconData != ''" />
<svg-icon :url="svgIconData" :name="'sidebar-' + svgIconName" v-if="svgIconData != ''" />
<span class="sidebar-item-text">{{ name }}</span>
</button>
</script>

View file

@ -954,18 +954,18 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.enabled" switch/>
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.enabled" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clientName')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<select class="md-select" v-model="app.cfg.general.discordrpc.client">
<select class="md-select" v-model="app.cfg.connectivity.discord_rpc.client">
<option value="Cider">{{$root.getLz('app.name')}}</option>
<option value="AppleMusic">{{$root.getLz('term.appleMusic')}}
</option>
@ -974,40 +974,40 @@
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clearOnPause')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.clear_on_pause" switch/>
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.clear_on_pause" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.hideButtons')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.hide_buttons" switch/>
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.hide_buttons" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.hideTimestamp')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discordrpc.hide_timestamp" switch/>
<input type="checkbox" v-model="app.cfg.connectivity.discord_rpc.hide_timestamp" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.detailsFormat')}}<br/>
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1015,12 +1015,12 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discordrpc.details_format"/>
<input type="text" v-model="app.cfg.connectivity.discord_rpc.details_format"/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.stateFormat')}}
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1028,12 +1028,12 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discordrpc.state_format"/>
<input type="text" v-model="app.cfg.connectivity.discord_rpc.state_format"/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.connectivity.discord_rpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.reload')}}
</div>
@ -1050,50 +1050,41 @@
{{$root.getLz('settings.option.connectivity.lastfmScrobble')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<button class="md-btn" id="lfmConnect" ref="lfmConnect"
@click="app.LastFMAuthenticate()">
{{$root.getLz('term.connect')}}
<button class="md-btn" id="lfmConnect" @click="app.cfg.connectivity.lastfm.enabled ? lfmDisconnect() : lfmAuthorize()">
{{$root.getLz(`term.${$root.cfg.connectivity.lastfm.enabled ? "disconnect" : "connect"}`)}}<br>
<small>{{app.cfg.connectivity.lastfm.enabled ? `${$root.getLz('term.authed')}: ${$root.cfg.connectivity.lastfm.secrets.username}` : '' }}</small>
</button>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.delay')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="number" min="50" max="100" v-model="app.cfg.lastfm.scrobble_after"/>
<input type="number" min="50" max="100" v-model="app.cfg.connectivity.lastfm.scrobble_after"/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.nowPlaying')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.NowPlaying" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.removeFeatured')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.enabledRemoveFeaturingArtists"
switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.lastfm.enabled">
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterLoop')}}
<small>{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterLoop.description')}}</small>
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.lastfm.filterLoop" switch/>
<input type="checkbox" v-model="app.cfg.connectivity.lastfm.filter_loop" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.connectivity.lastfm.enabled">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.lastfmScrobble.filterTypes')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" @change="filterChange" value="song">{{$root.getLz('term.songs')}}<br>
<input type="checkbox" @change="filterChange" value="musicVideo">{{$root.getLz('term.musicVideos')}}<br>
</label>
</div>
</div>
@ -1390,14 +1381,6 @@
this.canChangeHash = true
}
})
if (app.cfg.lastfm.enabled) {
const element = document.getElementById('lfmConnect');
if (element) {
element.innerHTML = `Disconnect\n<p style="font-size: 8px"><i>(Authed: ${app.cfg.lastfm.auth_token})</i></p>`;
element.onclick = app.LastFMDeauthorize;
}
}
},
methods: {
windowBgStyleChange() {
@ -1511,6 +1494,35 @@
},
reloadDiscordRPC() {
ipcRenderer.send('reloadRPC')
},
lfmDisconnect() {
this.$root.cfg.connectivity.lastfm.enabled = false;
this.$root.cfg.connectivity.lastfm.secrets.username = "";
this.$root.cfg.connectivity.lastfm.secrets.key = "";
ipcRenderer.send('lastfm:disconnect');
},
async lfmAuthorize() {
window.open(await ipcRenderer.invoke('lastfm:url'));
app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connecting'));
/* Just a timeout for the button */
setTimeout(() => {
if (document.getElementById('lfmConnect').innerText === app.getLz('term.connecting') + '...') {
app.notyf.error(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectError'));
console.warn('[lastfm:authorize] Last.fm authorization timed out.');
}
}, 20000);
ipcRenderer.once('lastfm:authenticated', (_e, session) => {
this.$root.cfg.connectivity.lastfm.secrets.username = session.username
this.$root.cfg.connectivity.lastfm.secrets.key = session.key
this.$root.cfg.connectivity.lastfm.enabled = true
app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectSuccess'));
})
},
filterChange(e) {
this.$root.cfg.connectivity.lastfm.filter_types[e.target.value] = e.target.checked;
}
}
})