mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 23:12:13 +00:00
Merge branch 'development' of https://github.com/Stremio/stremio-web into refactor/catalog-title-translate-key
This commit is contained in:
commit
75b3825312
5 changed files with 64 additions and 5 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -36,7 +36,7 @@
|
|||
"react-i18next": "^12.1.1",
|
||||
"react-is": "18.2.0",
|
||||
"spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
|
||||
"stremio-translations": "github:Stremio/stremio-translations#12b1307f95249496960d2a257b371db5700721e6",
|
||||
"stremio-translations": "github:Stremio/stremio-translations#38d283adf4bbe6d29657b5023778e30af7f6b05a",
|
||||
"url": "0.11.0",
|
||||
"use-long-press": "^3.1.5"
|
||||
},
|
||||
|
|
@ -12452,8 +12452,8 @@
|
|||
},
|
||||
"node_modules/stremio-translations": {
|
||||
"version": "1.44.5",
|
||||
"resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#12b1307f95249496960d2a257b371db5700721e6",
|
||||
"integrity": "sha512-929O9sIUph3ew4YlUfD/zoMUSAYmwrjRIS+opmft3Gi8qS36/gBrH8RYW8XvgkTon+xrgqr7hC2/QSck4tgrAA==",
|
||||
"resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#38d283adf4bbe6d29657b5023778e30af7f6b05a",
|
||||
"integrity": "sha512-O/uFENWQ/pXEw4hQ1XQ8e4g6ZeX80wrhrxZfaGq2svK2I3bC/gCe5et0lbVzFBkVefSP3o1BMrlhgoSqfQssqA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
"react-i18next": "^12.1.1",
|
||||
"react-is": "18.2.0",
|
||||
"spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
|
||||
"stremio-translations": "github:Stremio/stremio-translations#12b1307f95249496960d2a257b371db5700721e6",
|
||||
"stremio-translations": "github:Stremio/stremio-translations#38d283adf4bbe6d29657b5023778e30af7f6b05a",
|
||||
"url": "0.11.0",
|
||||
"use-long-press": "^3.1.5"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ const { NotFound } = require('stremio/routes');
|
|||
const { ToastProvider, TooltipProvider, CONSTANTS, withCoreSuspender } = require('stremio/common');
|
||||
const ServicesToaster = require('./ServicesToaster');
|
||||
const DeepLinkHandler = require('./DeepLinkHandler');
|
||||
const SearchParamsHandler = require('./SearchParamsHandler');
|
||||
const ErrorDialog = require('./ErrorDialog');
|
||||
const withProtectedRoutes = require('./withProtectedRoutes');
|
||||
const routerViewsConfig = require('./routerViewsConfig');
|
||||
|
|
@ -164,6 +165,7 @@ const App = () => {
|
|||
<TooltipProvider className={styles['tooltip-container']}>
|
||||
<ServicesToaster />
|
||||
<DeepLinkHandler />
|
||||
<SearchParamsHandler />
|
||||
<RouterWithProtectedRoutes
|
||||
className={styles['router']}
|
||||
viewsConfig={routerViewsConfig}
|
||||
|
|
|
|||
57
src/App/SearchParamsHandler.js
Normal file
57
src/App/SearchParamsHandler.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// Copyright (C) 2017-2023 Smart code 203358507
|
||||
|
||||
const React = require('react');
|
||||
const isEqual = require('lodash.isequal');
|
||||
const { withCoreSuspender, useProfile, useToast } = require('stremio/common');
|
||||
const { useServices } = require('stremio/services');
|
||||
|
||||
const SearchParamsHandler = () => {
|
||||
const { core } = useServices();
|
||||
const profile = useProfile();
|
||||
const toast = useToast();
|
||||
|
||||
const [searchParams, setSearchParams] = React.useState({});
|
||||
|
||||
const onLocationChange = () => {
|
||||
const { origin, hash, search } = window.location;
|
||||
const { searchParams } = new URL(`${origin}${hash.replace('#', '')}${search}`);
|
||||
|
||||
setSearchParams((previousSearchParams) => {
|
||||
const currentSearchParams = Object.fromEntries(searchParams.entries());
|
||||
return isEqual(previousSearchParams, currentSearchParams) ? previousSearchParams : currentSearchParams;
|
||||
});
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
const { streamingServerUrl } = searchParams;
|
||||
|
||||
if (streamingServerUrl) {
|
||||
core.transport.dispatch({
|
||||
action: 'Ctx',
|
||||
args: {
|
||||
action: 'UpdateSettings',
|
||||
args: {
|
||||
...profile.settings,
|
||||
streamingServerUrl,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: `Using streaming server at ${streamingServerUrl}`,
|
||||
timeout: 4000,
|
||||
});
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
React.useEffect(() => {
|
||||
onLocationChange();
|
||||
window.addEventListener('hashchange', onLocationChange);
|
||||
return () => window.removeEventListener('hashchange', onLocationChange);
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
module.exports = withCoreSuspender(SearchParamsHandler);
|
||||
|
|
@ -153,7 +153,7 @@ const SearchBar = React.memo(({ className, query, active }) => {
|
|||
localSearch?.items?.length ?
|
||||
<div className={styles['items']}>
|
||||
<div className={styles['title']}>
|
||||
<div className={styles['label']}>{ t('Recommendations') }</div>
|
||||
<div className={styles['label']}>{ t('SEARCH_SUGGESTIONS') }</div>
|
||||
</div>
|
||||
{
|
||||
localSearch.items.map(({ query, deepLinks }, index) => (
|
||||
|
|
|
|||
Loading…
Reference in a new issue