ESDP - List Parser - Notification fixes 0.0.6
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "esdp",
|
||||
"productName": "EMS Uploader",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"description": "EMS Uploader",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "ImEX Systems Inc.",
|
||||
|
||||
@@ -471,6 +471,10 @@ function createWindow(): BrowserWindow {
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(async () => {
|
||||
if (!gotTheLock) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Default open or close DevTools by F12 in development
|
||||
// and ignore CommandOrControl + R in production.
|
||||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||
@@ -478,7 +482,6 @@ app.whenReady().then(async () => {
|
||||
|
||||
if (platform.isWindows) {
|
||||
app.setAppUserModelId(appId);
|
||||
await repairWindowsProtocolRegistration();
|
||||
}
|
||||
|
||||
app.on("browser-window-created", (_, window) => {
|
||||
@@ -510,6 +513,10 @@ app.whenReady().then(async () => {
|
||||
log.warn("Failed to register protocol handler.");
|
||||
}
|
||||
|
||||
if (platform.isWindows) {
|
||||
await repairWindowsProtocolRegistration();
|
||||
}
|
||||
|
||||
//Dynamically load ipcMain handlers once ready.
|
||||
try {
|
||||
await import("./ipc/ipcMainConfig");
|
||||
@@ -705,7 +712,12 @@ function runRegCommand(args: string[]): Promise<void> {
|
||||
}
|
||||
|
||||
function getProtocolLaunchArgs(): string[] | null {
|
||||
if (!is.dev && !process.defaultApp) {
|
||||
const isRunningElectronBinary =
|
||||
path.basename(process.execPath).toLowerCase() === "electron.exe";
|
||||
const isDevelopmentRuntime =
|
||||
is.dev || process.defaultApp || !app.isPackaged || isRunningElectronBinary;
|
||||
|
||||
if (!isDevelopmentRuntime) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -714,12 +726,19 @@ function getProtocolLaunchArgs(): string[] | null {
|
||||
.filter((arg) => !arg.startsWith(`${protocol}://`));
|
||||
|
||||
if (launchArgs.length === 0) {
|
||||
return null;
|
||||
return [app.getAppPath()];
|
||||
}
|
||||
|
||||
return launchArgs.map((arg) =>
|
||||
const normalizedLaunchArgs = launchArgs.map((arg) =>
|
||||
arg.startsWith("-") ? arg : path.resolve(arg),
|
||||
);
|
||||
const hasAppPathArg = normalizedLaunchArgs.some(
|
||||
(arg) => !arg.startsWith("-"),
|
||||
);
|
||||
|
||||
return hasAppPathArg
|
||||
? normalizedLaunchArgs
|
||||
: [app.getAppPath(), ...normalizedLaunchArgs];
|
||||
}
|
||||
|
||||
function quoteCommandArg(arg: string): string {
|
||||
|
||||
@@ -87,8 +87,8 @@ const SettingsWatcherPollingSet = async (
|
||||
const { enabled, interval } = pollingSettings;
|
||||
Store.set("settings.polling", { enabled, interval });
|
||||
|
||||
await StopWatcher();
|
||||
await StartWatcher();
|
||||
await StopWatcher({ notifyOnStopped: false });
|
||||
await StartWatcher({ notifyOnStarted: false });
|
||||
|
||||
return { enabled, interval };
|
||||
};
|
||||
|
||||
@@ -14,6 +14,11 @@ let watcherReady = false;
|
||||
|
||||
type StartWatcherOptions = {
|
||||
notifyOnNoPaths?: boolean;
|
||||
notifyOnStarted?: boolean;
|
||||
};
|
||||
|
||||
type StopWatcherOptions = {
|
||||
notifyOnStopped?: boolean;
|
||||
};
|
||||
|
||||
function getValidWatcherPaths(filePaths: string[]): string[] {
|
||||
@@ -30,7 +35,7 @@ function getValidWatcherPaths(filePaths: string[]): string[] {
|
||||
async function StartWatcher(
|
||||
options: StartWatcherOptions = {},
|
||||
): Promise<boolean> {
|
||||
const { notifyOnNoPaths = true } = options;
|
||||
const { notifyOnNoPaths = true, notifyOnStarted = true } = options;
|
||||
const configuredFilePaths: string[] = store.get("settings.filepaths") || [];
|
||||
const filePaths = getValidWatcherPaths(configuredFilePaths);
|
||||
|
||||
@@ -116,7 +121,7 @@ async function StartWatcher(
|
||||
// errorTypeCheck(error)
|
||||
// );
|
||||
})
|
||||
.on("ready", onWatcherReady);
|
||||
.on("ready", () => onWatcherReady({ notifyOnStarted }));
|
||||
// .on("raw", function (event, path, details) {
|
||||
// // This event should be triggered everytime something happens.
|
||||
// // console.log("Raw event info:", event, path, details);
|
||||
@@ -139,21 +144,28 @@ function addWatcherPath(path: string | string[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
function onWatcherReady(): void {
|
||||
function onWatcherReady({
|
||||
notifyOnStarted,
|
||||
}: {
|
||||
notifyOnStarted: boolean;
|
||||
}): void {
|
||||
if (watcher) {
|
||||
const mainWindow = getMainWindow();
|
||||
watcherReady = true;
|
||||
showNotification({
|
||||
title: "Watcher Started",
|
||||
body: "Newly exported estimates will be automatically uploaded.",
|
||||
});
|
||||
if (notifyOnStarted) {
|
||||
showNotification({
|
||||
title: "Watcher Started",
|
||||
body: "Newly exported estimates will be automatically uploaded.",
|
||||
});
|
||||
}
|
||||
log.info("Confirmed watched paths:", watcher.getWatched());
|
||||
setWatcherTrayStatus(true);
|
||||
mainWindow?.webContents.send(ipcTypes.toRenderer.watcher.started);
|
||||
}
|
||||
}
|
||||
|
||||
async function StopWatcher(): Promise<boolean> {
|
||||
async function StopWatcher(options: StopWatcherOptions = {}): Promise<boolean> {
|
||||
const { notifyOnStopped = true } = options;
|
||||
const mainWindow = getMainWindow();
|
||||
|
||||
if (watcher) {
|
||||
@@ -164,10 +176,12 @@ async function StopWatcher(): Promise<boolean> {
|
||||
setWatcherTrayStatus(false);
|
||||
mainWindow?.webContents.send(ipcTypes.toRenderer.watcher.stopped);
|
||||
|
||||
showNotification({
|
||||
title: "Watcher Stopped",
|
||||
body: "Estimates will not be automatically uploaded.",
|
||||
});
|
||||
if (notifyOnStopped) {
|
||||
showNotification({
|
||||
title: "Watcher Stopped",
|
||||
body: "Estimates will not be automatically uploaded.",
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user