From a2dfec8ae6aa980c3b391be4e74172076b2adb39 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Thu, 19 Dec 2024 00:54:51 +0800 Subject: [PATCH] Update index.tsx --- .../src/floatingButton/index.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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(); }