refactor(frontend): saved and transcription results show where they were asked, not in a toast

This commit is contained in:
hh committed 2026-10-28 01:56:19 +00:00
1 parent 58b4346166
commit fb869e767b
7 files changed
+127 -36

No files matched your search

+4 -3
View File
@@ -1,7 +1,6 @@
import { requestTranscription } from "#lib/api/media.js";
import { t } from "#lib/i18n/locale.svelte.js";
import type { MessageKey } from "#lib/i18n/messages.js";
import { toasts } from "#lib/stores/toasts.svelte.js";
const REFUSALS: Record<string, MessageKey> = {
empty: "media.transcribeEmpty",
@@ -14,6 +13,7 @@ export class Transcript {
readonly #chatId: () => number;
readonly #messageId: () => number;
readonly #initial: () => string | null;
failure = $state<string | null>(null);
fetched = $state<string | null>(null);
pending = $state(false);
shown = $state(false);
@@ -45,6 +45,7 @@ export class Transcript {
return;
}
this.pending = true;
this.failure = null;
try {
const outcome = await requestTranscription(
this.#chatId(),
@@ -54,10 +55,10 @@ export class Transcript {
this.fetched = outcome.text;
this.shown = true;
} else {
toasts.error(t(REFUSALS[outcome.error] ?? "media.transcribeFailed"));
this.failure = t(REFUSALS[outcome.error] ?? "media.transcribeFailed");
}
} catch {
toasts.error(t("media.transcribeFailed"));
this.failure = t("media.transcribeFailed");
} finally {
this.pending = false;
}