Add showNotification function and update output folder path

This commit is contained in:
Nayam Amarshe
2024-01-15 17:00:59 +05:30
parent a6f21c429a
commit 57810f4d77
6 changed files with 49 additions and 18 deletions

View File

@@ -1,7 +1,6 @@
import fs from "fs";
import sharp, { FormatEnum, Metadata } from "sharp";
import logit from "./logit";
import { getMainWindow } from "../main-window";
import { compression } from "./config-variables";
import { ImageFormat } from "./types";
@@ -17,22 +16,24 @@ const convertAndScale = async (
logit("Skipping png compression for 4x scale");
return;
}
const mainWindow = getMainWindow();
let originalImage: Metadata | undefined;
try {
originalImage = await sharp(originalImagePath).metadata();
} catch (error) {
logit("❌ Error with original Image: ", error);
logit("❌ Error with original Image: ", error, " - ", originalImagePath);
}
fs.access(originalImagePath, fs.constants.F_OK, (err) => {
logit("🖼️ Checking if original image exists: ", originalImagePath);
if (err) {
throw new Error("Could not grab the original image!");
throw new Error(
"Could not grab the original image from the path provided! - " + err
);
}
});
if (!mainWindow || !originalImage) {
if (!originalImage) {
throw new Error("Could not grab the original image!");
}

View File

@@ -1,3 +1,5 @@
import { Dirent } from "fs";
/**
* Returns the filename without the extension.
* @param filename The filename to remove the extension from.

View File

@@ -0,0 +1,9 @@
import { Notification } from "electron/main";
export default function showNotification(title: string, body: string) {
new Notification({
title,
body,
closeButtonText: "Close",
}).show();
}