aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorMatt Goldspink <mattgoldspink1@gmail.com>2023-01-23 08:44:23 -0800
committerMatt Goldspink <mattgoldspink1@gmail.com>2023-01-23 08:44:23 -0800
commitf1f7541069eabd5234bb03676f0728ddb2a09ef7 (patch)
treedcd78fb19f7d3d2535cb829f037228ac1c778267 /src/web
parent31fb7f8baefbbfc478838137e0321b6e49ad78a2 (diff)
downloadslskd-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.js5
-rw-r--r--src/web/src/components/Search/Searches.js2
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(() => {