From a419b9ae38ce7048f984465678dc1bfd0a304cea Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:50:52 -0300 Subject: [PATCH] feat: add test notification --- src/main/main.ts | 14 ++++++++++++++ .../achievements/achievement-watcher-manager.ts | 13 +++++++------ .../services/achievements/merge-achievements.ts | 2 +- src/main/services/notifications.ts | 2 +- src/types/index.ts | 2 ++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 69bc62e0..f108feb7 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -12,6 +12,10 @@ import { UserPreferences } from "./entity"; import { RealDebridClient } from "./services/real-debrid"; import { HydraApi } from "./services/hydra-api"; import { uploadGamesBatch } from "./services/library-sync"; +import { + publishCombinedNewAchievementNotification, + publishNewAchievementNotification, +} from "./services/notifications"; const loadState = async (userPreferences: UserPreferences | null) => { import("./events"); @@ -49,5 +53,15 @@ userPreferencesRepository where: { id: 1 }, }) .then((userPreferences) => { + publishCombinedNewAchievementNotification(1000, 999); + + publishNewAchievementNotification({ + displayName: "Teste 1", + achievementIcon: + "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg", + unlockedAchievementCount: 10, + totalAchievementCount: 34, + }); + loadState(userPreferences); }); diff --git a/src/main/services/achievements/achievement-watcher-manager.ts b/src/main/services/achievements/achievement-watcher-manager.ts index 973ac3a7..b7c71f86 100644 --- a/src/main/services/achievements/achievement-watcher-manager.ts +++ b/src/main/services/achievements/achievement-watcher-manager.ts @@ -13,8 +13,7 @@ import type { AchievementFile, UnlockedAchievement } from "@types"; import { achievementsLogger } from "../logger"; import { Cracker } from "@shared"; import { IsNull, Not } from "typeorm"; -import { WindowManager } from "../window-manager"; -import { publishNewAchievementBulkNotification } from "../notifications"; +import { publishCombinedNewAchievementNotification } from "../notifications"; const fileStats: Map = new Map(); const fltFiles: Map> = new Map(); @@ -250,10 +249,12 @@ export class AchievementWatcherManager { 0 ); - publishNewAchievementBulkNotification( - totalNewAchievements, - totalNewGamesWithAchievements - ); + if (totalNewAchievements > 0) { + publishCombinedNewAchievementNotification( + totalNewAchievements, + totalNewGamesWithAchievements + ); + } this.hasFinishedMergingWithRemote = true; }; diff --git a/src/main/services/achievements/merge-achievements.ts b/src/main/services/achievements/merge-achievements.ts index 0fb7cb96..196574d9 100644 --- a/src/main/services/achievements/merge-achievements.ts +++ b/src/main/services/achievements/merge-achievements.ts @@ -9,7 +9,7 @@ import { getUnlockedAchievements } from "@main/events/user/get-unlocked-achievem import { Game } from "@main/entity"; import { achievementsLogger } from "../logger"; import { - publishNewAchievementBulkNotification as publishCombinedNewAchievementNotification, + publishCombinedNewAchievementNotification, publishNewAchievementNotification, } from "../notifications"; diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index c3473cd1..e7cb1374 100644 --- a/src/main/services/notifications.ts +++ b/src/main/services/notifications.ts @@ -92,7 +92,7 @@ async function downloadImage(url: string) { }); } -export const publishNewAchievementBulkNotification = async ( +export const publishCombinedNewAchievementNotification = async ( achievementCount, gameCount, achievementIcon?: string diff --git a/src/types/index.ts b/src/types/index.ts index 80a910e6..95a5410d 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -94,6 +94,8 @@ export interface UserGame { cover: string; playTimeInSeconds: number; lastTimePlayed: Date | null; + unlockedAchievementCount: number; + achievementCount: number; } export interface DownloadQueue {