Minor app fixes and improvements.
This commit is contained in:
@@ -60,7 +60,6 @@ workflows:
|
||||
deploy_and_build:
|
||||
jobs:
|
||||
- partner-win-build
|
||||
# - partner-mac-build:
|
||||
# filters:
|
||||
# branches:
|
||||
# only: main
|
||||
filters:
|
||||
branches:
|
||||
only: main
|
||||
|
||||
@@ -148,17 +148,23 @@ export default class LocalServer {
|
||||
|
||||
public start(): void {
|
||||
try {
|
||||
this.server = this.app.listen(this.PORT, (error: Error | undefined) => {
|
||||
if (error) {
|
||||
this.server = http.createServer(this.app);
|
||||
|
||||
this.server.on("error", (error: NodeJS.ErrnoException) => {
|
||||
if (error.code === "EADDRINUSE") {
|
||||
log.error(
|
||||
`[HTTP Server] Error starting server: ${errorTypeCheck(error)}`,
|
||||
`[HTTP Server] Port ${this.PORT} is already in use. Please use a different port.`,
|
||||
);
|
||||
} else {
|
||||
log.info(
|
||||
`[HTTP Server] Local HTTP server running on port ${this.PORT}`,
|
||||
);
|
||||
log.error(`[HTTP Server] Server error: ${error.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
this.server.listen(this.PORT, () => {
|
||||
log.info(
|
||||
`[HTTP Server] Local HTTP server running on port ${this.PORT}`,
|
||||
);
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
log.error("[HTTP Server] Error starting server", errorTypeCheck(error));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ const isMac = process.platform === "darwin";
|
||||
let isAppQuitting = false; //Needed on Mac as an override to allow us to fully quit the app.
|
||||
// Initialize the server
|
||||
const localServer = new LocalServer();
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
function createWindow(): void {
|
||||
// Create the browser window.
|
||||
const { width, height, x, y } = store.get("app.windowBounds") as {
|
||||
@@ -45,6 +47,7 @@ function createWindow(): void {
|
||||
minHeight: 400,
|
||||
//autoHideMenuBar: true,
|
||||
...(process.platform === "linux" ? { icon } : {}),
|
||||
title: "Shop Partner",
|
||||
webPreferences: {
|
||||
preload: join(__dirname, "../preload/index.js"),
|
||||
sandbox: false,
|
||||
@@ -260,6 +263,9 @@ function createWindow(): void {
|
||||
}
|
||||
}
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit(); // Quit the app if another instance is already running
|
||||
}
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
@@ -274,6 +280,12 @@ app.whenReady().then(async () => {
|
||||
optimizer.watchWindowShortcuts(window);
|
||||
});
|
||||
|
||||
// Add this event handler for second instance
|
||||
app.on("second-instance", () => {
|
||||
// Someone tried to run a second instance, we should focus our window
|
||||
openMainWindow();
|
||||
});
|
||||
|
||||
//Dynamically load ipcMain handlers once ready.
|
||||
try {
|
||||
// Replace 'path/to/your/file' with the actual path to your file
|
||||
@@ -365,6 +377,14 @@ app.on("window-all-closed", () => {
|
||||
|
||||
app.on("before-quit", () => {
|
||||
localServer.stop();
|
||||
const currentSetting = store.get("app.openOnStartup") as boolean;
|
||||
store.set("app.openOnStartup", !currentSetting);
|
||||
log.info("Open on startup set to", !currentSetting);
|
||||
app.setLoginItemSettings({
|
||||
enabled: true, //This is a windows only command. Updates the task manager and registry.
|
||||
openAtLogin: !currentSetting,
|
||||
});
|
||||
|
||||
isAppQuitting = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -45,8 +45,10 @@ const ipcMainHandleAuthStateChanged = async (
|
||||
const convCo = activeBodyshop.bodyshops[0].convenient_company;
|
||||
if (convCo === "alpha") {
|
||||
autoUpdater.channel = "alpha";
|
||||
log.debug("Setting update channel to ALPHA channel.");
|
||||
} else if (convCo === "beta") {
|
||||
autoUpdater.channel = "beta";
|
||||
log.debug("Setting update channel to BETA channel.");
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Electron</title>
|
||||
<title>Shop Partner</title>
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<!-- <meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
|
||||
@@ -97,7 +97,7 @@ const SettingsWatcher: React.FC = () => {
|
||||
>
|
||||
<Card title={t("settings.labels.watcherstatus")}>
|
||||
<Row>
|
||||
<Col span={12}>
|
||||
<Col md={12} xs={24}>
|
||||
{isWatcherStarted ? (
|
||||
<Button onClick={handleStop}>
|
||||
{t("settings.actions.stopwatcher")}
|
||||
@@ -108,7 +108,7 @@ const SettingsWatcher: React.FC = () => {
|
||||
</Button>
|
||||
)}
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Col md={12} xs={24}>
|
||||
<Space direction="vertical" wrap>
|
||||
<Switch
|
||||
checked={!pollingState.enabled}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Card, Typography } from "antd";
|
||||
import { JSX, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ipcTypes from "../../../../util/ipcTypes.json";
|
||||
|
||||
import _ from "lodash";
|
||||
const Welcome = (): JSX.Element => {
|
||||
const { t } = useTranslation();
|
||||
const [shopName, setShopName] = useState<string | null>(null);
|
||||
@@ -18,12 +18,14 @@ const Welcome = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card>
|
||||
<Typography.Title level={3}>
|
||||
{t("auth.labels.welcome", { name: auth.currentUser?.displayName })}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph>{shopName || ""}</Typography.Paragraph>
|
||||
</Card>
|
||||
<Typography.Title level={4}>
|
||||
{t("auth.labels.welcome", {
|
||||
name: _.isEmpty(auth.currentUser?.displayName)
|
||||
? auth.currentUser?.email
|
||||
: `${auth.currentUser?.displayName} (${auth.currentUser?.email})`.trim(),
|
||||
})}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph>{shopName || ""}</Typography.Paragraph>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
{
|
||||
"translation": {
|
||||
"auth": {
|
||||
"labels": {
|
||||
"welcome": "Welcome {{name}}"
|
||||
},
|
||||
"login": {
|
||||
"error": "The username and password combination provided is not valid.",
|
||||
"login": "Log In",
|
||||
"resetpassword": "Reset Password"
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
"errorboundary": "Uh oh - we've hit an error.",
|
||||
"notificationtitle": "Error Encountered"
|
||||
},
|
||||
"navigation": {
|
||||
"home": "Home",
|
||||
"settings": "Settings",
|
||||
"signout": "Sign Out"
|
||||
},
|
||||
"settings": {
|
||||
"actions": {
|
||||
"addpath": "Add path",
|
||||
"startwatcher": "Start Watcher",
|
||||
"stopwatcher": "Stop Watcher\n"
|
||||
},
|
||||
"labels": {
|
||||
"pollinginterval": "Polling Interval (ms)",
|
||||
"started": "Started",
|
||||
"stopped": "Stopped",
|
||||
"watchedpaths": "Watched Paths",
|
||||
"watchermodepolling": "Polling",
|
||||
"watchermoderealtime": "Real Time",
|
||||
"watcherstatus": "Watcher Status"
|
||||
}
|
||||
},
|
||||
"updates": {
|
||||
"apply": "Apply Update",
|
||||
"available": "An update is available.",
|
||||
"download": "Download Update",
|
||||
"downloading": "An update is downloading."
|
||||
}
|
||||
}
|
||||
"translation": {
|
||||
"auth": {
|
||||
"labels": {
|
||||
"welcome": "Hi {{name}}"
|
||||
},
|
||||
"login": {
|
||||
"error": "The username and password combination provided is not valid.",
|
||||
"login": "Log In",
|
||||
"resetpassword": "Reset Password"
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
"errorboundary": "Uh oh - we've hit an error.",
|
||||
"notificationtitle": "Error Encountered"
|
||||
},
|
||||
"navigation": {
|
||||
"home": "Home",
|
||||
"settings": "Settings",
|
||||
"signout": "Sign Out"
|
||||
},
|
||||
"settings": {
|
||||
"actions": {
|
||||
"addpath": "Add path",
|
||||
"startwatcher": "Start Watcher",
|
||||
"stopwatcher": "Stop Watcher\n"
|
||||
},
|
||||
"labels": {
|
||||
"pollinginterval": "Polling Interval (ms)",
|
||||
"started": "Started",
|
||||
"stopped": "Stopped",
|
||||
"watchedpaths": "Watched Paths",
|
||||
"watchermodepolling": "Polling",
|
||||
"watchermoderealtime": "Real Time",
|
||||
"watcherstatus": "Watcher Status"
|
||||
}
|
||||
},
|
||||
"updates": {
|
||||
"apply": "Apply Update",
|
||||
"available": "An update is available.",
|
||||
"download": "Download Update",
|
||||
"downloading": "An update is downloading."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user