From c7c303c5512927d22b430dda449727b296f3676f Mon Sep 17 00:00:00 2001 From: Heikki Aitakangas Date: Wed, 12 Jan 2022 20:57:45 +0200 Subject: [PATCH] Handle Steam achievement status check failure by logging them --- electron/achievements.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/electron/achievements.js b/electron/achievements.js index c136de958..1fc513ce2 100644 --- a/electron/achievements.js +++ b/electron/achievements.js @@ -10,7 +10,7 @@ async function enableAchievementsInterval(window) { // here. Hey if it works it works. const steamAchievements = greenworks.getAchievementNames(); log.info(`All Steam achievements ${JSON.stringify(steamAchievements)}`); - const playerAchieved = (await Promise.all(steamAchievements.map(name => new Promise((resolve, reject) => { greenworks.getAchievement(name, (playerHas) => resolve(playerHas ? name : ""), reject); })))).filter(name => !!name); + const playerAchieved = (await Promise.all(steamAchievements.map(checkSteamAchievement))).filter(name => !!name); log.info(`Player has Steam achievements ${JSON.stringify(playerAchieved)}`); const intervalID = setInterval(async () => { try { @@ -34,6 +34,15 @@ async function enableAchievementsInterval(window) { window.achievementsIntervalID = intervalID; } +function checkSteamAchievement(name) { + return new Promise((resolve) => { + greenworks.getAchievement(name, playerHas => resolve(playerHas ? name : ""), err => { + log.warn(`Failed to get Steam achievement ${name} status: ${err}`); + resolve(""); + }); + }); +} + function disableAchievementsInterval(window) { if (window.achievementsIntervalID) { clearInterval(window.achievementsIntervalID);