refactor: use useShell hook for UpdaterBanner

This commit is contained in:
Tim 2025-01-30 14:57:37 +01:00
parent e5882ea143
commit 77e283d934
4 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import Icon from '@stremio/stremio-icons/react';
import { useServices } from 'stremio/services';
import { useBinaryState } from 'stremio/common';
import { useBinaryState, useShell } from 'stremio/common';
import { Button, Transition } from 'stremio/components';
import styles from './UpdaterBanner.less';
@ -11,17 +11,18 @@ type Props = {
const UpdaterBanner = ({ className }: Props) => {
const { shell } = useServices();
const shellTransport = useShell();
const [visible, show, hide] = useBinaryState(false);
const onInstallClick = () => {
shell.transport && shell.transport.send('autoupdater-notif-clicked');
shellTransport.send('autoupdater-notif-clicked');
};
useEffect(() => {
shell.on('autoupdater-show-notif', show);
shell.transport && shell.transport.on('autoupdater-show-notif', show);
return () => {
shell.off('autoupdater-show-notif', show);
shell.transport && shell.transport.off('autoupdater-show-notif', show);
};
});

View file

@ -1,6 +1,6 @@
import React, { createContext, useContext } from 'react';
import { WHITELISTED_HOSTS } from 'stremio/common/CONSTANTS';
import useShell from './useShell';
import { useShell } from 'stremio/common';
import { name, isMobile } from './device';
interface PlatformContext {

View file

@ -19,6 +19,7 @@ const useModelState = require('./useModelState');
const useNotifications = require('./useNotifications');
const useOnScrollToBottom = require('./useOnScrollToBottom');
const useProfile = require('./useProfile');
const { default: useShell } = require('./useShell');
const useStreamingServer = require('./useStreamingServer');
const useTorrent = require('./useTorrent');
const useTranslate = require('./useTranslate');
@ -47,6 +48,7 @@ module.exports = {
useNotifications,
useOnScrollToBottom,
useProfile,
useShell,
useStreamingServer,
useTorrent,
useTranslate,