mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 05:41:03 +00:00
feat: i18n and refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
AchievementNotificationInfo,
|
||||
Game,
|
||||
GameShop,
|
||||
UnlockedAchievement,
|
||||
@@ -86,7 +87,7 @@ export const mergeAchievements = async (
|
||||
publishNotification &&
|
||||
userPreferences?.achievementNotificationsEnabled
|
||||
) {
|
||||
const achievementsInfo = newAchievements
|
||||
const achievementsInfo: AchievementNotificationInfo[] = newAchievements
|
||||
.toSorted((a, b) => {
|
||||
return a.unlockTime - b.unlockTime;
|
||||
})
|
||||
@@ -101,7 +102,12 @@ export const mergeAchievements = async (
|
||||
.filter((achievement) => Boolean(achievement))
|
||||
.map((achievement) => {
|
||||
return {
|
||||
displayName: achievement!.displayName,
|
||||
title: achievement!.displayName,
|
||||
description: achievement!.description,
|
||||
points: achievement!.points,
|
||||
isHidden: achievement!.hidden,
|
||||
isRare: false,
|
||||
isPlatinum: false,
|
||||
iconUrl: achievement!.icon,
|
||||
};
|
||||
});
|
||||
@@ -109,8 +115,6 @@ export const mergeAchievements = async (
|
||||
if (userPreferences?.achievementCustomNotificationsEnabled !== false) {
|
||||
WindowManager.notificationWindow?.webContents.send(
|
||||
"on-achievement-unlocked",
|
||||
game.objectId,
|
||||
game.shop,
|
||||
userPreferences.achievementCustomNotificationPosition ?? "top_left",
|
||||
achievementsInfo
|
||||
);
|
||||
|
||||
@@ -162,7 +162,7 @@ export const publishExtractionCompleteNotification = async (game: Game) => {
|
||||
};
|
||||
|
||||
export const publishNewAchievementNotification = async (info: {
|
||||
achievements: { displayName: string; iconUrl: string }[];
|
||||
achievements: { title: string; iconUrl: string }[];
|
||||
unlockedAchievementCount: number;
|
||||
totalAchievementCount: number;
|
||||
gameTitle: string;
|
||||
@@ -176,12 +176,12 @@ export const publishNewAchievementNotification = async (info: {
|
||||
gameTitle: info.gameTitle,
|
||||
achievementCount: info.achievements.length,
|
||||
}),
|
||||
body: info.achievements.map((a) => a.displayName).join(", "),
|
||||
body: info.achievements.map((a) => a.title).join(", "),
|
||||
icon: (await downloadImage(info.gameIcon)) ?? icon,
|
||||
}
|
||||
: {
|
||||
title: t("achievement_unlocked", { ns: "achievement" }),
|
||||
body: info.achievements[0].displayName,
|
||||
body: info.achievements[0].title,
|
||||
icon: (await downloadImage(info.achievements[0].iconUrl)) ?? icon,
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { db, gamesSublevel, levelKeys } from "@main/level";
|
||||
import { orderBy, slice } from "lodash-es";
|
||||
import type {
|
||||
AchievementCustomNotificationPosition,
|
||||
AchievementNotificationInfo,
|
||||
ScreenState,
|
||||
UserPreferences,
|
||||
} from "@types";
|
||||
@@ -371,10 +372,28 @@ export class WindowManager {
|
||||
}
|
||||
|
||||
if (showTestNotification) {
|
||||
const language = userPreferences.language ?? "en";
|
||||
setTimeout(() => {
|
||||
this.notificationWindow?.webContents.send(
|
||||
"on-test-achievement-notification",
|
||||
userPreferences.achievementCustomNotificationPosition ?? "top_left"
|
||||
"on-achievement-unlocked",
|
||||
userPreferences.achievementCustomNotificationPosition ?? "top_left",
|
||||
[
|
||||
{
|
||||
title: t("test_achievement_notification_title", {
|
||||
ns: "notifications",
|
||||
lng: language,
|
||||
}),
|
||||
description: t("test_achievement_notification_description", {
|
||||
ns: "notifications",
|
||||
lng: language,
|
||||
}),
|
||||
iconUrl: "https://cdn.losbroxas.org/favicon.svg",
|
||||
points: 100,
|
||||
isHidden: false,
|
||||
isRare: false,
|
||||
isPlatinum: false,
|
||||
},
|
||||
] as AchievementNotificationInfo[]
|
||||
);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user