From 32b1d0e272619f5042aa62d050f3bd2cd91e00de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 17 Jun 2026 16:58:43 +0200 Subject: [PATCH] Restore list scroll position on back/forward Navigating away from a list and back via history (the sidebar back/forward buttons) returns to the same scroll position with the previously loaded pages intact, instead of refetching only the first page at the top. --- crates/radicle-types/src/outbound/sqlite.rs | 8 +- src/components/VirtualList.svelte | 40 +++++- src/lib/listState.ts | 41 ++++++ src/lib/router.ts | 29 ++++- src/views/repo/Issues.svelte | 134 +++++++++++++++----- src/views/repo/Patches.svelte | 134 +++++++++++++++----- src/views/repo/RepoCommits.svelte | 52 +++++++- 7 files changed, 355 insertions(+), 83 deletions(-) create mode 100644 src/lib/listState.ts diff --git a/crates/radicle-types/src/outbound/sqlite.rs b/crates/radicle-types/src/outbound/sqlite.rs index b5735efb6..02485e0f9 100644 --- a/crates/radicle-types/src/outbound/sqlite.rs +++ b/crates/radicle-types/src/outbound/sqlite.rs @@ -74,7 +74,7 @@ impl PatchStorage for Sqlite { ) AS last_revision_timestamp FROM patches AS p WHERE repo = ?1 - ORDER BY last_revision_timestamp DESC; + ORDER BY last_revision_timestamp DESC, id DESC; ", )?; stmt.bind((1, &rid))?; @@ -99,7 +99,7 @@ impl PatchStorage for Sqlite { FROM patches AS p WHERE repo = ?1 AND patch->>'$.state.status' = ?2 - ORDER BY last_revision_timestamp DESC; + ORDER BY last_revision_timestamp DESC, id DESC; ", )?; stmt.bind((1, &rid))?; @@ -125,7 +125,7 @@ impl IssueStorage for Sqlite { ) AS created_timestamp FROM issues AS i WHERE repo = ?1 - ORDER BY created_timestamp DESC; + ORDER BY created_timestamp DESC, id DESC; ", )?; stmt.bind((1, &rid))?; @@ -150,7 +150,7 @@ impl IssueStorage for Sqlite { FROM issues AS i WHERE repo = ?1 AND issue->>'$.state.status' = ?2 - ORDER BY created_timestamp DESC; + ORDER BY created_timestamp DESC, id DESC; ", )?; stmt.bind((1, &rid))?; diff --git a/src/components/VirtualList.svelte b/src/components/VirtualList.svelte index 10cd2bd3f..adea1090d 100644 --- a/src/components/VirtualList.svelte +++ b/src/components/VirtualList.svelte @@ -1,8 +1,11 @@