renderer side of lastfm updated
This commit is contained in:
parent
47e3ad5b44
commit
2827dfb36d
5 changed files with 24 additions and 22 deletions
|
@ -448,3 +448,6 @@ Update 10/06/2022 20:00 UTC
|
||||||
|
|
||||||
* `settings.option.visual.purplePodcastPlaybackBar`: Added to `en_US`
|
* `settings.option.visual.purplePodcastPlaybackBar`: Added to `en_US`
|
||||||
|
|
||||||
|
Update 15/06/2022 20:00 UTC
|
||||||
|
|
||||||
|
* `settings.notyf.connectivity.lastfmScrobble.connectError`: Added to `en_US`
|
|
@ -539,6 +539,7 @@
|
||||||
"settings.option.connectivity.lastfmScrobble.nowPlaying": "Enable Last.fm Now Playing",
|
"settings.option.connectivity.lastfmScrobble.nowPlaying": "Enable Last.fm Now Playing",
|
||||||
"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.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",
|
||||||
|
|
|
@ -527,6 +527,7 @@
|
||||||
"settings.option.connectivity.lastfmScrobble.nowPlaying": "Enable Last.fm Now Playing",
|
"settings.option.connectivity.lastfmScrobble.nowPlaying": "Enable Last.fm Now Playing",
|
||||||
"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.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",
|
||||||
|
|
|
@ -52,6 +52,15 @@ export default class lastfm {
|
||||||
// console.debug('lastfm:auth', event, token)
|
// console.debug('lastfm:auth', event, token)
|
||||||
this.authenticateLastFM(token)
|
this.authenticateLastFM(token)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this._utils.getIPCMain().on('lastfm:disconnect', (event: any) => {
|
||||||
|
this._lfm.setSessionCredentials(null, null);
|
||||||
|
this._authenticated = false;
|
||||||
|
this._utils.setStoreValue('lastfm.enabled', false)
|
||||||
|
this._utils.setStoreValue('lastfm.secrets.username', "")
|
||||||
|
this._utils.setStoreValue('lastfm.secrets.key', "")
|
||||||
|
console.debug('[lastfm] [disconnect] Disconnected')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,10 +119,11 @@ export default class lastfm {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._utils.setStoreValue("lastfm.secrets.token", token)
|
|
||||||
this._utils.setStoreValue('lastfm.secrets.username', session.username);
|
this._utils.setStoreValue('lastfm.secrets.username', session.username);
|
||||||
this._utils.setStoreValue('lastfm.secrets.key', session.key);
|
this._utils.setStoreValue('lastfm.secrets.key', session.key);
|
||||||
|
this._utils.setStoreValue('lastfm.enabled', true)
|
||||||
this._authenticated = true;
|
this._authenticated = true;
|
||||||
|
console.debug(`[${lastfm.name}] [authenticate] Authenticated as ${session.username}`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1063,8 +1063,11 @@
|
||||||
{{$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 class="md-btn" id="lfmConnect" ref="lfmConnect"
|
<button v-if="app.cfg.lastfm.secrets.username" class="md-btn" @click="lfmDisconnect">
|
||||||
@click="lfmAuthorize">
|
{{$root.getLz('term.disconnect')}}<br>
|
||||||
|
<small>{{$root.getLz('term.authed')}}: {{app.cfg.lastfm.secrets.username}}</small>
|
||||||
|
</button>
|
||||||
|
<button v-else class="md-btn" @click="lfmAuthorize">
|
||||||
{{$root.getLz('term.connect')}}
|
{{$root.getLz('term.connect')}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1346,14 +1349,6 @@
|
||||||
this.canChangeHash = true
|
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: {
|
methods: {
|
||||||
windowBgStyleChange() {
|
windowBgStyleChange() {
|
||||||
|
@ -1474,14 +1469,10 @@
|
||||||
reloadDiscordRPC() {
|
reloadDiscordRPC() {
|
||||||
ipcRenderer.send('reloadRPC')
|
ipcRenderer.send('reloadRPC')
|
||||||
},
|
},
|
||||||
lfmDisconnect(event) {
|
lfmDisconnect() {
|
||||||
ipcRenderer.invoke('setStoreValue', 'lastfm.enabled', false).catch((e) => console.error(e));
|
ipcRenderer.send('lastfm:disconnect');
|
||||||
ipcRenderer.invoke('setStoreValue', 'lastfm.secrets.session', {}).catch((e) => console.error(e));
|
|
||||||
event.target.innerHTML = app.getLz('term.connect');
|
|
||||||
event.target.onclick = this.lfmAuthorize;
|
|
||||||
},
|
},
|
||||||
async lfmAuthorize(event) {
|
async lfmAuthorize(event) {
|
||||||
console.debug("[lastfm:authorize] Token received.")
|
|
||||||
window.open(await ipcRenderer.invoke('lastfm:url'));
|
window.open(await ipcRenderer.invoke('lastfm:url'));
|
||||||
event.target.innerText = app.getLz('term.connecting') + '...';
|
event.target.innerText = app.getLz('term.connecting') + '...';
|
||||||
|
|
||||||
|
@ -1489,15 +1480,11 @@
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (event.target.innerText === app.getLz('term.connecting') + '...') {
|
if (event.target.innerText === app.getLz('term.connecting') + '...') {
|
||||||
event.target.innerText = app.getLz('term.connect');
|
event.target.innerText = app.getLz('term.connect');
|
||||||
|
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.on('lastfm:renderer-auth', function (event, session) {
|
|
||||||
element.innerHTML = `${app.getLz('term.disconnect')}\n<p style="font-size: 8px"><i>(${app.getLz('term.authed')}: ${session.username})</i></p>`;
|
|
||||||
element.onclick = this.lfmDisconnect;
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue