|
1 | | -import { CrossIsolationMessages, type PluginID } from '@masknet/shared-base' |
| 1 | +import { CrossIsolationMessages } from '@masknet/shared-base' |
2 | 2 | import { createContext, useCallback, useEffect, useState } from 'react' |
3 | 3 |
|
4 | 4 | import type { CompositionType } from '@masknet/plugin-infra/content-script' |
5 | 5 | import { EVMWeb3ContextProvider } from '@masknet/web3-hooks-base' |
6 | | -import type { FireflyContext } from '../types.js' |
7 | | -import RedPacketDialog from './RedPacketDialog.js' |
8 | 6 | import { RedPacketMainDialog } from './MainDialog.js' |
9 | 7 |
|
10 | 8 | export const CompositionTypeContext = createContext<CompositionType>('timeline') |
11 | 9 |
|
12 | 10 | export function RedPacketInjection() { |
13 | 11 | const [open, setOpen] = useState(false) |
14 | | - const [source, setSource] = useState<PluginID>() |
15 | 12 | const [compositionType, setCompositionType] = useState<CompositionType>('timeline') |
16 | 13 |
|
17 | | - const [fireflyContext, setFireflyContext] = useState<FireflyContext>() |
18 | 14 | useEffect(() => { |
19 | | - return CrossIsolationMessages.events.redpacketDialogEvent.on( |
20 | | - ({ open, source: pluginId, fireflyContext, compositionType = 'timeline' }) => { |
21 | | - setOpen(open) |
22 | | - setSource(pluginId) |
23 | | - setFireflyContext(fireflyContext) |
24 | | - setCompositionType(compositionType) |
25 | | - }, |
26 | | - ) |
| 15 | + return CrossIsolationMessages.events.redpacketDialogEvent.on(({ open, compositionType = 'timeline' }) => { |
| 16 | + setOpen(open) |
| 17 | + setCompositionType(compositionType) |
| 18 | + }) |
27 | 19 | }, []) |
28 | 20 |
|
29 | 21 | const handleClose = useCallback(() => { |
30 | 22 | setOpen(false) |
31 | 23 | }, []) |
32 | 24 |
|
33 | | - const [status, setStatus] = useState(false) |
34 | | - useEffect(() => { |
35 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
36 | | - // @ts-ignore |
37 | | - window.toggleRedPacketDialog = () => { |
38 | | - setStatus((v) => !v) |
39 | | - } |
40 | | - }, []) |
41 | | - |
42 | 25 | if (!open) return null |
43 | 26 | return ( |
44 | 27 | <EVMWeb3ContextProvider> |
45 | 28 | <CompositionTypeContext value={compositionType}> |
46 | | - {status ? |
47 | | - <RedPacketDialog open onClose={handleClose} source={source} fireflyContext={fireflyContext} /> |
48 | | - : <RedPacketMainDialog open onClose={handleClose} />} |
| 29 | + <RedPacketMainDialog open onClose={handleClose} /> |
49 | 30 | </CompositionTypeContext> |
50 | 31 | </EVMWeb3ContextProvider> |
51 | 32 | ) |
|
0 commit comments