Skip to content

Commit 98ea71b

Browse files
committed
refactor(main): organize main structure
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent ad316fb commit 98ea71b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/main/handlers/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function registerAppHandlers(mb: Menubar): void {
2020

2121
onMainEvent(EVENTS.QUIT, () => mb.app.quit());
2222

23+
// Path handlers for renderer queries about resource locations
2324
handleMainEvent(EVENTS.NOTIFICATION_SOUND_PATH, () => {
2425
return Paths.notificationSound;
2526
});

src/main/lifecycle/first-run.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { APPLICATION } from '../../shared/constants';
77
import { logError } from '../../shared/logger';
88
import { isMacOS } from '../../shared/platform';
99

10+
/**
11+
* On first launch, write the first-run marker file and prompt macOS users
12+
* to move the app to the Applications folder. No-ops on subsequent launches.
13+
*/
1014
export async function onFirstRunMaybe() {
1115
if (isFirstRun()) {
1216
await promptMoveToApplicationsFolder();
@@ -38,6 +42,9 @@ async function promptMoveToApplicationsFolder() {
3842
}
3943
}
4044

45+
/**
46+
* Returns the absolute path to the first-run marker file in the user data directory.
47+
*/
4148
const getConfigPath = () => {
4249
const userDataPath = app.getPath('userData');
4350
return path.join(userDataPath, 'FirstRun', APPLICATION.FIRST_RUN_FOLDER);

src/main/utils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ import type { Menubar } from 'menubar';
99
import { APPLICATION } from '../shared/constants';
1010
import { logError, logInfo } from '../shared/logger';
1111

12-
export function isDevMode() {
12+
/**
13+
* Returns true when the app is running in development mode (i.e. not packaged).
14+
*/
15+
export function isDevMode(): boolean {
1316
return !app.isPackaged;
1417
}
1518

19+
/**
20+
* Capture the current window contents and save a PNG file to the user's home directory.
21+
* The filename includes an ISO timestamp and the application name.
22+
* @param mb - The menubar instance whose window is captured.
23+
*/
1624
export function takeScreenshot(mb: Menubar) {
1725
const date = new Date();
1826
const dateStr = date.toISOString().replaceAll(':', '-');
@@ -28,6 +36,10 @@ export function takeScreenshot(mb: Menubar) {
2836
});
2937
}
3038

39+
/**
40+
* Open the directory containing the application log file in the OS file manager.
41+
* Logs an error if the log file path cannot be resolved.
42+
*/
3143
export function openLogsDirectory() {
3244
const logFilePath = log.transports.file?.getFile()?.path;
3345

0 commit comments

Comments
 (0)