fix(ui,i18n): E30 review round 3 — the stored language follows the screen, a fresh text starts collapsed, Retry waits again
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { compareText } from "./collate";
|
||||
import { serverOrderLang } from "./saveLanguage";
|
||||
|
||||
// The channel manager's list order, and the priority steps its menu offers (E28 S3e3b).
|
||||
|
||||
@@ -32,14 +33,16 @@ function before(a: Ordered, b: Ordered, lang: string): boolean {
|
||||
|
||||
/** `rows` with the channel `id` taken out and put back where its priority now places it, every
|
||||
* other row left exactly where it was — the server's order, without a refetch that would reorder
|
||||
* anything the reader did not touch. */
|
||||
* anything the reader did not touch. It takes the account's `preferences`, not a language: the
|
||||
* server sorts in the STORED language (`serverOrderLang`), which a UI language is not always. */
|
||||
export function placeByPriority<T extends Ordered>(
|
||||
rows: readonly T[],
|
||||
id: string,
|
||||
lang: string,
|
||||
preferences: Record<string, unknown> | null | undefined,
|
||||
): T[] {
|
||||
const moved = rows.find((r) => r.id === id);
|
||||
if (!moved) return [...rows];
|
||||
const lang = serverOrderLang(preferences);
|
||||
const rest = rows.filter((r) => r !== moved);
|
||||
const at = rest.findIndex((r) => before(moved, r, lang));
|
||||
rest.splice(at < 0 ? rest.length : at, 0, moved);
|
||||
|
||||
Reference in New Issue
Block a user