diff --git a/.changeset/good-terms-hunt.md b/.changeset/good-terms-hunt.md new file mode 100644 index 000000000000..bfdaed1d1d10 --- /dev/null +++ b/.changeset/good-terms-hunt.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +Handle close sidebar and notify widget app diff --git a/apps/ledger-live-desktop/src/renderer/components/LiveAppDrawer.tsx b/apps/ledger-live-desktop/src/renderer/components/LiveAppDrawer.tsx index bb20bc94266d..eed9a68fed95 100644 --- a/apps/ledger-live-desktop/src/renderer/components/LiveAppDrawer.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/LiveAppDrawer.tsx @@ -31,6 +31,7 @@ import CompleteExchange, { import { ExchangeType } from "@ledgerhq/live-common/wallet-api/Exchange/server"; import { Exchange } from "@ledgerhq/live-common/exchange/types"; import { renderLoading } from "./DeviceAction/rendering"; +import { createCustomErrorClass } from "@ledgerhq/errors"; const Divider = styled(Box)` border: 1px solid ${p => p.theme.colors.palette.divider}; @@ -60,6 +61,8 @@ export function isStartExchangeData(data: unknown): data is StartExchangeData { return "exchangeType" in data; } +const DrawerClosedError = createCustomErrorClass("DrawerClosedError"); + export const LiveAppDrawer = () => { const [dismissDisclaimerChecked, setDismissDisclaimerChecked] = useState(false); const { t } = useTranslation(); @@ -192,6 +195,11 @@ export const LiveAppDrawer = () => { title={payload ? t(payload.title) : ""} isOpen={isOpen} onRequestClose={() => { + payload?.data?.onCancel?.({ + error: new DrawerClosedError("User closed the drawer"), + name: "DrawerClosedError", + message: "User closed the drawer", + }); dispatch(closePlatformAppDrawer()); }} direction="left"