From 53ffa321d84551be251d116717253b5ab9d62836 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 20 Mar 2025 11:00:30 +0100 Subject: [PATCH] feat(App): handle shell open-media event to open addons --- src/App/App.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/App/App.js b/src/App/App.js index d3a1ce188..d4c55be32 100644 --- a/src/App/App.js +++ b/src/App/App.js @@ -100,14 +100,26 @@ const App = () => { }; }, []); - // Handle shell window visibility changed event + // Handle shell events React.useEffect(() => { const onWindowVisibilityChanged = (state) => { setWindowHidden(state.visible === false && state.visibility === 0); }; + const onOpenMedia = (data) => { + if (data.startsWith('stremio://')) { + const transportUrl = data.replace('stremio://', 'https://'); + window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`; + } + }; + 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(() => {