diff options
| author | Matt Goldspink <mattgoldspink1@gmail.com> | 2023-01-23 08:44:23 -0800 |
|---|---|---|
| committer | Matt Goldspink <mattgoldspink1@gmail.com> | 2023-01-23 08:44:23 -0800 |
| commit | f1f7541069eabd5234bb03676f0728ddb2a09ef7 (patch) | |
| tree | dcd78fb19f7d3d2535cb829f037228ac1c778267 /src/web | |
| parent | 31fb7f8baefbbfc478838137e0321b6e49ad78a2 (diff) | |
| download | slskd-f1f7541069eabd5234bb03676f0728ddb2a09ef7.tar.gz | |
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.
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/src/components/App.js | 5 | ||||
| -rw-r--r-- | src/web/src/components/Search/Searches.js | 2 |
2 files changed, 5 insertions, 2 deletions
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 { <System {...props} state={applicationState} options={applicationOptions} /> ) }/> - <Redirect from='*' to={`${urlBase}/searches`}/> + <Route render={(props) => + /\/(searches\/?|browse|users|chat|rooms|uploads|downloads|system\/)/ + .test(props.location.pathname) ? + <></> : <Redirect to={`${urlBase}/searches`}/>} /> </>} </Switch> </AppContext.Provider> 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(() => { |
