Skip to content

Commit

Permalink
fix all style mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeDrangon committed Dec 29, 2021
1 parent 94300dd commit 99367fe
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
});
4 changes: 3 additions & 1 deletion src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]();
Expand Down
10 changes: 8 additions & 2 deletions src/helpers/autoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
15 changes: 6 additions & 9 deletions src/helpers/observers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserWindow, ipcRenderer } from "electron";
import { ipcRenderer } from "electron";
import { RECENT_CONVERSATION_TRAY_COUNT } from "./constants";
import { Conversation } from "./trayManager";

Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/helpers/trayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -108,8 +108,7 @@ export class TrayManager {
getMainWindow()?.webContents.send("focus-conversation", i);
},
};
}
);
});
this.tray?.setContextMenu(
Menu.buildFromTemplate([
...conversationMenuItems,
Expand Down
9 changes: 2 additions & 7 deletions src/menu/contextMenu.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/menu/items/about.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
7 changes: 1 addition & 6 deletions src/menu/settingsMenu.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/menu/trayMenu.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 99367fe

Please sign in to comment.