Skip to content

Commit e402907

Browse files
committed
Merge branch 'main' of https://github.com/HyperPlay-Gaming/hyperplay-desktop-client into feat/retry_ipdt_download
2 parents 18d6aaf + 15aae12 commit e402907

File tree

12 files changed

+369
-105
lines changed

12 files changed

+369
-105
lines changed

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"version": "0.23.2",
44
"private": true,
55
"main": "build/main/main.js",
6+
"productName": "HyperPlay",
67
"homepage": "./",
78
"license": "GPL-3.0-only",
8-
"description": "An Open Source Launcher for Web3, GOG and Epic Games",
9+
"description": "HyperPlay",
910
"repository": {
1011
"type": "Github",
1112
"url": "https://github.com/HyperPlay-Gaming/hyperplay-desktop-client"
@@ -71,8 +72,8 @@
7172
"@fortawesome/react-fontawesome": "^0.2.2",
7273
"@hyperplay/chains": "^0.5.0",
7374
"@hyperplay/check-disk-space": "^3.5.2",
74-
"@hyperplay/quests-ui": "^0.1.23",
75-
"@hyperplay/ui": "^1.9.7",
75+
"@hyperplay/quests-ui": "^0.1.26",
76+
"@hyperplay/ui": "^1.9.9",
7677
"@hyperplay/utils": "^0.3.7",
7778
"@mantine/carousel": "^7.12.0",
7879
"@mantine/core": "^7.12.0",
@@ -88,6 +89,7 @@
8889
"@tanstack/query-core": "^5.59.13",
8990
"@tanstack/react-query": "^5.59.15",
9091
"@valist/sdk": "^2.10.5",
92+
"@wagmi/core": "2.15.2",
9193
"@walletconnect/browser-utils": "^1.8.0",
9294
"@walletconnect/ethereum-provider": "^2.10.6",
9395
"@walletconnect/modal": "^2.6.0",
@@ -152,7 +154,7 @@
152154
"ts-prune": "^0.10.3",
153155
"tslib": "^2.6.3",
154156
"viem": "2.x",
155-
"wagmi": "^2.9.8",
157+
"wagmi": "^2.14.12",
156158
"yauzl": "^3.1.3",
157159
"zod": "^3.23.8"
158160
},

pnpm-lock.yaml

+80-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/locales/en/gamepage.json

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"yesCancel": "Yes, cancel"
6060
},
6161
"button": {
62+
"add_to_library": "Add to library",
6263
"cancel": "Pause/Cancel",
6364
"continue": "Continue Download",
6465
"details": "Details",
@@ -229,5 +230,13 @@
229230
"settings": "Settings",
230231
"store": "Store Page",
231232
"verify": "Verify and Repair"
233+
},
234+
"tooltip": {
235+
"installed_from_epic": "Installed from Epic Store",
236+
"installed_from_gog": "Installed from GOG Store",
237+
"installed_from_hyperplay": "Installed from HyperPlay Store",
238+
"will_install_from_epic": "Will install from Epic Store",
239+
"will_install_from_gog": "Will install from GOG Store",
240+
"will_install_from_hyperplay": "Will install from HyperPlay Store"
232241
}
233242
}

public/locales/en/translation.json

+19-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,25 @@
8888
"title": "Ubisoft Connect"
8989
},
9090
"update": {
91-
"message": "Something went wrong with the update! Please manually uninstall and reinstall HyperPlay.",
92-
"title": "Update Error"
91+
"addressUnreachable": "Address unreachable. Please check your internet connection.",
92+
"body": "Something went wrong with the update after multiple attempts! Please check the error message below or reinstall HyperPlay. error: {{error}}",
93+
"certAuthorityInvalid": "Certificate authority invalid. Please check your system time and date or open a ticket with HyperPlay support.",
94+
"certDateInvalid": "Certificate date invalid. Please check your system time and date or open a ticket with HyperPlay support.",
95+
"connectionAborted": "Connection aborted. Please check your internet connection.",
96+
"connectionClosed": "Connection closed. Please check your internet connection.",
97+
"connectionRefused": "Connection refused. Please check your internet connection.",
98+
"connectionReset": "Connection reset. Please check your internet connection.",
99+
"connectionTimedOut": "Connection timed out. Please check your internet connection.",
100+
"emptyResponse": "Empty response. Please check your internet connection.",
101+
"failed": "Download Failed. Please check your internet connection.",
102+
"http2ServerRefusedStream": "HTTP2 server refused stream. Please check your internet connection.",
103+
"internetDisconnected": "Internet disconnected. Please check your internet connection.",
104+
"message": "Error Updating",
105+
"nameNotResolved": "Name not resolved. Please check your internet connection.",
106+
"networkAccessDenied": "Network access denied. Please check your internet connection.",
107+
"networkChanged": "Network changed. Please check your internet connection.",
108+
"proxyConnectionFailed": "Proxy connection failed. Please check your proxy settings.",
109+
"sslProtocolError": "SSL protocol error. Please check your system time and date or open a ticket with HyperPlay support."
93110
},
94111
"winetricks": {
95112
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",

src/backend/ipcHandlers/quests.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ async function fetchQuests({
1919
}): Promise<Quest[]> {
2020
const url = new URL(`${DEV_PORTAL_URL}api/v1/quests`)
2121
url.searchParams.append('questStatus', status)
22+
url.searchParams.append('sortBy', 'start_date')
23+
url.searchParams.append('order', 'desc')
2224
if (projectId) {
2325
url.searchParams.append('projectId', projectId)
2426
}

src/backend/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ import {
151151
checkWineBeforeLaunch,
152152
runWineCommandOnGame
153153
} from './utils/compatibility_layers'
154-
import { isClientUpdating } from 'backend/updater'
154+
import { isClientUpdating } from 'backend/updater/updater'
155155

156156
/*
157157
* INSERT OTHER IPC HANDLERS HERE

src/backend/metrics/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,15 @@ export interface ClientUpdateNotified {
399399
sensitiveProperties?: never
400400
}
401401

402+
export interface ClientUpdateDownloading {
403+
event: 'Downloading Client Update'
404+
properties: {
405+
currentVersion: string
406+
newVersion: string
407+
}
408+
sensitiveProperties?: never
409+
}
410+
402411
export interface ClientUpdateError {
403412
event: 'Client Update Error'
404413
properties: {
@@ -460,6 +469,7 @@ export type PossibleMetricPayloads =
460469
| RewardClaimSuccess
461470
| RewardClaimError
462471
| ClientUpdateNotified
472+
| ClientUpdateDownloading
463473
| ClientUpdateError
464474
| ClientUpdateDownloaded
465475
| PatchingStarted

src/backend/updater.ts src/backend/updater/updater.ts

+83-25
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { dialog, shell } from 'electron'
1+
import { app, dialog, shell } from 'electron'
22
import { autoUpdater } from 'electron-updater'
33
import { t } from 'i18next'
44

5-
import { configStore, icon, isLinux } from './constants'
6-
import { logError, logInfo, LogPrefix } from './logger/logger'
7-
import { isOnline } from './online_monitor'
5+
import { configStore, icon, isLinux } from '../constants'
6+
import { logError, logInfo, LogPrefix } from '../logger/logger'
87
import { captureException } from '@sentry/electron'
9-
import { getFileSize } from './utils'
8+
import { getFileSize } from '../utils'
109
import { ClientUpdateStatuses } from '@hyperplay/utils'
11-
import { trackEvent } from './metrics/metrics'
12-
// to test auto update on windows locally make sure you added the option "verifyUpdateCodeSignature": false
13-
// under build.win in package.json and also change the app version to an old one there
10+
import { trackEvent } from '../metrics/metrics'
11+
import { getErrorMessage, removeCachedUpdatesFolder } from './utils'
12+
// to test auto update on windows locally make sure you added the option verifyUpdateCodeSignature: false
13+
// under build.win in electron-builder.yml and also change the app version to an old one there
1414

1515
const appSettings = configStore.get_nodefault('settings')
1616
const shouldCheckForUpdates = appSettings?.checkForUpdatesOnStartup === true
@@ -21,17 +21,35 @@ autoUpdater.autoInstallOnAppQuit = true
2121

2222
let isAppUpdating = false
2323
let hasUpdated = false
24+
let hasReportedDownloadStart = false
2425

25-
// check for updates every hour
26-
const checkUpdateInterval = 1 * 60 * 60 * 1000
27-
setInterval(() => {
28-
if (isOnline() && shouldCheckForUpdates) {
29-
autoUpdater.checkForUpdates()
26+
let updateAttempts = 0
27+
const MAX_UPDATE_ATTEMPTS = 10
28+
// check for updates every 3 hours
29+
const checkUpdateInterval = 3 * 1000 * 60 * 60
30+
31+
setInterval(async () => {
32+
if (shouldCheckForUpdates && !hasUpdated && !isAppUpdating) {
33+
logInfo('Checking for client updates...', LogPrefix.AutoUpdater)
34+
await autoUpdater.checkForUpdates()
3035
}
3136
}, checkUpdateInterval)
3237

3338
autoUpdater.on('update-available', async (info) => {
34-
if (!isOnline() || !shouldCheckForUpdates) {
39+
if (isAppUpdating && hasUpdated) {
40+
logInfo(
41+
'New update available, but user has already updated the app',
42+
LogPrefix.AutoUpdater
43+
)
44+
return
45+
}
46+
47+
if (!shouldCheckForUpdates) {
48+
logInfo(
49+
'New update available, but user has disabled auto updates',
50+
LogPrefix.AutoUpdater
51+
)
52+
3553
return
3654
}
3755
newVersion = info.version
@@ -56,6 +74,19 @@ autoUpdater.on('update-available', async (info) => {
5674
// log download progress
5775
autoUpdater.on('download-progress', (progress) => {
5876
isAppUpdating = true
77+
78+
// Track download start only once
79+
if (!hasReportedDownloadStart) {
80+
trackEvent({
81+
event: 'Downloading Client Update',
82+
properties: {
83+
currentVersion: autoUpdater.currentVersion.version,
84+
newVersion
85+
}
86+
})
87+
hasReportedDownloadStart = true
88+
}
89+
5990
logInfo(
6091
'Downloading HyperPlay update...' +
6192
`Download speed: ${progress.bytesPerSecond}, ` +
@@ -68,7 +99,10 @@ autoUpdater.on('download-progress', (progress) => {
6899
})
69100

70101
autoUpdater.on('update-downloaded', async () => {
71-
logInfo('App update is downloaded')
102+
logInfo('The App update was downloaded', LogPrefix.AutoUpdater)
103+
hasUpdated = true
104+
isAppUpdating = false
105+
hasReportedDownloadStart = false // Reset for potential future updates
72106

73107
trackEvent({
74108
event: 'Client Update Downloaded',
@@ -91,16 +125,38 @@ autoUpdater.on('update-downloaded', async () => {
91125
if (response === 1) {
92126
return autoUpdater.quitAndInstall()
93127
}
94-
hasUpdated = true
128+
logInfo('User chose not to update the app for now.', LogPrefix.AutoUpdater)
95129
})
96130

97131
autoUpdater.on('error', async (error) => {
98-
if (!isOnline()) {
132+
isAppUpdating = false
133+
const isNewVersion = newVersion !== app.getVersion()
134+
135+
// To avoid false positives, we should not show the error dialog if the app has already updated successfully
136+
if (hasUpdated || !isNewVersion) {
99137
return
100138
}
101139

102-
isAppUpdating = false
103-
logError(`Error updating HyperPlay: ${error.message}`, LogPrefix.AutoUpdater)
140+
const errorMessage = getErrorMessage(error.message)
141+
logError(`Error updating HyperPlay: ${errorMessage}`, LogPrefix.AutoUpdater)
142+
143+
// will remove cached updates when it fails to avoid corrupted updates
144+
if (updateAttempts > 3) {
145+
await removeCachedUpdatesFolder()
146+
}
147+
148+
updateAttempts++
149+
150+
if (updateAttempts < MAX_UPDATE_ATTEMPTS) {
151+
logInfo(
152+
`Retrying update attempt ${updateAttempts + 1}/${MAX_UPDATE_ATTEMPTS}`,
153+
LogPrefix.AutoUpdater
154+
)
155+
setTimeout(() => {
156+
autoUpdater.checkForUpdates()
157+
}, 6000)
158+
return
159+
}
104160

105161
trackEvent({
106162
event: 'Client Update Error',
@@ -115,17 +171,19 @@ autoUpdater.on('error', async (error) => {
115171
tags: {
116172
event: 'Client Update Error',
117173
currentVersion: autoUpdater.currentVersion.version,
118-
newVersion
174+
newVersion,
175+
totalAttempts: MAX_UPDATE_ATTEMPTS
119176
}
120177
})
121178

179+
updateAttempts = 0
180+
122181
const { response } = await dialog.showMessageBox({
123-
title: t('box.error.update.title', 'Error Updating'),
182+
title: t('box.error.update.message', 'Error Updating'),
124183
message: t(
125-
'box.error.update.message',
126-
`Something went wrong with the update after multiple attempts! Please manually uninstall and reinstall HyperPlay. error: ${JSON.stringify(
127-
error
128-
)}`
184+
'box.error.update.body',
185+
`Something went wrong with the update after multiple attempts! Please check the error message below or reinstall HyperPlay. error: {{error}}`,
186+
{ error: errorMessage }
129187
),
130188
type: 'error',
131189
buttons: [t('button.cancel', 'Cancel'), t('button.download', 'Download')]

0 commit comments

Comments
 (0)