Skip to content

Commit 67e28f7

Browse files
committed
Fix lint errors: readonly fields, sync fs comments, unused vars, dynamic import
1 parent e28e1d0 commit 67e28f7

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/constants/storage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export const USE_1M_CONTEXT_KEY = "use1MContext";
8484
*/
8585
export const NOTIFICATION_ENABLED_KEY = "notifications:completionEnabled";
8686

87-
8887
/**
8988
* Get the localStorage key for the preferred compaction model (global)
9089
* Format: "preferredCompactionModel"

src/services/NotificationService.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import { log } from "./log.js";
1010
* - Web/Mobile: Sends web push notifications to subscribed clients
1111
*/
1212
export class NotificationService {
13-
private isDesktop: boolean;
13+
private readonly isDesktop: boolean;
1414
private vapidKeys: VapidKeys | null = null;
1515
private subscriptions = new Map<string, PushSubscription[]>(); // workspaceId -> subscriptions
16-
private vapidKeysPath: string;
16+
private readonly vapidKeysPath: string;
1717

1818
constructor(configDir: string, isDesktop: boolean) {
1919
this.isDesktop = isDesktop;
2020
this.vapidKeysPath = path.join(configDir, "vapid.json");
21-
21+
2222
// Load or generate VAPID keys for web push
2323
if (!isDesktop) {
2424
this.initializeVapidKeys();
@@ -28,11 +28,15 @@ export class NotificationService {
2828
/**
2929
* Initialize VAPID keys for web push authentication
3030
* Generates new keys if they don't exist, otherwise loads from disk
31+
* Note: Uses sync fs methods during startup initialization (before async operations start)
3132
*/
3233
private initializeVapidKeys(): void {
3334
try {
35+
// eslint-disable-next-line local/no-sync-fs-methods -- Startup initialization needs sync
3436
if (fs.existsSync(this.vapidKeysPath)) {
37+
// eslint-disable-next-line local/no-sync-fs-methods -- Startup initialization needs sync
3538
const keysJson = fs.readFileSync(this.vapidKeysPath, "utf-8");
39+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- JSON parse is safe for VAPID keys
3640
this.vapidKeys = JSON.parse(keysJson);
3741
log.info("Loaded existing VAPID keys");
3842
} else {
@@ -41,6 +45,7 @@ export class NotificationService {
4145
publicKey: keys.publicKey,
4246
privateKey: keys.privateKey,
4347
};
48+
// eslint-disable-next-line local/no-sync-fs-methods -- Startup initialization needs sync
4449
fs.writeFileSync(this.vapidKeysPath, JSON.stringify(this.vapidKeys, null, 2));
4550
log.info("Generated and saved new VAPID keys");
4651
}
@@ -70,9 +75,9 @@ export class NotificationService {
7075
*/
7176
subscribePush(workspaceId: string, subscription: PushSubscription): void {
7277
const existing = this.subscriptions.get(workspaceId) ?? [];
73-
78+
7479
// Check if subscription already exists (by endpoint)
75-
const isDuplicate = existing.some(sub => sub.endpoint === subscription.endpoint);
80+
const isDuplicate = existing.some((sub) => sub.endpoint === subscription.endpoint);
7681
if (isDuplicate) {
7782
log.debug(`Subscription already exists for workspace ${workspaceId}`);
7883
return;
@@ -88,8 +93,8 @@ export class NotificationService {
8893
*/
8994
unsubscribePush(workspaceId: string, endpoint: string): void {
9095
const existing = this.subscriptions.get(workspaceId) ?? [];
91-
const filtered = existing.filter(sub => sub.endpoint !== endpoint);
92-
96+
const filtered = existing.filter((sub) => sub.endpoint !== endpoint);
97+
9398
if (filtered.length < existing.length) {
9499
this.subscriptions.set(workspaceId, filtered);
95100
log.info(`Removed push subscription for workspace ${workspaceId}`);
@@ -135,16 +140,16 @@ export class NotificationService {
135140
});
136141

137142
const results = await Promise.allSettled(sendPromises);
138-
143+
139144
// Remove failed subscriptions
140145
const validSubscriptions = results
141-
.filter((result, index) => {
146+
.filter((result) => {
142147
if (result.status === "fulfilled" && result.value.success) {
143148
return true;
144149
}
145150
return false;
146151
})
147-
.map((result, index) => subscriptions[index]);
152+
.map((_result, index) => subscriptions[index]);
148153

149154
this.subscriptions.set(workspaceId, validSubscriptions);
150155
}

src/services/ipcMain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ export class IpcMain {
11791179
});
11801180
}
11811181

1182-
11831182
private registerNotificationHandlers(ipcMain: ElectronIpcMain): void {
11841183
// Get VAPID public key for push subscription
11851184
ipcMain.handle(IPC_CHANNELS.NOTIFICATION_GET_VAPID_KEY, () => {
@@ -1216,7 +1215,8 @@ export class IpcMain {
12161215
async (_event, workspaceId: string, workspaceName: string) => {
12171216
try {
12181217
if (this.isDesktop) {
1219-
// For desktop, we'll import Notification dynamically and show it
1218+
// Dynamic import required: can't statically import electron in server mode
1219+
// eslint-disable-next-line no-restricted-syntax -- Dynamic import necessary for server compatibility
12201220
const { Notification } = await import("electron");
12211221
const notification = new Notification({
12221222
title: "Completion",

src/utils/commands/sources.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,14 @@ export function buildCoreSources(p: BuildSourcesParams): Array<() => CommandActi
421421
// Settings
422422
actions.push(() => {
423423
const notificationsEnabled = readPersistedState(NOTIFICATION_ENABLED_KEY, false);
424-
424+
425425
return [
426426
{
427427
id: "settings:toggle-notifications",
428428
title: notificationsEnabled
429429
? "Disable Completion Notifications"
430430
: "Enable Completion Notifications",
431-
subtitle: notificationsEnabled
432-
? "Currently enabled"
433-
: "Get notified when streams complete",
431+
subtitle: notificationsEnabled ? "Currently enabled" : "Get notified when streams complete",
434432
section: section.settings,
435433
run: async () => {
436434
const newValue = !notificationsEnabled;

0 commit comments

Comments
 (0)