fix ts & pretty

This commit is contained in:
Anton Bracke 2022-02-18 23:03:05 +01:00
parent 635bce8379
commit 4db20eea0a
No known key found for this signature in database
GPG Key ID: B1222603899C6B25
14 changed files with 407 additions and 427 deletions

View File

@ -49,8 +49,7 @@ function init() {
defaultId: 0,
title: "WorkAdventure - Update",
message: process.platform === "win32" ? releaseNotes : releaseName,
detail:
"A new version has been downloaded. Restart the application to apply the updates.",
detail: "A new version has been downloaded. Restart the application to apply the updates.",
};
const { response } = await dialog.showMessageBox(dialogOpts);
@ -60,8 +59,7 @@ function init() {
autoUpdater.quitAndInstall();
// 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();
}
})();

View File

@ -54,9 +54,7 @@ export default () => {
return true;
});
ipcMain.handle(
"sidebar:addServer",
(event, serverName: string, serverUrl: string) => {
ipcMain.handle("sidebar:addServer", (event, serverName: string, serverUrl: string) => {
const servers = settings.get("servers", []);
servers.push({
_id: `${servers.length + 1}`,
@ -65,6 +63,5 @@ export default () => {
});
settings.set("servers", servers);
return true;
}
);
});
};

View File

@ -7,10 +7,7 @@ function onError(e: Error) {
try {
log.error(e);
dialog.showErrorBox(
"WorkAdventure - A JavaScript error occurred",
e.stack || ""
);
dialog.showErrorBox("WorkAdventure - A JavaScript error occurred", e.stack || "");
} catch (logError) {
// eslint-disable-next-line no-console
console.error(e);

View File

@ -1,9 +1,7 @@
import path from "path";
import { Notification, NotificationConstructorOptions } from "electron";
export function createNotification(
options: Partial<NotificationConstructorOptions>
) {
export function createNotification(options: Partial<NotificationConstructorOptions>) {
const notification = new Notification({
title: "WorkAdventure",
icon: path.join(__dirname, "..", "assets", "icons", "logo.png"),
@ -13,9 +11,7 @@ export function createNotification(
return notification;
}
export function createAndShowNotification(
options: Partial<NotificationConstructorOptions>
) {
export function createAndShowNotification(options: Partial<NotificationConstructorOptions>) {
const notification = createNotification(options);
notification.show();

View File

@ -14,21 +14,15 @@ async function init() {
settings = (await Settings.get()) as SettingsData;
}
function get<T extends keyof SettingsData>(
key: T,
fallback?: SettingsData[T]
): SettingsData[T] {
function get<T extends keyof SettingsData>(key: T, fallback?: SettingsData[T]): SettingsData[T] {
if (settings === null) {
throw new Error("Settings not initialized");
}
return settings[key];
return settings?.[key];
}
export function set<T extends keyof SettingsData>(
key: T,
value: SettingsData[T]
) {
export function set<T extends keyof SettingsData>(key: T, value: SettingsData[T]) {
if (settings === null) {
throw new Error("Settings not initialized");
}

View File

@ -4,8 +4,7 @@ import type { WorkAdventureSidebarApi } from "./types";
const api: WorkAdventureSidebarApi = {
desktop: true,
getServers: () => ipcRenderer.invoke("sidebar:getServers"),
selectServer: (serverId: string) =>
ipcRenderer.invoke("sidebar:selectServer", serverId),
selectServer: (serverId: string) => ipcRenderer.invoke("sidebar:selectServer", serverId),
addServer: (serverName: string, serverUrl: string) =>
ipcRenderer.invoke("sidebar:addServer", serverName, serverUrl),
};

View File

@ -58,8 +58,7 @@ export function createTray() {
{
label: "Quit",
click() {
app.isQuiting = true;
app.confirmedExitPrompt = true;
// app.confirmedExitPrompt = true;
app.quit();
},
},