-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathreset.ts
More file actions
36 lines (30 loc) · 1008 Bytes
/
reset.ts
File metadata and controls
36 lines (30 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { dialog } from 'electron';
import type { Menubar } from 'menubar';
import { APPLICATION } from '../../shared/constants';
import { EVENTS } from '../../shared/events';
import { sendRendererEvent } from '../events';
/**
* Show a confirmation dialog and, if confirmed, broadcast a reset event to the
* renderer then quit the application.
*
* @param mb - The menubar instance used for the dialog parent window and quit.
*/
export function resetApp(mb: Menubar): void {
if (!mb.window) {
return;
}
const cancelButtonId = 0;
const resetButtonId = 1;
const response = dialog.showMessageBoxSync(mb.window, {
type: 'warning',
title: `Reset ${APPLICATION.NAME}`,
message: `Are you sure you want to reset ${APPLICATION.NAME}? You will be logged out of all accounts`,
buttons: ['Cancel', 'Reset'],
defaultId: cancelButtonId,
cancelId: cancelButtonId,
});
if (response === resetButtonId) {
sendRendererEvent(mb, EVENTS.RESET_APP);
mb.app.quit();
}
}