From d8f1d7bcbd3ee6f15cad76d396bd891d4346de87 Mon Sep 17 00:00:00 2001 From: digital-garbage <133010426+digital-garbage@users.noreply.github.com> Date: Tue, 10 Nov 2026 01:03:33 +0200 Subject: [PATCH] Reference sheet: tell the media bin to refresh (it listens for "media") Co-Authored-By: Claude Sonnet 5.5 --- app/ui/features/refsheet/hub.test.js | 4 +++- app/ui/features/refsheet/index.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/ui/features/refsheet/hub.test.js b/app/ui/features/refsheet/hub.test.js index 03302408..b3c5f723 100644 --- a/app/ui/features/refsheet/hub.test.js +++ b/app/ui/features/refsheet/hub.test.js @@ -33,9 +33,10 @@ test("it is hidden when the server has no refsheet module, and the button opens const host = document.createElement("div"); offer("assets.actions", host); let sent; + const said = []; const api = { media: async () => ({ media: [{ id: "a", name: "front.png", kind: "image" }, { id: "v", name: "clip.mp4", kind: "video" }] }), uploadMedia: async () => ({ media: [], problems: [] }), refsheetMake: async (b) => { sent = b; return { media: { id: "n", name: "Sheet.png" }, missing: [] }; } }; - const app = { api, dom: { pickFile: async () => null }, say() {}, hasModule: () => false }; + const app = { api, dom: { pickFile: async () => null }, say: (w) => said.push(w), hasModule: () => false }; const none = await loadFeatures(["x"], { load: async () => ({ default: hub }), app, has: (n) => n in app }); assert.equal(none.mounted.length, 0); @@ -63,6 +64,7 @@ test("it is hidden when the server has no refsheet module, and the button opens make.click(); await new Promise((r) => setTimeout(r, 20)); assert.deepEqual(sent, { title: "", rows: 2, cols: 3, format: "1:1", width: 512, slots: [{ picture: "a", label: undefined }] }); + assert.ok(said.includes("media")); // the media bin redraws on "media" mounted[0].teardown(); assert.equal(host.textContent, ""); }); diff --git a/app/ui/features/refsheet/index.js b/app/ui/features/refsheet/index.js index 6be2c7f6..35bfc241 100644 --- a/app/ui/features/refsheet/index.js +++ b/app/ui/features/refsheet/index.js @@ -28,7 +28,7 @@ export default { if (!file) return; const got = await app.api.uploadMedia([file]); if (got.problems.length) c.toast.warn({ text: got.problems[0] }); - if (got.media[0]) { await reload(); state.slots[i].picture = got.media[0].id; app.say("bin"); } + if (got.media[0]) { await reload(); state.slots[i].picture = got.media[0].id; app.say("media"); } }; // The bin itself, as pictures with their names: one click chooses, Escape or the close button keeps what was there. let picking = null; @@ -58,7 +58,7 @@ export default { make.setBusy(true); try { const out = await app.api.refsheetMake(request(state)); - await reload(); app.say("bin"); + await reload(); app.say("media"); c.toast.good({ text: `Saved “${out.media.name}” to the media bin.` }); if (out.missing.length) c.toast.warn({ text: `Left empty (picture gone or not readable): ${out.missing.join(", ")}.` }); win.close("done");