-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathindex.ts
More file actions
70 lines (56 loc) · 1.82 KB
/
index.ts
File metadata and controls
70 lines (56 loc) · 1.82 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { app } from 'electron';
import log from 'electron-log';
import { menubar } from '@gitify/menubar';
import { Paths, WindowConfig } from './config';
import {
registerAppHandlers,
registerStorageHandlers,
registerSystemHandlers,
registerTrayHandlers,
} from './handlers';
import { TrayIcons } from './icons';
import {
configureWindowEvents,
handleProtocolURL,
initializeAppLifecycle,
onFirstRunMaybe,
} from './lifecycle';
import MenuBuilder from './menu';
import AppUpdater from './updater';
import { isDevMode } from './utils';
log.initialize();
if (!app.isPackaged) {
log.transports.file.fileName = 'main.dev.log';
}
const mb = menubar({
icon: TrayIcons.idle,
index: Paths.indexHtml,
browserWindow: WindowConfig,
preloadWindow: true,
showDockIcon: false, // Hide the app from the macOS dock
hideOnClose: true, // Keep renderer state across WM close; Wayland-safe.
escapeToHide: true, // Hide the window when Escape is pressed.
});
const menuBuilder = new MenuBuilder(mb);
const contextMenu = menuBuilder.buildMenu();
// Register your app as the handler for a custom protocol
const protocol = isDevMode() ? 'gitify-dev' : 'gitify';
app.setAsDefaultProtocolClient(protocol);
const appUpdater = new AppUpdater(mb, menuBuilder);
app.whenReady().then(async () => {
await onFirstRunMaybe();
appUpdater.start();
initializeAppLifecycle(mb, contextMenu, protocol);
// Configure window event handlers (Escape key, DevTools resize)
configureWindowEvents(mb, menuBuilder);
// Register IPC handlers for various channels
registerTrayHandlers(mb);
registerSystemHandlers(mb);
registerStorageHandlers();
registerAppHandlers(mb);
});
// Handle gitify:// custom protocol URL events for OAuth 2.0 callback
app.on('open-url', (event, url) => {
event.preventDefault();
handleProtocolURL(mb, url, protocol);
});