mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
bc9dad02e5
commit
4d95bb89ee
2 changed files with 12 additions and 4 deletions
|
@ -3,7 +3,7 @@ import { mkdirp } from "mkdirp";
|
|||
import fs from "fs";
|
||||
import log from "./logger";
|
||||
import { getTeaPath } from "./tea-dir";
|
||||
import { GUIPackage, Packages } from "../../src/libs/types";
|
||||
import { Packages } from "../../src/libs/types";
|
||||
|
||||
const pkgsFilePath = path.join(getTeaPath(), "tea.xyz/gui/pkgs.json");
|
||||
const pkgsFolder = path.join(getTeaPath(), "tea.xyz/gui");
|
||||
|
@ -52,3 +52,8 @@ export const nameToSlug = (name: string) => {
|
|||
const slug = nameOnly.replace(/[^\w\s]/gi, "_").toLocaleLowerCase();
|
||||
return slug;
|
||||
};
|
||||
|
||||
export function isInstalled(fullName: string) {
|
||||
const folderPath = path.join(getTeaPath(), fullName);
|
||||
return fs.existsSync(folderPath);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { readSessionData } from "./auth";
|
|||
import { post } from "./v1-client";
|
||||
import log from "./logger";
|
||||
import { Notification, BrowserWindow } from "electron";
|
||||
import { nameToSlug } from "./package";
|
||||
import { isInstalled, nameToSlug } from "./package";
|
||||
import {
|
||||
getInstalledPackages,
|
||||
getPackagesInstalledList,
|
||||
|
@ -42,9 +42,10 @@ export default function initialize(mainWindow: BrowserWindow) {
|
|||
Pushy.setNotificationListener(async (data: any) => {
|
||||
try {
|
||||
log.info("new notification received", data);
|
||||
|
||||
const pkg = data?.url.replace("tea://packages/", "");
|
||||
const installed = isInstalled(pkg);
|
||||
const isDup = await wasReceivedBefore(data);
|
||||
if (!isDup) {
|
||||
if (!isDup && installed) {
|
||||
new Notification({
|
||||
title: "tea",
|
||||
body: data?.message as string
|
||||
|
@ -56,6 +57,8 @@ export default function initialize(mainWindow: BrowserWindow) {
|
|||
} else {
|
||||
app.dock.setBadge((parseInt(v) + 1).toString());
|
||||
}
|
||||
} else if (!installed) {
|
||||
unsubscribeToPackageTopic(pkg);
|
||||
} else {
|
||||
log.info("notification was already received before", data);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue