mirror of
https://git.wetfence.xyz/RandyTheSilly/jellyPod.git
synced 2026-10-26 23:39:56 -04:00
Add on-watch artist listing
This commit is contained in:
1 parent
03bf39227c
commit
5507ef52ea
3 files changed
+68
-34
No files matched your search
+40
-16
@@ -3,6 +3,14 @@ var clayConfig = require('./config');
|
||||
var keys = require('message_keys');
|
||||
new Clay(clayConfig);
|
||||
|
||||
var NavScope = Object.freeze({
|
||||
NAV_SCOPE_MAIN: 0,
|
||||
NAV_SCOPE_SEARCH: 1,
|
||||
NAV_SCOPE_ARTISTS: 2,
|
||||
NAV_SCOPE_ALBUMS: 3,
|
||||
NAV_SCOPE_ALBUM_TRACKS: 4,
|
||||
});
|
||||
|
||||
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
||||
var lookupMap = new Map();
|
||||
|
||||
@@ -78,21 +86,44 @@ Pebble.addEventListener("ready", function () {
|
||||
}
|
||||
});
|
||||
|
||||
// PKJS seems to change its mind on how to index message keys, so this is necessary... :/
|
||||
function payloadGet(payload, name) {
|
||||
if (payload[name] !== undefined) return payload[name];
|
||||
if (payload[keys[name]] !== undefined) return payload[keys[name]];
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Pebble.addEventListener("appmessage", function (dict) {
|
||||
if (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
||||
switch (dict.payload[keys.OUT_MENU_NAV_SCOPE]) {
|
||||
case 1: { // search
|
||||
const vanityList = Array.from(lookupMap.keys());
|
||||
const outDict = {};
|
||||
for (let i = 0; i < vanityList.length; i++) {
|
||||
outDict[keys.IN_VANITY_LIST + i] = vanityList[i];
|
||||
//console.log("payload", JSON.stringify(dict.payload));
|
||||
//console.log("expected NAV_SCOPE key", keys.BIDIR_MENU_NAV_SCOPE);
|
||||
|
||||
const scope = payloadGet(dict.payload, "BIDIR_MENU_NAV_SCOPE");
|
||||
if (scope) {
|
||||
let vanityList;
|
||||
switch (scope) {
|
||||
case NavScope.NAV_SCOPE_SEARCH: { // search
|
||||
vanityList = Array.from(lookupMap.keys());
|
||||
break;
|
||||
}
|
||||
case NavScope.NAV_SCOPE_ARTISTS: { // artists
|
||||
const subscope = payloadGet(dict.payload, "OUT_MENU_NAV_SUBSCOPE");
|
||||
if (subscope) {
|
||||
// allow filtering by starting character
|
||||
vanityList = Array.from(lookupMap.get(subscope).keys());
|
||||
} else {
|
||||
vanityList = Array.from(lookupMap.values()).flatMap((artistMap) => Array.from(artistMap.keys()));
|
||||
}
|
||||
Pebble.sendAppMessage(outDict);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
const outDict = {};
|
||||
for (let i = 0; i < vanityList.length; i++) {
|
||||
outDict[keys.IN_VANITY_LIST + i] = vanityList[i];
|
||||
outDict[keys.BIDIR_MENU_NAV_SCOPE] = scope;
|
||||
}
|
||||
Pebble.sendAppMessage(outDict);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -126,13 +157,6 @@ function callAPI(method, endpoint, callback) {
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
// On Settings Save/Sync Button Press
|
||||
//// Get User ID
|
||||
|
||||
//curl -H "Authorization: MediaBrowser Token=\"TOKEN\"" -X GET 'BASEURL/Users'
|
||||
|
||||
// Get Track List Using Logic From JellyPod Server
|
||||
|
||||
// On Every Startup
|
||||
//// Get Session ID
|
||||
|
||||
|
||||
Reference in new issue
Block a user