Skip to content

Commit

Permalink
Keep not supported but monitoring apps after unchecked monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-rohid committed Sep 25, 2024
1 parent a8ff713 commit 08e7b91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion electron/helpers/apps-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const wakatimeAppsSchema = z.object({
extraApps: z.array(appDataSchema),
});

const validateExtraApps = (apps: AppData[]) => {
return apps.filter((app) => {
return fs.existsSync(app.path);
});
};

export class AppsManager {
cacheFilePath: string;
installedApps: AppData[] = [];
Expand Down Expand Up @@ -67,7 +73,7 @@ export class AppsManager {
async loadApps() {
const { installedApps, extraApps } = this.getCachedApps();
this.installedApps = installedApps;
this.extraApps = extraApps;
this.extraApps = validateExtraApps(extraApps);
this.installedApps = await getApps();
this.saveCache();
return [...this.installedApps, ...this.extraApps];
Expand Down
6 changes: 2 additions & 4 deletions electron/helpers/monitoring-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ export abstract class MonitoringManager {
if (AppsManager.isExcludedApp(app)) {
return;
}
const monitoringKey = this.monitoredKey(app.path);
if (monitor) {
if (!AppsManager.instance().getApp(app.path)) {
AppsManager.instance().addExtraApp(app);
} else {
AppsManager.instance().removeExtraApp(app.path);
}
const monitoringKey = this.monitoredKey(app.path);
const file = getDesktopWakaTimeConfigFilePath();
ConfigFileReader.setBool(file, "monitoring", monitoringKey, monitor);
}
Expand Down

0 comments on commit 08e7b91

Please sign in to comment.