Skip to content

Commit 2e105be

Browse files
committed
feat: Add desktop notification for user logout events
Displays 'You've been logged out' notification when users are randomly logged out, helping maintain awareness during working hours and enabling prompt reconnection to maintain productivity.
1 parent f566baa commit 2e105be

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/i18n/en.i18n.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@
162162
"downloadCancelled": "Download Cancelled",
163163
"downloadFailed": "Download Failed",
164164
"downloadExpired": "Downlaod Expired",
165-
"downloadExpiredMessage": "Please retry downloading from source."
165+
"downloadExpiredMessage": "Please retry downloading from source.",
166+
"userLoggedOut": "You've been logged out"
166167
},
167168
"filters": {
168169
"search": "Search",
@@ -438,4 +439,4 @@
438439
"cancel": "Cancel",
439440
"share": "Share"
440441
}
441-
}
442+
}

src/servers/main.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import { app } from 'electron';
55
import { satisfies, coerce } from 'semver';
66

77
import { packageJsonInformation } from '../app/main/app';
8+
import i18n from '../i18n/main';
89
import { invoke } from '../ipc/main';
10+
import { createNotification } from '../notifications/preload';
911
import { select, dispatch, listen } from '../store';
1012
import { hasMeta } from '../store/fsa';
1113
import {
1214
WEBVIEW_GIT_COMMIT_HASH_CHANGED,
1315
WEBVIEW_GIT_COMMIT_HASH_CHECK,
16+
WEBVIEW_USER_LOGGED_IN,
1417
} from '../ui/actions';
1518
import { getRootWindow } from '../ui/main/rootWindow';
1619
import { getWebContentsByServerUrl } from '../ui/main/serverView';
@@ -203,6 +206,24 @@ export const setupServers = async (
203206
}
204207
});
205208

209+
const userLoginStates = new Map<string, boolean>();
210+
211+
listen(WEBVIEW_USER_LOGGED_IN, async (action) => {
212+
const { url, userLoggedIn } = action.payload;
213+
const previousState = userLoginStates.get(url);
214+
215+
if (previousState === true && userLoggedIn === false) {
216+
await createNotification({
217+
title: i18n.t('downloads.notifications.userLoggedOut'),
218+
body: '',
219+
});
220+
}
221+
222+
if (typeof userLoggedIn === 'boolean') {
223+
userLoginStates.set(url, userLoggedIn);
224+
}
225+
});
226+
206227
let servers = select(({ servers }) => servers);
207228

208229
let currentServerUrl = select(({ currentView }) =>

0 commit comments

Comments
 (0)