From dda7c7c958db3a4dce4e75ffcf2e3406c5c5cd04 Mon Sep 17 00:00:00 2001 From: Kylie C <52550063+Covkie@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:59:45 -0400 Subject: [PATCH] Unread badge and suggestions Applied reviewer suggestions. Unread Badge displays a `0` --- src/main/appBadge.ts | 25 +++++++++++++++++++------ src/main/mainWindow.ts | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/appBadge.ts b/src/main/appBadge.ts index 602c14a..40b68c6 100644 --- a/src/main/appBadge.ts +++ b/src/main/appBadge.ts @@ -7,7 +7,7 @@ import { app, NativeImage, nativeImage } from "electron"; import { join } from "path"; import { BADGE_DIR } from "shared/paths"; -import { exec } from "child_process"; +import { execFile } from "child_process"; const imgCache = new Map(); function loadBadge(index: number) { @@ -25,18 +25,31 @@ let lastIndex: null | number = -1; export function setBadgeCount(count: number) { switch (process.platform) { case "linux": - if (count === -1) count = 0; - // app.setBadgeCount(count); + if (typeof count !== "number") { //sanitize + console.log("what the hel- *kaboom*") + break; + } function emitDBusBadge(count: number, visible: boolean) { - const badgeCountCommand = `gdbus emit --session --object-path / --signal com.canonical.Unity.LauncherEntry.Update "application://vesktop.desktop" "{'count': , 'count-visible': <${visible}>}"`; - exec(badgeCountCommand) + execFile ("gdbus", [ + "emit", + "--session", + "--object-path", + "/", + "--signal", + "com.canonical.Unity.LauncherEntry.Update", + "application://vesktop.desktop", + `{\'count\': , \'count-visible\': <${visible}>}` + ]); } - if (count === 0) { emitDBusBadge(count, false); break; } + if (count === -1) { + emitDBusBadge(0, true); + break; + } emitDBusBadge(count, true); break; case "darwin": diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 33f5a28..39acec8 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -446,7 +446,7 @@ function createMainWindow() { if (Settings.store.staticTitle) win.on("page-title-updated", e => e.preventDefault()); else if (Settings.store.appBadge) mainWin.webContents.on('page-title-updated', (_, title) => { - let cleanedTitle = title.replace(/^\(\d+\)\s*/, ''); + let cleanedTitle = title.replace(/^\(\d+\)\s*|•\s/, ''); mainWin.setTitle(cleanedTitle); });