-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.js
30 lines (25 loc) · 889 Bytes
/
session.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Javascript for retrieving sessions state
app.ports.saveSession.subscribe(function(key) {
window.localStorage.setItem("sessionKey", key);
});
app.ports.saveServerUrl.subscribe(function(url) {
window.localStorage.setItem("serverUrl", url);
});
app.ports.saveLastPlayed.subscribe(function(id) {
window.localStorage.setItem("lastPlayed", id);
});
app.ports.clearSession.subscribe(function() {
window.localStorage.clear();
});
app.ports.requestLastPlayed.subscribe(function() {
let lastPlayed = window.localStorage.getItem("lastPlayed");
if (lastPlayed) {
app.ports.getLastPlayed.send(lastPlayed);
}
});
let serverUrl = window.localStorage.getItem("serverUrl");
let key = window.localStorage.getItem("sessionKey");
if (serverUrl && key) {
app.ports.startupInfo.send({"loginToken": key, "serverUrl": serverUrl});
setVolume(window.localStorage.getItem("volume"));
}