From f1f7541069eabd5234bb03676f0728ddb2a09ef7 Mon Sep 17 00:00:00 2001 From: Matt Goldspink Date: Mon, 23 Jan 2023 08:44:23 -0800 Subject: Fixing #555 to allow browser reload to stay on the same page. There were 2 issues here: 1. The Redirect in App.js seems to be being hit on reload always and would always force a redirect. I tried googling but couldn't find a good answer why and how to workaround it, so I've just excluded our known paths from that redirect. 2. Even after this in Searches.js there's a race condition with the component being connected and starting to process the searchId, but the searches haven't been set yet, so it assumes it's invalid and resets to /searches. So I've swapped the order in onUpdate and that seems to fix it with no side effects. --- src/web/src/components/App.js | 5 ++++- src/web/src/components/Search/Searches.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js index 70d154af..74ae2cd8 100644 --- a/src/web/src/components/App.js +++ b/src/web/src/components/App.js @@ -356,7 +356,10 @@ class App extends Component { ) }/> - + + /\/(searches\/?|browse|users|chat|rooms|uploads|downloads|system\/)/ + .test(props.location.pathname) ? + <> : } /> } diff --git a/src/web/src/components/Search/Searches.js b/src/web/src/components/Search/Searches.js index 46a9f709..42b82f8c 100644 --- a/src/web/src/components/Search/Searches.js +++ b/src/web/src/components/Search/Searches.js @@ -42,8 +42,8 @@ const Searches = ({ server }) => { const onConnectionError = (error) => { setConnecting(false); setError(error); }; const onUpdate = (update) => { - onConnected(); setSearches(update); + onConnected(); }; useEffect(() => { -- cgit v1.2.3