Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioislima committed Nov 6, 2024
1 parent 4e42d40 commit 9db2ab1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 21 deletions.
83 changes: 63 additions & 20 deletions src/backend/downloadmanager/downloadqueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,59 @@ async function addToQueue(element: DMQueueElement) {
element.channel = element.params.channelName ?? 'main'

if (!element.params.size) {
const installSize = installInfo?.manifest?.download_size
? getFileSize(installInfo?.manifest?.download_size)
: '?? MB'

const updateSize =
// @ts-expect-error - confusion because of the platform
element.params.gameInfo.channels[element.channel!].release_meta
.platforms[element.params.platformToInstall].downloadSize
? getFileSize(
// @ts-expect-error - confusion because of the platform
element.params.gameInfo.channels[element.channel!].release_meta
.platforms[element.params.platformToInstall].downloadSize
)
: '?? MB'

element.params.size =
element.type === 'install' ? installSize : updateSize
let size = '?? MB'
if (element.type === 'install') {
const installSize = installInfo?.manifest?.download_size
if (installSize) {
size = getFileSize(installSize)
}
} else {
const {
channelName,
platformToInstall,
gameInfo: { channels }
} = element.params

const updateSize =
// @ts-expect-error - confusion because of the platform type
channels[channelName ?? 'main'].release_meta.platforms[
platformToInstall
]?.downloadSize

if (updateSize) {
size = getFileSize(updateSize)
}
}

element.params.size = size
}

if (!element.params.size) {
let size = '?? MB'
if (element.type === 'install') {
const installSize = installInfo?.manifest?.download_size
if (installSize) {
size = getFileSize(installSize)
}
} else {
const {
channelName,
platformToInstall,
gameInfo: { channels }
} = element.params

const updateSize =
// @ts-expect-error - confusion because of the platform type
channels[channelName ?? 'main'].release_meta.platforms[
platformToInstall
].downloadSize

if (updateSize) {
size = getFileSize(updateSize)
}
}

element.params.size = size
}

elements.push(element)
Expand Down Expand Up @@ -373,16 +409,23 @@ async function updateQueueElementParam<T extends keyof DMQueueElement>(
)
if (index !== -1) {
queue[index][prop] = value
if (currentElement) {
currentElement[prop] = value
}
updateCurrentElementParam(prop, value)
downloadManager.set('queue', queue)
sendFrontendMessage('changedDMQueueInformation', queue, queueState)
} else {
throw new Error('Element not found in the queue')
}
}

function updateCurrentElementParam<T extends keyof DMQueueElement>(
prop: T,
value: DMQueueElement[T]
) {
if (currentElement) {
currentElement[prop] = value
}
}

export {
initQueue,
addToQueue,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/storeManagers/hyperplay/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ async function getManifest(
}
}
)
return ''
throw new Error(`Error in getManifest for ${appName}: ${error}`)
}
}

Expand Down

0 comments on commit 9db2ab1

Please sign in to comment.