fix(frontend): jobs name their chats, open links tab counts only links that are really open

This commit is contained in:
hh committed 2026-10-19 03:53:08 +00:00
1 parent 4082adba25
commit 90b37ec708
2 files changed
+10 -6

No files matched your search

@@ -6,6 +6,7 @@
import { locale, t } from "#lib/i18n/locale.svelte.js"; import { locale, t } from "#lib/i18n/locale.svelte.js";
import type { MessageKey } from "#lib/i18n/messages.js"; import type { MessageKey } from "#lib/i18n/messages.js";
import { accounts } from "#lib/stores/accounts.svelte.js"; import { accounts } from "#lib/stores/accounts.svelte.js";
import { chats } from "#lib/stores/chats.svelte.js";
import { toasts } from "#lib/stores/toasts.svelte.js"; import { toasts } from "#lib/stores/toasts.svelte.js";
interface Props { interface Props {
@@ -75,6 +76,9 @@
async function load() { async function load() {
jobs = await listJobs(); jobs = await listJobs();
chats.ensureMany(
jobs.map(chatId).filter((id): id is number => id !== null)
);
loading = false; loading = false;
schedule(); schedule();
} }
@@ -100,6 +104,10 @@
return typeof value === "number" ? value : null; return typeof value === "number" ? value : null;
} }
function chatLabel(id: number): string {
return chats.byId(id)?.title ?? t("jobs.chat", { id });
}
$effect(() => { $effect(() => {
if (version >= 0 && accounts.selectedId !== null) { if (version >= 0 && accounts.selectedId !== null) {
load().catch(() => { load().catch(() => {
@@ -141,7 +149,7 @@
</div> </div>
<div class="meta"> <div class="meta">
{#if chat !== null} {#if chat !== null}
<span>{t("jobs.chat", { id: chat })}</span> <span>{chatLabel(chat)}</span>
{/if} {/if}
{#if count !== null} {#if count !== null}
<span> <span>
@@ -29,7 +29,6 @@
let items = $state<FileShare[]>([]); let items = $state<FileShare[]>([]);
let loading = $state(false); let loading = $state(false);
let filter = $state<Filter>("active"); let filter = $state<Filter>("active");
let fetchedAll = $state(false);
let expanded = $state<number | null>(null); let expanded = $state<number | null>(null);
let token = 0; let token = 0;
@@ -39,9 +38,7 @@
: items : items
); );
const activeCount = $derived( const activeCount = $derived(
fetchedAll items.filter((item) => shareState(item) === "active").length
? items.filter((item) => shareState(item) === "active").length
: items.length
); );
async function load() { async function load() {
@@ -53,7 +50,6 @@
const rows = await listShares(activeOnly); const rows = await listShares(activeOnly);
if (current === token) { if (current === token) {
items = rows; items = rows;
fetchedAll = !activeOnly;
} }
} catch { } catch {
if (current === token) { if (current === token) {