Skip to content

Commit

Permalink
fix: notify exchangeSdk about closing the drawer (#8319)
Browse files Browse the repository at this point in the history
* fix: notify exchangeSdk about closing the drawer

* fix: add error name

* chore: add changeset

* refactor: replaces custom error with createCustomErrorClass utility
  • Loading branch information
sergiubreban authored Nov 26, 2024
1 parent 2a839c6 commit 42e9d67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-terms-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

Handle close sidebar and notify widget app
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<boolean>(false);
const { t } = useTranslation();
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 42e9d67

Please sign in to comment.