Add on-watch artist listing

This commit is contained in:
RandyTheSilly committed 2026-10-10 21:28:59 -04:00
1 parent 03bf39227c
commit 5507ef52ea
3 files changed
+68 -34

No files matched your search

+3 -2
View File
@@ -39,8 +39,9 @@
"PKJS_READY",
"IN_VANITY_LIST[2048]",
"IN_ID_LIST[2048]",
"OUT_MENU_NAV_SCOPE",
"OUT_JFID",
"BIDIR_MENU_NAV_SCOPE",
"OUT_MENU_NAV_SUBSCOPE",
"OUT_PLAY_SEQ_ID",
"OUT_SHUFFLE_MODE"
],
"resources": {
+25 -16
View File
@@ -53,27 +53,31 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *t_ready = dict_find(iter, MESSAGE_KEY_PKJS_READY);
if (t_ready) {
s_pkjs_ready = true;
APP_LOG(APP_LOG_LEVEL_DEBUG, "PKJS READY RECEIVED");
return;
}
// handle incoming menu list items
for (uint16_t i = 0; i < MAX_MENU_ITEMS; i++) {
Tuple *t_vanity = dict_find(iter, MESSAGE_KEY_IN_VANITY_LIST + i);
if (t_vanity) {
s_current_menu_vanity[i] = t_vanity->value->cstring;
} else {
s_menu_items_count = i;
break;
Tuple *t_new_scope = dict_find(iter, MESSAGE_KEY_BIDIR_MENU_NAV_SCOPE);
if (t_new_scope) {
for (uint16_t i = 0; i < MAX_MENU_ITEMS; i++) {
Tuple *t_vanity = dict_find(iter, MESSAGE_KEY_IN_VANITY_LIST + i);
if (t_vanity) {
s_current_menu_vanity[i] = t_vanity->value->cstring;
} else {
s_menu_items_count = i;
break;
}
}
s_current_menu_scope = t_new_scope->value->uint8;
menu_layer_reload_data(s_menu_layer);
menu_layer_set_selected_index(s_menu_layer, MenuIndex(0, 0), MenuRowAlignTop, false);
return;
}
s_current_menu_scope = NAV_SCOPE_SEARCH;
menu_layer_reload_data(s_menu_layer);
menu_layer_set_selected_index(s_menu_layer, MenuIndex(0, 0), MenuRowAlignTop, false);
return;
}
// request a new menu scope from the PKJS side
static void to_pkjs_scope_change(NavScope scope) {
static void to_pkjs_scope_change(NavScope scope, uint16_t *subscope_index) {
if (!s_pkjs_ready) {
return;
}
@@ -83,7 +87,10 @@ static void to_pkjs_scope_change(NavScope scope) {
if (result != APP_MSG_OK) {
return;
}
dict_write_uint8(out, MESSAGE_KEY_OUT_MENU_NAV_SCOPE, scope);
if (subscope_index) {
dict_write_cstring(out, MESSAGE_KEY_OUT_MENU_NAV_SUBSCOPE, s_current_menu_vanity[*subscope_index]);
}
dict_write_uint8(out, MESSAGE_KEY_BIDIR_MENU_NAV_SCOPE, scope);
result = app_message_outbox_send();
if (result != APP_MSG_OK) {
@@ -119,13 +126,15 @@ static void menu_select_click(struct MenuLayer *menu_layer, MenuIndex *clicked_i
case 1:
break;
case 2:
to_pkjs_scope_change(NAV_SCOPE_ARTISTS);
to_pkjs_scope_change(NAV_SCOPE_ARTISTS, NULL);
break;
default:
to_pkjs_scope_change(NAV_SCOPE_SEARCH);
to_pkjs_scope_change(NAV_SCOPE_SEARCH, NULL);
}
return;
case NAV_SCOPE_SEARCH:
to_pkjs_scope_change(NAV_SCOPE_ARTISTS, &clicked_index->row);
break;
case NAV_SCOPE_ARTISTS:
case NAV_SCOPE_ALBUMS:
case NAV_SCOPE_ALBUM_TRACKS:
@@ -179,7 +188,7 @@ static void init() {
// initialize pkjs
app_message_register_inbox_received(inbox_received_handler);
app_message_register_outbox_failed(outbox_failed_handler);
app_message_open(app_message_inbox_size_maximum(), 512);
app_message_open(app_message_inbox_size_maximum(), 255);
// load font
s_font_chicago = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHICAGO_16));
+40 -16
View File
@@ -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