fix ts & pretty

This commit is contained in:
Anton Bracke
2022-02-18 23:03:05 +01:00
parent 635bce8379
commit 4db20eea0a
14 changed files with 407 additions and 427 deletions
+2 -4
View File
@@ -49,8 +49,7 @@ function init() {
defaultId: 0, defaultId: 0,
title: "WorkAdventure - Update", title: "WorkAdventure - Update",
message: process.platform === "win32" ? releaseNotes : releaseName, message: process.platform === "win32" ? releaseNotes : releaseName,
detail: detail: "A new version has been downloaded. Restart the application to apply the updates.",
"A new version has been downloaded. Restart the application to apply the updates.",
}; };
const { response } = await dialog.showMessageBox(dialogOpts); const { response } = await dialog.showMessageBox(dialogOpts);
@@ -60,8 +59,7 @@ function init() {
autoUpdater.quitAndInstall(); autoUpdater.quitAndInstall();
// Force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app. // Force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app.
app.isQuiting = true; // app.confirmedExitPrompt = true;
app.confirmedExitPrompt = true;
app.quit(); app.quit();
} }
})(); })();
+2 -5
View File
@@ -54,9 +54,7 @@ export default () => {
return true; return true;
}); });
ipcMain.handle( ipcMain.handle("sidebar:addServer", (event, serverName: string, serverUrl: string) => {
"sidebar:addServer",
(event, serverName: string, serverUrl: string) => {
const servers = settings.get("servers", []); const servers = settings.get("servers", []);
servers.push({ servers.push({
_id: `${servers.length + 1}`, _id: `${servers.length + 1}`,
@@ -65,6 +63,5 @@ export default () => {
}); });
settings.set("servers", servers); settings.set("servers", servers);
return true; return true;
} });
);
}; };
+1 -4
View File
@@ -7,10 +7,7 @@ function onError(e: Error) {
try { try {
log.error(e); log.error(e);
dialog.showErrorBox( dialog.showErrorBox("WorkAdventure - A JavaScript error occurred", e.stack || "");
"WorkAdventure - A JavaScript error occurred",
e.stack || ""
);
} catch (logError) { } catch (logError) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(e); console.error(e);
+2 -6
View File
@@ -1,9 +1,7 @@
import path from "path"; import path from "path";
import { Notification, NotificationConstructorOptions } from "electron"; import { Notification, NotificationConstructorOptions } from "electron";
export function createNotification( export function createNotification(options: Partial<NotificationConstructorOptions>) {
options: Partial<NotificationConstructorOptions>
) {
const notification = new Notification({ const notification = new Notification({
title: "WorkAdventure", title: "WorkAdventure",
icon: path.join(__dirname, "..", "assets", "icons", "logo.png"), icon: path.join(__dirname, "..", "assets", "icons", "logo.png"),
@@ -13,9 +11,7 @@ export function createNotification(
return notification; return notification;
} }
export function createAndShowNotification( export function createAndShowNotification(options: Partial<NotificationConstructorOptions>) {
options: Partial<NotificationConstructorOptions>
) {
const notification = createNotification(options); const notification = createNotification(options);
notification.show(); notification.show();
+3 -9
View File
@@ -14,21 +14,15 @@ async function init() {
settings = (await Settings.get()) as SettingsData; settings = (await Settings.get()) as SettingsData;
} }
function get<T extends keyof SettingsData>( function get<T extends keyof SettingsData>(key: T, fallback?: SettingsData[T]): SettingsData[T] {
key: T,
fallback?: SettingsData[T]
): SettingsData[T] {
if (settings === null) { if (settings === null) {
throw new Error("Settings not initialized"); throw new Error("Settings not initialized");
} }
return settings[key]; return settings?.[key];
} }
export function set<T extends keyof SettingsData>( export function set<T extends keyof SettingsData>(key: T, value: SettingsData[T]) {
key: T,
value: SettingsData[T]
) {
if (settings === null) { if (settings === null) {
throw new Error("Settings not initialized"); throw new Error("Settings not initialized");
} }
+1 -2
View File
@@ -4,8 +4,7 @@ import type { WorkAdventureSidebarApi } from "./types";
const api: WorkAdventureSidebarApi = { const api: WorkAdventureSidebarApi = {
desktop: true, desktop: true,
getServers: () => ipcRenderer.invoke("sidebar:getServers"), getServers: () => ipcRenderer.invoke("sidebar:getServers"),
selectServer: (serverId: string) => selectServer: (serverId: string) => ipcRenderer.invoke("sidebar:selectServer", serverId),
ipcRenderer.invoke("sidebar:selectServer", serverId),
addServer: (serverName: string, serverUrl: string) => addServer: (serverName: string, serverUrl: string) =>
ipcRenderer.invoke("sidebar:addServer", serverName, serverUrl), ipcRenderer.invoke("sidebar:addServer", serverName, serverUrl),
}; };
+1 -2
View File
@@ -58,8 +58,7 @@ export function createTray() {
{ {
label: "Quit", label: "Quit",
click() { click() {
app.isQuiting = true; // app.confirmedExitPrompt = true;
app.confirmedExitPrompt = true;
app.quit(); app.quit();
}, },
}, },