diff --git a/web/src/components/MemoActionMenu.tsx b/web/src/components/MemoActionMenu.tsx index 9131f9112..a894dfd38 100644 --- a/web/src/components/MemoActionMenu.tsx +++ b/web/src/components/MemoActionMenu.tsx @@ -89,13 +89,17 @@ const MemoActionMenu = observer((props: Props) => { return; } }; - //() => Promise.resolve({}) + + //async () => {} = () => Promise.resolve({}) + //await promiseFunc, this just waits for the promise to be fulfilled + //use async just so we can use await inside, dont care about returned Promise const handleToggleMemoStatusClick = async () => { //changing the state const state = memo.state === State.ARCHIVED ? State.NORMAL : State.ARCHIVED; //showing message depending on state const message = memo.state === State.ARCHIVED ? t("message.restored-successfully") : t("message.archived-successfully"); try { + //must wait for this promise returned by updateMemo to be fulfileld before continuing await memoStore.updateMemo( { name: memo.name, @@ -104,31 +108,38 @@ const MemoActionMenu = observer((props: Props) => { ["state"], ); - // Show toast with Undo button + //Show toast with Undo button //input is function that takes in the toast object we will work with and it will be used in the output of the higher order function - toast.custom((tToast) => ( -
- {message} - -
- )); + toast.custom( + ( + tToast, + ) => ( + //div container +
+ {message} + +
+ ), + ); } catch (error: any) { toast.error(error.details); console.error(error);