diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index ceac34a2..3ac4769e 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -43,8 +43,9 @@ const textStyle = { const containerId = 'onekey-floating-widget'; -const removeApp = () => { +const removeIcon = () => { document.getElementById(containerId)?.remove(); + isInjected = false; } const useOutsideClick = ( @@ -81,7 +82,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { }).$onekey.$private.request({ method: 'wallet_disableFloatingButton', }); - removeApp(); + removeIcon(); }, []) const handleHideOnSite = useCallback(() => { void (globalThis as unknown as { @@ -96,7 +97,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { method: 'wallet_hideFloatingButtonOnSite', params: { url: window.location.origin }, }); - removeApp(); + removeIcon(); }, []) return (
, document.body, div); } @@ -760,7 +761,11 @@ export function injectFloatingButton() { } } }).$onekey.$private.onNotifyFloatingIconChanged(({ showFloatingIcon }: { showFloatingIcon: boolean }) => { - console.log(showFloatingIcon); + if (showFloatingIcon) { + void injectIcon(); + } else { + removeIcon(); + } }); void injectIcon(); }