feat: show notification on launch

This commit is contained in:
Zamitto
2024-10-21 12:57:07 -03:00
parent 9f76ae8c59
commit d801bad49e
9 changed files with 72 additions and 19 deletions

View File

@@ -13,6 +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";
const fileStats: Map<string, number> = new Map();
const fltFiles: Map<string, Set<string>> = new Map();
@@ -136,6 +137,8 @@ const processAchievementFileDiff = async (
if (unlockedAchievements.length) {
return mergeAchievements(game, unlockedAchievements, true);
}
return 0;
};
export class AchievementWatcherManager {
@@ -234,11 +237,16 @@ export class AchievementWatcherManager {
};
public static preSearchAchievements = async () => {
if (process.platform === "win32") {
await this.preSearchAchievementsWindows();
} else {
await this.preSearchAchievementsWithWine();
}
const newAchievementsCount =
process.platform === "win32"
? await this.preSearchAchievementsWindows()
: await this.preSearchAchievementsWithWine();
WindowManager.notificationWindow?.webContents.send(
"on-combined-achievements-unlocked",
newAchievementsCount.filter((achievements) => achievements).length,
newAchievementsCount.reduce((acc, val) => acc + val, 0)
);
this.hasFinishedMergingWithRemote = true;
};

View File

@@ -201,10 +201,10 @@ const getPathFromCracker = (cracker: Cracker) => {
if (cracker === Cracker.flt) {
return [
{
folderPath: path.join(appData, "FLT"),
fileLocation: ["stats"],
},
// {
// folderPath: path.join(appData, "FLT"),
// fileLocation: ["stats"],
// },
];
}

View File

@@ -117,7 +117,7 @@ export const mergeAchievements = async (
const mergedLocalAchievements = unlockedAchievements.concat(newAchievements);
if (game.remoteId) {
return HydraApi.put(
await HydraApi.put(
"/profile/games/achievements",
{
id: game.remoteId,
@@ -141,12 +141,14 @@ export const mergeAchievements = async (
publishNotification
);
});
} else {
await saveAchievementsOnLocal(
game.objectID,
game.shop,
mergedLocalAchievements,
publishNotification
);
}
return saveAchievementsOnLocal(
game.objectID,
game.shop,
mergedLocalAchievements,
publishNotification
);
return newAchievements.length;
};