mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
Merge pull request #871 from Stremio/feat/shell-open-addons
Some checks failed
Build / build (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
App(Shell): support opening addons from deeplink
This commit is contained in:
commit
acb441bbcf
1 changed files with 17 additions and 2 deletions
|
|
@ -100,14 +100,29 @@ const App = () => {
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Handle shell window visibility changed event
|
// Handle shell events
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const onWindowVisibilityChanged = (state) => {
|
const onWindowVisibilityChanged = (state) => {
|
||||||
setWindowHidden(state.visible === false && state.visibility === 0);
|
setWindowHidden(state.visible === false && state.visibility === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onOpenMedia = (data) => {
|
||||||
|
if (data.startsWith('stremio:///')) return;
|
||||||
|
if (data.startsWith('stremio://')) {
|
||||||
|
const transportUrl = data.replace('stremio://', 'https://');
|
||||||
|
if (URL.canParse(transportUrl)) {
|
||||||
|
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
shell.on('win-visibility-changed', onWindowVisibilityChanged);
|
shell.on('win-visibility-changed', onWindowVisibilityChanged);
|
||||||
return () => shell.off('win-visibility-changed', onWindowVisibilityChanged);
|
shell.on('open-media', onOpenMedia);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
shell.off('win-visibility-changed', onWindowVisibilityChanged);
|
||||||
|
shell.off('open-media', onOpenMedia);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue