Image support!
Some checks failed
Test / test (push) Failing after 5s
Build and Deploy Nuxt / build (push) Successful in 1m46s

This commit is contained in:
2026-11-20 19:10:28 +01:00
parent d61659cfdd
commit fe662bb351
11 changed files with 119 additions and 21 deletions

View File

@@ -9,14 +9,15 @@ import { BuildLinkSuggestions } from './LinkAutocomplete';
const CACHE_TTL = 30 * 1000;
const cache = new Map(); // campaignId → { at, promise }
// The campaign's four lists as the API answers them. The note preview needs the entry itself (a
// The campaign's lists as the API answers them. The note preview needs the entry itself (a
// character sheet, an item), not only the label the suggestion carries, so the lists are kept as
// they arrive and both readers resolve from the same round of requests.
const LIST_PATHS = {
note: { path: '/note/all', key: 'notes' },
actor: { path: '/actor/list', key: 'actors' },
item: { path: '/item/list', key: 'items' },
map: { path: '/map/list', key: 'maps' }
map: { path: '/map/list', key: 'maps' },
media: { path: '/media/list', key: 'media' }
};
async function fetchList(campaignId, path, key) {
@@ -32,7 +33,7 @@ async function fetchList(campaignId, path, key) {
function LoadCampaignEntries(campaignId) {
const id = campaignId ? String(campaignId) : '';
if (!id) {
return Promise.resolve({ notes: [], actors: [], items: [], maps: [] });
return Promise.resolve({ notes: [], actors: [], items: [], maps: [], media: [] });
}
const cached = cache.get(id);
@@ -40,7 +41,7 @@ function LoadCampaignEntries(campaignId) {
const promise = Promise.all(
Object.values(LIST_PATHS).map(({ path, key }) => fetchList(id, path, key))
).then(([notes, actors, items, maps]) => ({ notes, actors, items, maps }));
).then(([notes, actors, items, maps, media]) => ({ notes, actors, items, maps, media }));
cache.set(id, { at: Date.now(), promise });
return promise;