various optimisations

This commit is contained in:
Core 2022-06-15 23:26:51 +01:00
parent 69c460ad03
commit bd330c1ec0
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
6 changed files with 23 additions and 21 deletions

View file

@ -450,4 +450,6 @@ Update 10/06/2022 20:00 UTC
Update 15/06/2022 20:00 UTC Update 15/06/2022 20:00 UTC
* `settings.notyf.connectivity.lastfmScrobble.connectError`: Added to `en_US` * `settings.notyf.connectivity.lastfmScrobble.connectError`: Added to `en_US`
* `settings.notyf.connectivity.lastfmScrobble.connectSuccess`: Added to `en_US`
* `settings.notyf.connectivity.lastfmScrobble.connecting`: Added to `en_US`

View file

@ -540,6 +540,8 @@
"settings.option.connectivity.lastfmScrobble.removeFeatured": "Remove featuring artists from song title (Last.fm)", "settings.option.connectivity.lastfmScrobble.removeFeatured": "Remove featuring artists from song title (Last.fm)",
"settings.option.connectivity.lastfmScrobble.filterLoop": "Filter looped track (Last.fm)", "settings.option.connectivity.lastfmScrobble.filterLoop": "Filter looped track (Last.fm)",
"settings.notyf.connectivity.lastfmScrobble.connectError": "Last.fm Connection Timed Out", "settings.notyf.connectivity.lastfmScrobble.connectError": "Last.fm Connection Timed Out",
"settings.notyf.connectivity.lastfmScrobble.connectSuccess": "Last.fm Connection Successful",
"settings.notyf.connectivity.lastfmScrobble.connecting": "Connecting to Last.fm...",
"settings.header.debug": "Debug", "settings.header.debug": "Debug",
"settings.option.debug.copy_log": "Copy logs to clipboard", "settings.option.debug.copy_log": "Copy logs to clipboard",
"settings.option.debug.openAppData": "Open Cider Folder", "settings.option.debug.openAppData": "Open Cider Folder",

View file

@ -528,6 +528,8 @@
"settings.option.connectivity.lastfmScrobble.removeFeatured": "Remove featuring artists from song title (Last.fm)", "settings.option.connectivity.lastfmScrobble.removeFeatured": "Remove featuring artists from song title (Last.fm)",
"settings.option.connectivity.lastfmScrobble.filterLoop": "Filter looped track (Last.fm)", "settings.option.connectivity.lastfmScrobble.filterLoop": "Filter looped track (Last.fm)",
"settings.notyf.connectivity.lastfmScrobble.connectError": "Last.fm Connection Timed Out", "settings.notyf.connectivity.lastfmScrobble.connectError": "Last.fm Connection Timed Out",
"settings.notyf.connectivity.lastfmScrobble.connectSuccess": "Last.fm Connection Successful",
"settings.notyf.connectivity.lastfmScrobble.connecting": "Connecting to Last.fm...",
"settings.header.debug": "Debug", "settings.header.debug": "Debug",
"settings.option.debug.copy_log": "Copy logs to clipboard", "settings.option.debug.copy_log": "Copy logs to clipboard",
"settings.option.debug.openAppData": "Open Cider Folder", "settings.option.debug.openAppData": "Open Cider Folder",

View file

@ -224,8 +224,7 @@ export class Store {
"scrobble_after": 50, "scrobble_after": 50,
"secrets": { "secrets": {
"username": "", "username": "",
"key": "", "key": ""
"token": ""
} }
}, },

View file

@ -829,12 +829,6 @@ const app = new Vue({
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player") MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
ipcRenderer.on('lastfm:authenticated', (_e, session) => {
app.cfg.lastfm.username = session.username
app.cfg.lastfm.key = session.key
app.cfg.lastfm.enabled = true
})
ipcRenderer.on('setStoreValue', (e, key, value) => { ipcRenderer.on('setStoreValue', (e, key, value) => {
app.cfg[key] = value app.cfg[key] = value
}) })

View file

@ -1063,12 +1063,9 @@
{{$root.getLz('settings.option.connectivity.lastfmScrobble')}} {{$root.getLz('settings.option.connectivity.lastfmScrobble')}}
</div> </div>
<div class="md-option-segment md-option-segment_auto"> <div class="md-option-segment md-option-segment_auto">
<button v-if="app.cfg.lastfm.secrets.username" class="md-btn" @click="lfmDisconnect"> <button class="md-btn" id="lfmConnect" @click="app.cfg.lastfm.enabled ? lfmDisconnect() : lfmAuthorize()">
{{$root.getLz('term.disconnect')}}<br> {{$root.getLz(`term.${$root.cfg.lastfm.enabled ? "disconnect" : "connect"}`)}}<br>
<small>{{$root.getLz('term.authed')}}: {{app.cfg.lastfm.secrets.username}}</small> <small>{{app.cfg.lastfm.enabled ? `${$root.getLz('term.authed')}: ${$root.cfg.lastfm.secrets.username}` : '' }}</small>
</button>
<button v-else class="md-btn" @click="lfmAuthorize">
{{$root.getLz('term.connect')}}
</button> </button>
</div> </div>
</div> </div>
@ -1471,23 +1468,29 @@
}, },
lfmDisconnect() { lfmDisconnect() {
app.cfg.lastfm.enabled = false; app.cfg.lastfm.enabled = false;
app.cfg.lastfm.username = ""; app.cfg.lastfm.secrets.username = "";
app.cfg.lastfm.key = ""; app.cfg.lastfm.secrets.key = "";
ipcRenderer.send('lastfm:disconnect'); ipcRenderer.send('lastfm:disconnect');
}, },
async lfmAuthorize(event) { async lfmAuthorize() {
window.open(await ipcRenderer.invoke('lastfm:url')); window.open(await ipcRenderer.invoke('lastfm:url'));
event.target.innerText = app.getLz('term.connecting') + '...'; app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connecting'));
/* Just a timeout for the button */ /* Just a timeout for the button */
setTimeout(() => { setTimeout(() => {
if (event.target.innerText === app.getLz('term.connecting') + '...') { if (document.getElementById('lfmConnect').innerText === app.getLz('term.connecting') + '...') {
event.target.innerText = app.getLz('term.connect');
app.notyf.error(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectError')); app.notyf.error(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectError'));
console.warn('[lastfm:authorize] Last.fm authorization timed out.'); console.warn('[lastfm:authorize] Last.fm authorization timed out.');
} }
}, 20000); }, 20000);
ipcRenderer.once('lastfm:authenticated', (_e, session) => {
app.cfg.lastfm.secrets.username = session.username
app.cfg.lastfm.secrets.key = session.key
app.cfg.lastfm.enabled = true
app.notyf.success(app.getLz('settings.notyf.connectivity.lastfmScrobble.connectSuccess'));
})
}, },
} }
}) })