mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 11:42:05 +00:00
refactor: use useShell hook for UpdaterBanner
This commit is contained in:
parent
e5882ea143
commit
77e283d934
4 changed files with 8 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import Icon from '@stremio/stremio-icons/react';
|
import Icon from '@stremio/stremio-icons/react';
|
||||||
import { useServices } from 'stremio/services';
|
import { useServices } from 'stremio/services';
|
||||||
import { useBinaryState } from 'stremio/common';
|
import { useBinaryState, useShell } from 'stremio/common';
|
||||||
import { Button, Transition } from 'stremio/components';
|
import { Button, Transition } from 'stremio/components';
|
||||||
import styles from './UpdaterBanner.less';
|
import styles from './UpdaterBanner.less';
|
||||||
|
|
||||||
|
|
@ -11,17 +11,18 @@ type Props = {
|
||||||
|
|
||||||
const UpdaterBanner = ({ className }: Props) => {
|
const UpdaterBanner = ({ className }: Props) => {
|
||||||
const { shell } = useServices();
|
const { shell } = useServices();
|
||||||
|
const shellTransport = useShell();
|
||||||
const [visible, show, hide] = useBinaryState(false);
|
const [visible, show, hide] = useBinaryState(false);
|
||||||
|
|
||||||
const onInstallClick = () => {
|
const onInstallClick = () => {
|
||||||
shell.transport && shell.transport.send('autoupdater-notif-clicked');
|
shellTransport.send('autoupdater-notif-clicked');
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
shell.on('autoupdater-show-notif', show);
|
shell.transport && shell.transport.on('autoupdater-show-notif', show);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
shell.off('autoupdater-show-notif', show);
|
shell.transport && shell.transport.off('autoupdater-show-notif', show);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
import { WHITELISTED_HOSTS } from 'stremio/common/CONSTANTS';
|
import { WHITELISTED_HOSTS } from 'stremio/common/CONSTANTS';
|
||||||
import useShell from './useShell';
|
import { useShell } from 'stremio/common';
|
||||||
import { name, isMobile } from './device';
|
import { name, isMobile } from './device';
|
||||||
|
|
||||||
interface PlatformContext {
|
interface PlatformContext {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ const useModelState = require('./useModelState');
|
||||||
const useNotifications = require('./useNotifications');
|
const useNotifications = require('./useNotifications');
|
||||||
const useOnScrollToBottom = require('./useOnScrollToBottom');
|
const useOnScrollToBottom = require('./useOnScrollToBottom');
|
||||||
const useProfile = require('./useProfile');
|
const useProfile = require('./useProfile');
|
||||||
|
const { default: useShell } = require('./useShell');
|
||||||
const useStreamingServer = require('./useStreamingServer');
|
const useStreamingServer = require('./useStreamingServer');
|
||||||
const useTorrent = require('./useTorrent');
|
const useTorrent = require('./useTorrent');
|
||||||
const useTranslate = require('./useTranslate');
|
const useTranslate = require('./useTranslate');
|
||||||
|
|
@ -47,6 +48,7 @@ module.exports = {
|
||||||
useNotifications,
|
useNotifications,
|
||||||
useOnScrollToBottom,
|
useOnScrollToBottom,
|
||||||
useProfile,
|
useProfile,
|
||||||
|
useShell,
|
||||||
useStreamingServer,
|
useStreamingServer,
|
||||||
useTorrent,
|
useTorrent,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue