mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 07:32:02 +00:00
check for search and queryParams
This commit is contained in:
parent
3de87ce5bd
commit
30c3e4b6ed
1 changed files with 8 additions and 2 deletions
|
|
@ -14,14 +14,20 @@ const useSelectedAddon = (transportUrl) => {
|
||||||
|
|
||||||
fetch(transportUrl)
|
fetch(transportUrl)
|
||||||
.then((resp) => resp.json())
|
.then((resp) => resp.json())
|
||||||
.then((manifest) => setAddon({ ...manifest, transportUrl }));
|
.then((manifest) => setAddon({ manifest, transportUrl, flags: {} }));
|
||||||
}, [transportUrl]);
|
}, [transportUrl]);
|
||||||
const clear = React.useCallback(() => {
|
const clear = React.useCallback(() => {
|
||||||
if (active) {
|
if (active) {
|
||||||
const { pathname, search } = UrlUtils.parse(locationHash.slice(1));
|
const { pathname, search } = UrlUtils.parse(locationHash.slice(1));
|
||||||
const queryParams = new URLSearchParams(search);
|
const queryParams = new URLSearchParams(search);
|
||||||
queryParams.delete('addon');
|
queryParams.delete('addon');
|
||||||
window.location.replace(`#${pathname}?${queryParams.toString()}`);
|
if (search && queryParams) {
|
||||||
|
window.location.replace(`#${pathname}?${queryParams.toString()}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.location.replace(`#${pathname}`);
|
||||||
|
}
|
||||||
|
setAddon(null);
|
||||||
}
|
}
|
||||||
}, [active]);
|
}, [active]);
|
||||||
return [addon, clear];
|
return [addon, clear];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue