Reference sheet: tell the media bin to refresh (it listens for "media")

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
digital-garbage
2026-11-10 01:03:33 +02:00
co-authored by Claude Sonnet 5.5
parent 1faeb30000
commit d8f1d7bcbd
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -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, "");
});
+2 -2
View File
@@ -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");