fix(frontend): a filter written to the url survives another url write, the chat picked with alt and arrows stays in view
This commit is contained in:
1 parent
8a1723e99f
commit
e977ab77a8
2 files changed
+26
-6
No files matched your search
@@ -83,6 +83,11 @@
|
||||
if (index === -1 || viewport === null) {
|
||||
return;
|
||||
}
|
||||
const row = viewport.querySelector<HTMLElement>(".Chat.selected");
|
||||
if (row) {
|
||||
row.scrollIntoView({ block: "nearest" });
|
||||
return;
|
||||
}
|
||||
const top = index * rowHeight;
|
||||
if (top < viewport.scrollTop) {
|
||||
viewport.scrollTop = top;
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/state";
|
||||
|
||||
export async function replaceParam(
|
||||
key: string,
|
||||
value: string | null
|
||||
): Promise<void> {
|
||||
const ATTEMPTS = 2;
|
||||
|
||||
function withParam(key: string, value: string | null): URL {
|
||||
const url = new URL(page.url.href);
|
||||
if (value === null) {
|
||||
url.searchParams.delete(key);
|
||||
} else {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
if (url.href !== page.url.href) {
|
||||
await goto(url, { replace: true, reset: false, state: { ...page.state } });
|
||||
return url;
|
||||
}
|
||||
|
||||
export async function replaceParam(
|
||||
key: string,
|
||||
value: string | null
|
||||
): Promise<void> {
|
||||
for (let attempt = 0; attempt < ATTEMPTS; attempt += 1) {
|
||||
const url = withParam(key, value);
|
||||
if (url.href === page.url.href) {
|
||||
return;
|
||||
}
|
||||
// biome-ignore lint/performance/noAwaitInLoops: a write overtaken by another navigation is retried once
|
||||
await goto(url, {
|
||||
replace: true,
|
||||
reset: false,
|
||||
state: { ...page.state },
|
||||
}).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user