From 99367fe9de81a6b27d37b0899ba94be8eed872b0 Mon Sep 17 00:00:00 2001 From: Kyle Rosenberg Date: Tue, 28 Dec 2021 22:14:37 -0500 Subject: [PATCH] fix all style mistakes --- src/background.ts | 8 ++++---- src/bridge.ts | 4 +++- src/helpers/autoUpdate.ts | 10 ++++++++-- src/helpers/observers.ts | 15 ++++++--------- src/helpers/settings.ts | 3 +++ src/helpers/trayManager.ts | 7 +++---- src/menu/contextMenu.ts | 9 ++------- src/menu/items/about.ts | 2 +- src/menu/settingsMenu.ts | 7 +------ src/menu/trayMenu.ts | 2 +- 10 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/background.ts b/src/background.ts index 1903d2b7..7838505c 100644 --- a/src/background.ts +++ b/src/background.ts @@ -165,14 +165,14 @@ ipcMain.on("should-hide-notification-content", (event) => { event.returnValue = settings.hideNotificationContentEnabled.value; }); -ipcMain.on("show-main-window", (event) => { +ipcMain.on("show-main-window", () => { mainWindow.show(); if (IS_MAC) { app.dock.setBadge(""); } }); -ipcMain.on("flash-main-window-if-not-focused", (event) => { +ipcMain.on("flash-main-window-if-not-focused", () => { if (!mainWindow.isFocused()) { mainWindow.flashFrame(true); if (IS_MAC) { @@ -181,10 +181,10 @@ ipcMain.on("flash-main-window-if-not-focused", (event) => { } }); -ipcMain.on("set-unread-status", (event, unreadStatus: boolean) => { +ipcMain.on("set-unread-status", (_event, unreadStatus: boolean) => { trayManager.setUnread(unreadStatus); }); -ipcMain.on("set-recent-conversations", (event, data: Conversation[]) => { +ipcMain.on("set-recent-conversations", (_event, data: Conversation[]) => { trayManager.setRecentConversations(data); }); diff --git a/src/bridge.ts b/src/bridge.ts index ce983d59..61996c30 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -51,6 +51,7 @@ window.addEventListener("load", () => { const OldNotification = window.Notification; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore window.Notification = function (title: string, options: NotificationOptions) { const icon = getProfileImg(title); @@ -77,9 +78,10 @@ window.Notification = function (title: string, options: NotificationOptions) { return notification; }; -window.Notification.requestPermission = async () => "granted"; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore window.Notification.permission = "granted"; +window.Notification.requestPermission = async () => "granted"; ipcRenderer.on("focus-conversation", (event, i) => { focusFunctions[i](); diff --git a/src/helpers/autoUpdate.ts b/src/helpers/autoUpdate.ts index 0fbc8aed..d724c817 100644 --- a/src/helpers/autoUpdate.ts +++ b/src/helpers/autoUpdate.ts @@ -19,7 +19,11 @@ export async function checkForUpdate( const results = await autoUpdater.checkForUpdates().catch(() => null); let isUpdate = false; if (results != null) { - console.log(results.updateInfo.version, app.getVersion(), results.updateInfo.version > app.getVersion()); + console.log( + results.updateInfo.version, + app.getVersion(), + results.updateInfo.version > app.getVersion() + ); isUpdate = results.updateInfo.version > app.getVersion(); if (isUpdate && showNotification) { @@ -33,7 +37,9 @@ export async function checkForUpdate( notification.show(); } } - const installUpdateMenuItem = Menu.getApplicationMenu()?.getMenuItemById("installUpdateMenuItem"); + const installUpdateMenuItem = Menu.getApplicationMenu()?.getMenuItemById( + "installUpdateMenuItem" + ); if (installUpdateMenuItem != null) { installUpdateMenuItem.visible = isUpdate; } diff --git a/src/helpers/observers.ts b/src/helpers/observers.ts index 64e9dc91..a9adc0e0 100644 --- a/src/helpers/observers.ts +++ b/src/helpers/observers.ts @@ -1,4 +1,4 @@ -import { BrowserWindow, ipcRenderer } from "electron"; +import { ipcRenderer } from "electron"; import { RECENT_CONVERSATION_TRAY_COUNT } from "./constants"; import { Conversation } from "./trayManager"; @@ -13,9 +13,7 @@ function unreadObserver() { export function createUnreadObserver(): MutationObserver { const observer = new MutationObserver(unreadObserver); observer.observe( - (document.body.querySelector( - "mws-conversations-list" - ) as unknown) as Element, + document.body.querySelector("mws-conversations-list") as unknown as Element, { subtree: true, attributes: true, @@ -35,8 +33,9 @@ export function recentThreadObserver() { ).slice(0, RECENT_CONVERSATION_TRAY_COUNT); const data: Conversation[] = conversations.map((conversation, i) => { - const name = conversation.querySelector("a div.text-content h3.name span") - ?.textContent; + const name = conversation.querySelector( + "a div.text-content h3.name span" + )?.textContent; const canvas = conversation.querySelector( "a div.avatar-container canvas" ) as HTMLCanvasElement | null; @@ -58,9 +57,7 @@ export function recentThreadObserver() { export function createRecentThreadObserver(): MutationObserver { const observer = new MutationObserver(recentThreadObserver); observer.observe( - (document.body.querySelector( - "mws-conversations-list" - ) as unknown) as Element, + document.body.querySelector("mws-conversations-list") as unknown as Element, { attributes: false, subtree: true, diff --git a/src/helpers/settings.ts b/src/helpers/settings.ts index eb70b194..c288fbe5 100644 --- a/src/helpers/settings.ts +++ b/src/helpers/settings.ts @@ -83,6 +83,9 @@ if (!jetpack.exists(SETTINGS_FILE())) { } // temporary settings object during creation +// This is ok because this object is holding stuff derived from the loop of defaultSettings +// There may be an elegant way to express the type but I do not know it. +// eslint-disable-next-line @typescript-eslint/no-explicit-any const settingsToExport: any = {}; // loop through and create all the settings diff --git a/src/helpers/trayManager.ts b/src/helpers/trayManager.ts index 5d40f0fa..e38f0dbd 100644 --- a/src/helpers/trayManager.ts +++ b/src/helpers/trayManager.ts @@ -90,8 +90,8 @@ export class TrayManager { } public refreshTrayMenu() { - const conversationMenuItems: MenuItemConstructorOptions[] = this.recentConversations.map( - ({ name, image, recentMessage, i }) => { + const conversationMenuItems: MenuItemConstructorOptions[] = + this.recentConversations.map(({ name, image, recentMessage, i }) => { const icon = image != null && image != INITIAL_ICON_IMAGE && @@ -108,8 +108,7 @@ export class TrayManager { getMainWindow()?.webContents.send("focus-conversation", i); }, }; - } - ); + }); this.tray?.setContextMenu( Menu.buildFromTemplate([ ...conversationMenuItems, diff --git a/src/menu/contextMenu.ts b/src/menu/contextMenu.ts index f46e65ae..b843f8eb 100644 --- a/src/menu/contextMenu.ts +++ b/src/menu/contextMenu.ts @@ -1,9 +1,4 @@ -import { - ContextMenuParams, - Menu, - MenuItemConstructorOptions, - app, -} from "electron"; +import { ContextMenuParams, Menu, MenuItemConstructorOptions } from "electron"; import { getMainWindow } from "../helpers/getMainWindow"; import { separator } from "./items/separator"; @@ -56,7 +51,7 @@ export const popupContextMenu = ( _event: Electron.Event, params: ContextMenuParams ) => { - let menu: any = Menu.buildFromTemplate(standardMenuTemplate); + let menu = Menu.buildFromTemplate(standardMenuTemplate); if (params.mediaType === "none" && params.isEditable) { const textMenuTemplateCopy = [...textMenuTemplate]; if (params.misspelledWord) { diff --git a/src/menu/items/about.ts b/src/menu/items/about.ts index 8098d29f..c8c5524f 100644 --- a/src/menu/items/about.ts +++ b/src/menu/items/about.ts @@ -1,7 +1,7 @@ import openAboutWindow from "about-window"; import { app, MenuItemConstructorOptions } from "electron"; import path from "path"; -import { IS_DEV, RESOURCES_PATH } from "../../helpers/constants"; +import { RESOURCES_PATH } from "../../helpers/constants"; const productName = "Android Messages Desktop"; const localeStyle = diff --git a/src/menu/settingsMenu.ts b/src/menu/settingsMenu.ts index ce0fa5f3..986641b0 100644 --- a/src/menu/settingsMenu.ts +++ b/src/menu/settingsMenu.ts @@ -1,9 +1,4 @@ -import { - BrowserWindow, - Menu, - MenuItem, - MenuItemConstructorOptions, -} from "electron"; +import { BrowserWindow, MenuItem, MenuItemConstructorOptions } from "electron"; import { IS_MAC } from "../helpers/constants"; import { settings } from "../helpers/settings"; import { separator } from "./items/separator"; diff --git a/src/menu/trayMenu.ts b/src/menu/trayMenu.ts index f87b237d..523a1152 100644 --- a/src/menu/trayMenu.ts +++ b/src/menu/trayMenu.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, MenuItemConstructorOptions } from "electron"; +import { app, MenuItemConstructorOptions } from "electron"; import { IS_MAC } from "../helpers/constants"; import { getMainWindow } from "../helpers/getMainWindow"; import { separator } from "./items/separator";