Skip to content

Commit

Permalink
Fix: 'Back' doesn't work in RecentView because of navigation loop
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Aug 20, 2024
1 parent 195993e commit 4848673
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions mwdb/web/src/components/RecentView/Views/RecentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ export function RecentView(props: Props) {
// Optionally convert query if only hash or hashes were provided
query = multiFromHashes(query);
// Set query in URL (currentQuery, countingEnabled)
setSearchParams((prev) => {
if (query === prev.get("query"))
throw new Error("Tried to set the same query twice");
return {
...Object.fromEntries(prev.entries()),
q: query,
count: prev.get("count") === "1" ? "1" : "0",
};
});
setSearchParams(
(prev) => {
if (query === prev.get("query"))
throw new Error("Tried to set the same query twice");
return {
...Object.fromEntries(prev.entries()),
q: query,
count: prev.get("count") === "1" ? "1" : "0",
};
},
{ replace: true }
);
},
[setSearchParams]
);
Expand Down

0 comments on commit 4848673

Please sign in to comment.