Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

feat: implement desktop popup ui toggle#598

Merged
OGPoyraz merged 3 commits intomainfrom
feat/desktop-popup-ui-toggle-3
Mar 13, 2023
Merged

feat: implement desktop popup ui toggle#598
OGPoyraz merged 3 commits intomainfrom
feat/desktop-popup-ui-toggle-3

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz commented Mar 9, 2023

Overview

This PR implements desktop popup ui toggle.

@OGPoyraz OGPoyraz requested a review from a team March 9, 2023 08:50
factoryReset: () => {
return ipcRenderer.invoke('factory-reset');
},
toggleDesktopPopup: async (isEnabled: boolean) => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dialogs are triggered from main process.
The reason behind exposing it on the renderer is that depending on the selected yes or no answer, we either trigger redux action. It would also be possible to fire an event from main to renderer to execute a redux action, but that would mean a full round trip which we don't want to do.

@OGPoyraz OGPoyraz force-pushed the feat/desktop-popup-ui-toggle-3 branch from 3fb7570 to c65df16 Compare March 9, 2023 11:01

ipcMain.handle('toggle-desktop-popup', (_event, isEnabled) => {
if (cfg().enableDesktopPopup && isEnabled) {
this.enableDesktopPopup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enableDesktopPopup is an async method. We should add a catch to handle any error, otherwise we will have unhandledPromiseRejections and the App will crash.

Copy link
Copy Markdown
Member Author

@OGPoyraz OGPoyraz Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok if we follow up, this method is used as async just because of createApprovalWindow. But neither createMainWindow nor createApprovalWindow needs to be async. So theoretically there will never be an unhandledPromiseRejections

Ok, BrowserWindow.loadFile is actually async.

defaultValue: false,
});
if (cfg().enableDesktopPopup && isDesktopPopupEnabled) {
this.enableDesktopPopup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, this is an async method. We should wait for the Promise to resolve (and maybe add a try/catch block around so that any issues from enabling the desktop popup do not prevent the App from initialise)

@OGPoyraz OGPoyraz force-pushed the feat/desktop-popup-ui-toggle-3 branch 3 times, most recently from bdbea58 to 1a7dec5 Compare March 10, 2023 08:18
@OGPoyraz OGPoyraz force-pushed the feat/desktop-popup-ui-toggle-3 branch 3 times, most recently from c41c2b0 to 0f22385 Compare March 10, 2023 12:57
@OGPoyraz OGPoyraz force-pushed the feat/desktop-popup-ui-toggle-3 branch from 1ac9e03 to f16d159 Compare March 10, 2023 13:21
@OGPoyraz OGPoyraz merged commit 8c65123 into main Mar 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants