feat: add test notification

This commit is contained in:
Zamitto 2024-10-29 23:50:52 -03:00
parent 7d4d434164
commit a419b9ae38
5 changed files with 25 additions and 8 deletions

View file

@ -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);
});

View file

@ -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<string, number> = new Map();
const fltFiles: Map<string, Set<string>> = new Map();
@ -250,10 +249,12 @@ export class AchievementWatcherManager {
0
);
publishNewAchievementBulkNotification(
totalNewAchievements,
totalNewGamesWithAchievements
);
if (totalNewAchievements > 0) {
publishCombinedNewAchievementNotification(
totalNewAchievements,
totalNewGamesWithAchievements
);
}
this.hasFinishedMergingWithRemote = true;
};

View file

@ -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";

View file

@ -92,7 +92,7 @@ async function downloadImage(url: string) {
});
}
export const publishNewAchievementBulkNotification = async (
export const publishCombinedNewAchievementNotification = async (
achievementCount,
gameCount,
achievementIcon?: string

View file

@ -94,6 +94,8 @@ export interface UserGame {
cover: string;
playTimeInSeconds: number;
lastTimePlayed: Date | null;
unlockedAchievementCount: number;
achievementCount: number;
}
export interface DownloadQueue {