Add watcher status and additional typing.

This commit is contained in:
Patrick Fic
2025-03-21 11:28:30 -07:00
parent 6da5822197
commit 14e7c64eab
19 changed files with 385 additions and 81 deletions

View File

@@ -3,7 +3,7 @@ import log from "electron-log/main";
import path from "path";
import ipcTypes from "../../util/ipcTypes.json";
import ImportJob from "../decoder/decoder";
import { StartWatcher } from "../watcher/watcher";
import { StartWatcher, StopWatcher } from "../watcher/watcher";
import {
SettingsWatchedFilePathsAdd,
SettingsWatchedFilePathsGet,
@@ -83,4 +83,8 @@ ipcMain.on(ipcTypes.toMain.watcher.start, () => {
StartWatcher();
});
ipcMain.on(ipcTypes.toMain.watcher.stop, () => {
StopWatcher();
});
logIpcMessages();

View File

@@ -2,6 +2,7 @@ import { BrowserWindow, dialog, IpcMainInvokeEvent } from "electron";
import log from "electron-log/main";
import _ from "lodash";
import Store from "../store/store";
import { addWatcherPath, removeWatcherPath, watcher } from "../watcher/watcher";
const SettingsWatchedFilePathsAdd = async (): Promise<string[]> => {
const mainWindow = BrowserWindow.getAllWindows()[0]; //TODO: Filter to only main window once a proper key has been set.
@@ -18,6 +19,7 @@ const SettingsWatchedFilePathsAdd = async (): Promise<string[]> => {
"settings.filepaths",
_.union(result.filePaths, Store.get("settings.filepaths"))
);
addWatcherPath(result.filePaths);
}
return Store.get("settings.filepaths");
@@ -30,7 +32,7 @@ const SettingsWatchedFilePathsRemove = async (
"settings.filepaths",
_.without(Store.get("settings.filepaths"), path)
);
removeWatcherPath(path);
return Store.get("settings.filepaths");
};