diff options
Diffstat (limited to 'packages/meshbay-hub')
4 files changed, 18 insertions, 46 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/group-page.js b/packages/meshbay-hub/src/meshbay_hub/static/group-page.js index 341d37e..fec685b 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/group-page.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/group-page.js @@ -355,11 +355,9 @@ function GroupPage({ groupId, group, token, username, userId, userPrefs, // missing `video_directories` as "nothing configured" would empty a // working Videos tab. setAppDirectories({ - video: ack.video_directories - || (ack.video_root ? [ack.video_root] : []), - music: ack.music_directories - || (ack.audio_root ? [ack.audio_root] : []), - photo: ack.photo_directories || ack.photo_roots || [], + video: ack.video_directories || [], + music: ack.music_directories || [], + photo: ack.photo_directories || [], }); setChatDirectory(ack.chat_directory || ''); setChatLinkPreview(ack.chat_link_preview !== false); @@ -374,16 +372,9 @@ function GroupPage({ groupId, group, token, username, userId, userPrefs, // recent value. transport.onTmdbConfig = (cfg) => setTmdbConfig((prev) => ({ ...(prev || {}), ...cfg })); transport.onTmdbEnabled = (enabled) => setTmdbConfig((prev) => ({ ...(prev || {}), enabled })); - // One handler for every app's directories, plus the three older - // per-app messages a node that predates the generic op still sends. + // One handler for every app's directories, keyed by the app's name. transport.onAppDirectories = (app, dirs) => setAppDirectories((prev) => ({ ...prev, [app]: dirs })); - transport.onVideoRoot = (path) => setAppDirectories( - (prev) => ({ ...prev, video: path ? [path] : [] })); - transport.onAudioRoot = (path) => setAppDirectories( - (prev) => ({ ...prev, music: path ? [path] : [] })); - transport.onPhotoRoots = (roots) => setAppDirectories( - (prev) => ({ ...prev, photo: roots || [] })); transport.onChatDirectory = (path) => setChatDirectory(path); transport.onChatLinkPreview = (on) => setChatLinkPreview(on); transport.onMusicbrainzEnabled = (enabled) => diff --git a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js index 81d4ac2..ee99ccc 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js @@ -151,9 +151,9 @@ async function fetchGroupIndex(groupId, token, bundleKey, username, userId) { // Plural, with the old scalars as the fallback for a node still speaking // MNP 1.0 — the same reading group-page.js does on its own handshake. const roots = { - video: ack.video_directories || (ack.video_root ? [ack.video_root] : []), - music: ack.music_directories || (ack.audio_root ? [ack.audio_root] : []), - photo: ack.photo_directories || ack.photo_roots || [], + video: ack.video_directories || [], + music: ack.music_directories || [], + photo: ack.photo_directories || [], }; // Which of the reader's groups sit on their own node — the tie-breaker // when the same file is announced by several of them diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js index 2e3712c..32005b7 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js @@ -75,8 +75,8 @@ function _aborted() { // back-to-back sequence) fired two of these within milliseconds of each // other. Both admin_challenge replies, and both domain acks afterward, // were routed by nothing more than "whichever request happens to be -// oldest pending" — apps_enabled's challenge stole audio_root's slot, then -// audio_root's own request just sat there until its 30s timeout, having +// oldest pending" — apps_enabled's challenge stole app_directories' slot, +// then that request just sat there until its 30s timeout, having // never received a challenge to answer at all. Keying both hops by op name // (below, in _key and in _dispatch) fixes this without needing the node to // change anything — `op` is already on every admin_challenge, and this @@ -532,9 +532,6 @@ class MeshBayTransport { set onChatEpoch(fn) { this._onChatEpoch = fn; } set onTmdbConfig(fn) { this._onTmdbConfig = fn; } set onTmdbEnabled(fn) { this._onTmdbEnabled = fn; } - set onVideoRoot(fn) { this._onVideoRoot = fn; } - set onAudioRoot(fn) { this._onAudioRoot = fn; } - set onPhotoRoots(fn) { this._onPhotoRoots = fn; } set onMusicbrainzEnabled(fn) { this._onMusicbrainzEnabled = fn; } set onIndexProgress(fn) { this._onIndexProgress = fn; } // Fired when a message that must open under the group key does not — @@ -1961,7 +1958,7 @@ class MeshBayTransport { // signature) — carried so _sendAndWait can key this reply by op, the // same way the admin_challenge that preceded it was keyed. Without // it, two admin_response replies in flight together (e.g. one op's - // audio_root_ack arriving while another's apps_enabled_ack is still + // app_directories_ack arriving while another's apps_enabled_ack is still // pending) are matched by nothing more than arrival order. op: challenge.op, }); @@ -3133,24 +3130,6 @@ class MeshBayTransport { this._onTmdbOverride({ fileId: msg.file_id || '', tmdbId: '', mediaType: '' }); } - // Same shape: the operator changed which folder is the Videos app's - // entry point for this group. - if (msg.type === 'video_root_ack' && this._onVideoRoot) { - this._onVideoRoot(msg.path || ''); - } - - // Same shape: the operator changed which folder is the Music app's - // entry point for this group. - if (msg.type === 'audio_root_ack' && this._onAudioRoot) { - this._onAudioRoot(msg.path || ''); - } - - // Same shape: the operator replaced the Photos app's whole root set - // for this group (docs/photos.md §2.1). - if (msg.type === 'photo_roots_ack' && this._onPhotoRoots) { - this._onPhotoRoots(msg.roots || []); - } - // Per-group, like tmdb_enabled_ack above. if (msg.type === 'musicbrainz_enabled_ack' && this._onMusicbrainzEnabled) { this._onMusicbrainzEnabled(Boolean(msg.enabled)); diff --git a/packages/meshbay-hub/tests/test_app_settings_plugin.py b/packages/meshbay-hub/tests/test_app_settings_plugin.py index 892fd09..af86f12 100644 --- a/packages/meshbay-hub/tests/test_app_settings_plugin.py +++ b/packages/meshbay-hub/tests/test_app_settings_plugin.py @@ -254,17 +254,19 @@ def test_each_app_takes_a_list_of_directories(app, prop): f"{app} still reads {singular} — one shape per idea") -def test_an_older_node_still_fills_the_lists(): +def test_the_lists_are_read_under_one_name_each(): """ - A node speaking MNP 1.0 sends `video_root`, not `video_directories`. - Reading the missing plural as "nothing configured" would empty a working - Videos tab on every group hosted by a node that has not been upgraded. + One name per app on the ack — `<app>_directories`, always a list. A second + name for the same answer means a page that reads whichever it thinks of + first, and a node that fills only the other one empties a working tab. """ page = GROUP_PAGE.read_text(encoding="utf-8") block = page[page.index("setAppDirectories({"):] block = block[:block.index("setChatDirectory")] - assert "ack.video_root" in block and "ack.audio_root" in block - assert "ack.photo_roots" in block + assert "ack.video_directories" in block and "ack.music_directories" in block + assert "ack.photo_directories" in block + for gone in ("ack.video_root", "ack.audio_root", "ack.photo_roots"): + assert gone not in block, f"{gone} is a second name for the same answer" def test_the_search_cache_reads_both_shapes(): |