Skip to content

Commit 759213e

Browse files
feat(auth): show notification when token refreshing fails
1 parent fe91487 commit 759213e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/main/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ app
786786
.then(() => {
787787
registerTokenRefreshHandler(handleSuccessfulSignIn);
788788
registerAuthFailureHandler(() => {
789-
/**
790-
* to be figured out
791-
*/
789+
mainWindow?.webContents.send(
790+
ChannelsEnum.RESPONSE_TOKEN_REFRESHING_FAILED,
791+
);
792792
});
793793
createWindow();
794794
app.on('activate', () => {

src/renderer/context/AppProvider.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ const AppContextFn = (initialUser: User | null) => {
103103
setNotifier,
104104
]);
105105

106+
useEffect(() => {
107+
// sourcery skip: inline-immediately-returned-variable
108+
const unsubscribe = window.electron.ipcRenderer.on(
109+
ChannelsEnum.RESPONSE_TOKEN_REFRESHING_FAILED,
110+
() => {
111+
setNotifier(
112+
'Failed to refresh your session. Sync is paused. Please sign out and sign in again to resume.',
113+
'error',
114+
);
115+
},
116+
);
117+
return unsubscribe;
118+
}, [setNotifier]);
119+
106120
useEffect(() => {
107121
// sourcery skip: inline-immediately-returned-variable
108122
const unsubscribe = window.electron.ipcRenderer.on(

src/renderer/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,6 @@ export enum ChannelsEnum {
182182
RESPONSE_COUNT_OF_TASKS_OVERDUE = 'response_count_of_tasks_overdue',
183183

184184
REQUEST_SYNC_START = 'REQUEST_SYNC_START',
185+
186+
RESPONSE_TOKEN_REFRESHING_FAILED = 'response_token_refreshing_failed',
185187
}

0 commit comments

Comments
 (0)