fix(ui,i18n): E30 review round 2 — honest bio failure, a full show summary, one HU name per thing
- Person page: a bio ask that fails says so with a retry instead of reading as 'no biography'. - Show page: the summary is a ClampedText (5 lines + More), like the person and collection pages; one More/Less pair (plex.textMore/textLess) for all three. - Channels: a re-slotted row is placed in the language the server orders by (the stored preference, else English), not the UI's guess. - A skipped run's body is only the reason (its title already says skipped). - HU: Behúzási kvótatartalék; Eseménynapló ürítve / az eseménynaplót; indok; közvetlenül játszható / közvetlen közvetítés in the Plex hints. - Tests: ClampedText re-measures on a resize, the show summary clamp, serverOrderLang.
This commit is contained in:
@@ -23,7 +23,7 @@ describe("a job's result", () => {
|
||||
"hu",
|
||||
),
|
||||
).toBe(
|
||||
"friss (feldolgozott csatorna: 0 · hozzáadott videó: 0 · ok: nincs szolgáltatásfiók) · " +
|
||||
"friss (feldolgozott csatorna: 0 · hozzáadott videó: 0 · indok: nincs szolgáltatásfiók) · " +
|
||||
"mély (feldolgozott csatorna: 2 · hozzáadott videó: 5 · teljesen egyeztetve: 1)",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ export function jobResultText(t: TFunction, result: JobResult, lang: string): st
|
||||
|
||||
/** What a job run said, as the inbox notice and the audit row both show it (E30): a title naming the job
|
||||
* and how the run ended, and its result in the reader's language — from the data when it rode along,
|
||||
* else read back from the English one-liner. A run skipped for a pause names why; a failed run keeps the
|
||||
* else read back from the English one-liner. A skipped run names only why; a failed run keeps the
|
||||
* upstream's own error text (it is diagnostic). */
|
||||
export function jobRunText(
|
||||
t: TFunction,
|
||||
@@ -63,8 +63,21 @@ export function jobRunText(
|
||||
: (parseSummary(summary) ??
|
||||
(run.status === "skipped" && summary ? { skipped: summary } : null));
|
||||
}
|
||||
// A skipped run's title already says "skipped": its body is only the reason, not "skipped: <reason>".
|
||||
const reason = run.status === "skipped" ? onlySkipReason(result) : null;
|
||||
return {
|
||||
title: t(titleKey, { job }),
|
||||
body: result ? jobResultText(t, result, lang) : summary,
|
||||
body:
|
||||
reason !== null
|
||||
? t(`scheduler.skip.${vocabKey(reason)}`, { defaultValue: reason })
|
||||
: result
|
||||
? jobResultText(t, result, lang)
|
||||
: summary,
|
||||
};
|
||||
}
|
||||
|
||||
function onlySkipReason(result: JobResult | null): string | null {
|
||||
const keys = result ? Object.keys(result) : [];
|
||||
const word = result?.skipped;
|
||||
return keys.length === 1 && typeof word === "string" ? word : null;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
import { api } from "./api";
|
||||
import { LANGUAGE_ORDERED, qk } from "./queryKeys";
|
||||
import { saveLanguage } from "./saveLanguage";
|
||||
import { saveLanguage, serverOrderLang } from "./saveLanguage";
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
@@ -37,3 +37,12 @@ describe("saveLanguage", () => {
|
||||
expect(asked).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("serverOrderLang", () => {
|
||||
it("is the stored language, else English — never the UI's guess", () => {
|
||||
expect(serverOrderLang({ language: "hu" })).toBe("hu");
|
||||
expect(serverOrderLang({})).toBe("en"); // nothing stored: the server sorts in English
|
||||
expect(serverOrderLang({ language: "de" })).toBe("en");
|
||||
expect(serverOrderLang(undefined)).toBe("en");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import { isSupported } from "../i18n";
|
||||
import { api } from "./api";
|
||||
import { LANGUAGE_ORDERED } from "./queryKeys";
|
||||
|
||||
@@ -9,3 +10,11 @@ export async function saveLanguage(qc: QueryClient, code: string): Promise<void>
|
||||
await api.savePrefs({ language: code });
|
||||
for (const queryKey of LANGUAGE_ORDERED) void qc.invalidateQueries({ queryKey });
|
||||
}
|
||||
|
||||
/** The language the server orders this account's lists in (backend `mailtext.lang_for_user`): the
|
||||
* stored preference, else English. Not always the UI's — a browser-detected language, or one picked
|
||||
* while signed out, is never stored — so a list re-slotted here to match the server's order uses it. */
|
||||
export function serverOrderLang(preferences: Record<string, unknown> | null | undefined): string {
|
||||
const lang = preferences?.language;
|
||||
return typeof lang === "string" && isSupported(lang) ? lang : "en";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user