mirror of
https://git.wetfence.xyz/RandyTheSilly/jellyPod.git
synced 2026-10-26 23:39:56 -04:00
Only sync library on Clay save
This commit is contained in:
1 parent
c95c75b11d
commit
6fb0a6dae6
3 files changed
+39
-13
No files matched your search
+1
-1
@@ -28,6 +28,6 @@ module.exports = [
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"defaultValue": "Save/Sync Library"
|
||||
"defaultValue": "Sync Library"
|
||||
}
|
||||
];
|
||||
+36
-8
@@ -1,7 +1,7 @@
|
||||
var Clay = require('@rebble/clay');
|
||||
var clayConfig = require('./config');
|
||||
var clay = new Clay(clayConfig, null, { autoHandleEvents: false });
|
||||
var keys = require('message_keys');
|
||||
new Clay(clayConfig);
|
||||
|
||||
var NavScope = Object.freeze({
|
||||
NAV_SCOPE_MAIN: 0,
|
||||
@@ -17,7 +17,15 @@ var jfIdToSeqIdMap = new Map();
|
||||
var allJfIds = [];
|
||||
var currentArtist = null;
|
||||
|
||||
Pebble.addEventListener("ready", function () {
|
||||
function toggleReadyState(ready) {
|
||||
const readyDict = {};
|
||||
readyDict[keys.PKJS_READY] = ready;
|
||||
Pebble.sendAppMessage(readyDict);
|
||||
}
|
||||
|
||||
function syncLibrary() {
|
||||
toggleReadyState(false);
|
||||
|
||||
// store cache of library info from Jellyfin
|
||||
if (cfg.PRIV_BASE_URL && cfg.PRIV_API_KEY && cfg.PRIV_USERNAME) {
|
||||
// get userId from Jellyfin
|
||||
@@ -39,7 +47,8 @@ Pebble.addEventListener("ready", function () {
|
||||
|
||||
// format response for jellyPod
|
||||
//// build lookupMap
|
||||
let lastAlbumInfo = { AlbumArtist: "", AlbumName: "", AlbumYear: 0 };
|
||||
let lastAlbumInfo = { AlbumArtist: "", AlbumName: ""};
|
||||
//let lastAlbumInfo = { AlbumArtist: "", AlbumName: "", AlbumYear: 0 }; // TODO FUTURE USE
|
||||
let currentSeqId = 0;
|
||||
allJfIds = [] // ensure blank
|
||||
for (const track of libObj.Items) {
|
||||
@@ -79,19 +88,38 @@ Pebble.addEventListener("ready", function () {
|
||||
lastAlbumInfo = {
|
||||
AlbumArtist: albumArtist,
|
||||
AlbumName: albumName,
|
||||
AlbumYear: track.ProductionYear ? track.ProductionYear : 1970
|
||||
//AlbumYear: track.ProductionYear ? track.ProductionYear : 1970 // TODO FUTURE USE
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//console.log(JSON.stringify(lookupMap, (k, v) => v instanceof Map ? Object.fromEntries(v) : v));
|
||||
|
||||
const readyDict = {};
|
||||
readyDict[keys.PKJS_READY] = 1;
|
||||
Pebble.sendAppMessage(readyDict);
|
||||
toggleReadyState(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function () {
|
||||
Pebble.openURL(clay.generateUrl());
|
||||
});
|
||||
|
||||
Pebble.addEventListener('webviewclosed', function(e) {
|
||||
if (!e || !e.response) { return; }
|
||||
|
||||
// persist settings
|
||||
try {
|
||||
clay.getSettings(e.response);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
||||
syncLibrary()
|
||||
});
|
||||
|
||||
Pebble.addEventListener("ready", function () {
|
||||
toggleReadyState(true);
|
||||
});
|
||||
|
||||
// PKJS seems to change its mind on how to index message keys, so this is necessary... :/
|
||||
|
||||
Reference in new issue
Block a user