@@ -29,35 +29,29 @@
|
|||||||
let convo = $state(1);
|
let convo = $state(1);
|
||||||
|
|
||||||
let talkFiles: FileList | undefined = $state();
|
let talkFiles: FileList | undefined = $state();
|
||||||
const talkData = $derived.by(async () => {
|
let readIDs = new SvelteSet<number>();
|
||||||
|
let talkFileInvalid = $state(false);
|
||||||
|
async function setRead(f: FileList) {
|
||||||
|
talkFiles = f;
|
||||||
|
readIDs.clear();
|
||||||
|
talkFileInvalid = false;
|
||||||
if (talkFiles == null || talkFiles.length === 0) {
|
if (talkFiles == null || talkFiles.length === 0) {
|
||||||
return undefined;
|
return;
|
||||||
}
|
}
|
||||||
const t = await talkFiles[0].text();
|
const t = await talkFiles[0].text();
|
||||||
const d = JSON.parse(t);
|
const d = JSON.parse(t);
|
||||||
return talk.Gallery.safeDecode(d);
|
const g = talk.Gallery.safeDecode(d);
|
||||||
});
|
if (!g.success) {
|
||||||
const readIDs = $derived.by(async () => {
|
talkFileInvalid = true;
|
||||||
const d = await talkData;
|
console.warn(g.error);
|
||||||
const s = new SvelteSet<number>();
|
return;
|
||||||
if (d == null) {
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
if (!d.success) {
|
for (const e of g.data.talk_gallery_list) {
|
||||||
console.warn(d.error);
|
readIDs.add(e.home_story_trigger_id);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
for (const e of d.data.talk_gallery_list) {
|
|
||||||
s.add(e.home_story_trigger_id);
|
|
||||||
}
|
}
|
||||||
return s;
|
const conversations = $derived(allConvos.filter((c) => !readIDs.has(c.id)));
|
||||||
});
|
const convoMap = $derived(byChara(conversations));
|
||||||
const talkFileErrs = $derived((await talkData)?.error?.issues);
|
|
||||||
const conversations = $derived.by(async () => {
|
|
||||||
const s = await readIDs;
|
|
||||||
return allConvos.filter((c) => !s.has(c.id));
|
|
||||||
});
|
|
||||||
const convoMap = $derived(byChara(await conversations));
|
|
||||||
const selCharas = $derived(characters.filter((c) => convoMap.has(c.chara_id)));
|
const selCharas = $derived(characters.filter((c) => convoMap.has(c.chara_id)));
|
||||||
|
|
||||||
const options = $derived(convoMap.get(chara?.chara_id ?? 0) ?? []);
|
const options = $derived(convoMap.get(chara?.chara_id ?? 0) ?? []);
|
||||||
@@ -96,9 +90,19 @@
|
|||||||
<label for="talkgallery" class="block">
|
<label for="talkgallery" class="block">
|
||||||
Select <span class="inline-block font-mono">talk_gallery_data.json</span> to hide read conversations.
|
Select <span class="inline-block font-mono">talk_gallery_data.json</span> to hide read conversations.
|
||||||
</label>
|
</label>
|
||||||
<input type="file" class="appearance-auto" accept="application/json" id="talkgallery" bind:files={talkFiles} />
|
<input
|
||||||
|
type="file"
|
||||||
|
class="rounded-full p-4"
|
||||||
|
accept="application/json"
|
||||||
|
id="talkgallery"
|
||||||
|
bind:files={() => talkFiles ?? new DataTransfer().files, setRead}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="ml-4 rounded-full bg-mist-300 p-2 hover:cursor-pointer dark:bg-mist-900"
|
||||||
|
onclick={() => setRead(new DataTransfer().files)}>Reset</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
{#if (talkFileErrs?.length ?? 0) > 0}
|
{#if talkFileInvalid}
|
||||||
<div class="col-span-full">Invalid File</div>
|
<div class="col-span-full">Invalid File</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user