From 3b828ca0f44f7b4236f7827afa4c20a44f504ac2 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:02:36 -0300 Subject: [PATCH] feat: adjust css --- src/main/main.ts | 20 -------------- .../achievements/merge-achievements.ts | 5 +--- src/main/services/notifications/index.ts | 26 ++++++++++--------- .../achievements/achievements-content.tsx | 1 - .../pages/achievements/achievements.css.ts | 25 ------------------ 5 files changed, 15 insertions(+), 62 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index abf3072f..69bc62e0 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -12,10 +12,6 @@ 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"); @@ -53,21 +49,5 @@ userPreferencesRepository where: { id: 1 }, }) .then((userPreferences) => { - publishCombinedNewAchievementNotification(1000, 999); - - publishNewAchievementNotification({ - achievements: [ - { - displayName: "Teste 1", - iconUrl: - "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg", - }, - ], - unlockedAchievementCount: 10, - totalAchievementCount: 34, - gameTitle: "Teste", - gameIcon: null, - }); - loadState(userPreferences); }); diff --git a/src/main/services/achievements/merge-achievements.ts b/src/main/services/achievements/merge-achievements.ts index 2b3b21d5..43e2759b 100644 --- a/src/main/services/achievements/merge-achievements.ts +++ b/src/main/services/achievements/merge-achievements.ts @@ -8,10 +8,7 @@ import { HydraApi } from "../hydra-api"; import { getUnlockedAchievements } from "@main/events/user/get-unlocked-achievements"; import { Game } from "@main/entity"; import { achievementsLogger } from "../logger"; -import { - publishCombinedNewAchievementNotification, - publishNewAchievementNotification, -} from "../notifications"; +import { publishNewAchievementNotification } from "../notifications"; const saveAchievementsOnLocal = async ( objectId: string, diff --git a/src/main/services/notifications/index.ts b/src/main/services/notifications/index.ts index 4f598868..e4fb8f6e 100644 --- a/src/main/services/notifications/index.ts +++ b/src/main/services/notifications/index.ts @@ -73,7 +73,10 @@ export const publishNotificationUpdateReadyToInstall = async ( export const publishNewFriendRequestNotification = async () => {}; -async function downloadImage(url: string) { +async function downloadImage(url: string | null) { + if (!url) return null; + if (!url.startsWith("http")) return null; + const fileName = url.split("/").pop()!; const outputPath = path.join(app.getPath("temp"), fileName); const writer = fs.createWriteStream(outputPath); @@ -94,13 +97,8 @@ async function downloadImage(url: string) { export const publishCombinedNewAchievementNotification = async ( achievementCount, - gameCount, - achievementIcon?: string + gameCount ) => { - const iconPath = achievementIcon - ? await downloadImage(achievementIcon) - : icon; - const options: NotificationOptions = { title: t("achievement_unlocked", { ns: "achievement" }), body: t("new_achievements_unlocked", { @@ -108,7 +106,7 @@ export const publishCombinedNewAchievementNotification = async ( gameCount, achievementCount, }), - icon: iconPath, + icon, silent: true, }; @@ -117,7 +115,9 @@ export const publishCombinedNewAchievementNotification = async ( toastXml: toXmlString(options), }).show(); - sound.play(achievementSoundPath); + if (process.platform !== "linux") { + sound.play(achievementSoundPath); + } }; export const publishNewAchievementNotification = async (info: { @@ -136,12 +136,12 @@ export const publishNewAchievementNotification = async (info: { achievementCount: info.achievements.length, }), body: info.achievements.map((a) => a.displayName).join(", "), - icon: info.gameIcon ? await downloadImage(info.gameIcon) : icon, + icon: (await downloadImage(info.gameIcon)) ?? icon, } : { title: t("achievement_unlocked", { ns: "achievement" }), body: info.achievements[0].displayName, - icon: await downloadImage(info.achievements[0].iconUrl), + icon: (await downloadImage(info.achievements[0].iconUrl)) ?? icon, }; const options: NotificationOptions = { @@ -162,5 +162,7 @@ export const publishNewAchievementNotification = async (info: { toastXml: toXmlString(options), }).show(); - sound.play(achievementSoundPath); + if (process.platform !== "linux") { + sound.play(achievementSoundPath); + } }; diff --git a/src/renderer/src/pages/achievements/achievements-content.tsx b/src/renderer/src/pages/achievements/achievements-content.tsx index 72dfe83f..a7a9aaa8 100644 --- a/src/renderer/src/pages/achievements/achievements-content.tsx +++ b/src/renderer/src/pages/achievements/achievements-content.tsx @@ -273,7 +273,6 @@ export function AchievementsContent({ src={steamUrlBuilder.libraryHero(objectId)} style={{ display: "none" }} alt={gameTitle} - className={styles.heroImage} onLoad={handleHeroLoad} /> diff --git a/src/renderer/src/pages/achievements/achievements.css.ts b/src/renderer/src/pages/achievements/achievements.css.ts index ba5e36ef..242ed6f6 100644 --- a/src/renderer/src/pages/achievements/achievements.css.ts +++ b/src/renderer/src/pages/achievements/achievements.css.ts @@ -23,31 +23,6 @@ export const hero = style({ flexDirection: "column", position: "relative", transition: "all ease 0.2s", - "@media": { - "(min-width: 1250px)": { - height: "350px", - minHeight: "350px", - }, - }, -}); - -export const heroImage = style({ - width: "100%", - height: `${HERO_HEIGHT}px`, - minHeight: `${HERO_HEIGHT}px`, - objectFit: "cover", - objectPosition: "top", - transition: "all ease 0.2s", - position: "absolute", - zIndex: "0", - filter: "blur(5px)", - "@media": { - "(min-width: 1250px)": { - objectPosition: "center", - height: "350px", - minHeight: "350px", - }, - }, }); export const heroContent = style({