Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Improve Download Toast #558

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8aa4a31
fix extracting state, <99% when DL finishes
BrettCleary Sep 27, 2023
5ba4bd8
merge: Fixed conflicts
red-game-dev Oct 24, 2023
ef947a2
fix: Lint, codecheck, prettier issues
red-game-dev Oct 24, 2023
b9fd67f
fix: prettier issues
red-game-dev Oct 24, 2023
a2fd8d6
fix: Add hyperplay-ui package for test to pass
red-game-dev Oct 24, 2023
35f37ba
fix: Updated yarn lock, as app wont start
red-game-dev Oct 24, 2023
0fb04bd
feat: Added extraction zip service
red-game-dev Oct 27, 2023
6b71a4d
feat: Added extraction zip service tests
red-game-dev Oct 27, 2023
19cca3d
feat: Removed previous function for extract and its tests
red-game-dev Oct 27, 2023
631780b
feat: Integrated the service on install
red-game-dev Oct 27, 2023
cfdc7d1
feat: Removed the download status to be always bounded to 100 for Gam…
red-game-dev Oct 27, 2023
75ae813
feat: Integrated the new changes for extraction data from BE
red-game-dev Oct 27, 2023
b0ec5c4
feat: Added new status for extraction
red-game-dev Oct 29, 2023
ece4aa9
feat: Added cancel extraction api from InstallationToast
red-game-dev Oct 29, 2023
10c36bf
feat: Passed status through DownloadToastManager
red-game-dev Oct 29, 2023
fcf2332
feat: Added ipc handlers for cancel extraction
red-game-dev Oct 29, 2023
7e7d201
feat: Added cancel extraction queue
red-game-dev Oct 29, 2023
14c96ba
feat: Added cancellation to the service
red-game-dev Oct 29, 2023
7edd562
feat: Integrated cancellation event, and fixed progress bug that init…
red-game-dev Oct 29, 2023
9d7952a
chore: Updated tests after renaming cancel in service
red-game-dev Oct 29, 2023
a882d76
fix: Fixed prettier & lint
red-game-dev Oct 29, 2023
38154f0
fix: Updated tests with the reflected changes (Does not include cance…
red-game-dev Oct 29, 2023
d2a1382
fix: Fixed failing unit tests on utils
red-game-dev Oct 30, 2023
f091886
feat: Removed logging
red-game-dev Oct 30, 2023
0b872dd
chore: Updated from end to finished event and couple of other changes
red-game-dev Oct 30, 2023
694787e
feat: Updated game page extraction details
red-game-dev Oct 30, 2023
966a860
feat: Added disk size estimation for compressed file on install dialog
red-game-dev Oct 31, 2023
7baec4c
feat: Removed pause button for extracting (Requires hyperplay-ui lib …
red-game-dev Oct 31, 2023
cddb194
feat: Added uncompressed size of the file zip passed
red-game-dev Oct 31, 2023
5e695b6
feat: Added tests for pause, resume,
red-game-dev Oct 31, 2023
b5655a7
fix: Fixed lint and lint issues
red-game-dev Oct 31, 2023
d33e2e2
Merge branch 'main' into ux/improve_download_toast
red-game-dev Oct 31, 2023
10aaa4b
fix: Checking if build was fixed as supposed to be
red-game-dev Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
408 changes: 408 additions & 0 deletions src/backend/__tests__/services/ExtractZipService.test.ts

Large diffs are not rendered by default.

67 changes: 1 addition & 66 deletions src/backend/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import axios from 'axios'
import { app } from 'electron'
import { extractZip } from '../../backend/utils'
import { logError } from '../logger/logger'
import * as utils from '../utils'
import { test_data } from './test_data/github-api-heroic-test-data.json'
import path from 'path'
import {
copyFileSync,
existsSync,
readFileSync,
rmSync,
rmdirSync,
renameSync
} from 'graceful-fs'
import { logError } from '../logger/logger'

jest.mock('electron')
jest.mock('../logger/logger')
Expand Down Expand Up @@ -257,59 +247,4 @@ describe('backend/utils.ts', () => {
expect(utils.bytesToSize(2059 * 1024 * 3045 * 4000)).toEqual('23.36 TB')
})
})

describe('extractZip', () => {
let testCopyZipPath: string
let destFilePath: string

beforeEach(() => {
const testZipPath = path.resolve('./src/backend/__mocks__/test.zip')
//copy zip because extract will delete it
testCopyZipPath = path.resolve('./src/backend/__mocks__/test2.zip')
copyFileSync(testZipPath, testCopyZipPath)
destFilePath = path.resolve('./src/backend/__mocks__/test')
})

afterEach(async () => {
const extractPromise = utils.extractZip(testCopyZipPath, destFilePath)
await extractPromise
expect(extractPromise).resolves

const testTxtFilePath = path.resolve(destFilePath, './test.txt')
console.log('checking dest file path ', testTxtFilePath)
expect(existsSync(testTxtFilePath)).toBe(true)

const testMessage = readFileSync(testTxtFilePath).toString()
console.log('unzipped file contents: ', testMessage)
expect(testMessage).toEqual('this is a test message')

//extract deletes the zip file used to extract async so we wait and then check
await utils.wait(100)
expect(existsSync(testCopyZipPath)).toBe(false)

//clean up test
rmSync(testTxtFilePath)
rmdirSync(destFilePath)
expect(existsSync(testTxtFilePath)).toBe(false)
expect(existsSync(destFilePath)).toBe(false)
})

test('extract a normal test zip', async () => {
console.log('extracting test.zip')
})

test('extract a test zip with non ascii characters', async () => {
const renamedZipFilePath = path.resolve(
'./src/backend/__mocks__/谷���新道ひばりヶ�.zip'
)
renameSync(testCopyZipPath, renamedZipFilePath)
testCopyZipPath = renamedZipFilePath
})

it('should throw an error if the zip file does not exist', async () => {
await expect(
extractZip('nonexistent.zip', destFilePath)
).rejects.toThrow()
})
})
})
3 changes: 3 additions & 0 deletions src/backend/api/downloadmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const handleDMQueueInformation = (
export const cancelDownload = (removeDownloaded: boolean) =>
ipcRenderer.send('cancelDownload', removeDownloaded)

export const cancelExtraction = (appName: string) =>
ipcRenderer.send('cancelExtraction', appName)

export const resumeCurrentDownload = () =>
ipcRenderer.send('resumeCurrentDownload')

Expand Down
20 changes: 18 additions & 2 deletions src/backend/downloadmanager/downloadqueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ function getQueueInformation() {
return { elements, finished, state: queueState }
}

function cancelQueueExtraction() {
if (currentElement) {
if (Array.isArray(currentElement.params.installDlcs)) {
const dlcsToRemove = currentElement.params.installDlcs
for (const dlc of dlcsToRemove) {
removeFromQueue(dlc)
}
}
if (isRunning()) {
stopCurrentDownload()
}
removeFromQueue(currentElement.params.appName)

currentElement = null
}
}

function cancelCurrentDownload({ removeDownloaded = false }) {
if (currentElement) {
if (Array.isArray(currentElement.params.installDlcs)) {
Expand Down Expand Up @@ -255,8 +272,6 @@ function processNotification(element: DMQueueElement, status: DMStatus) {
element.params.appName
)

console.log('processNotification', status)

if (status === 'abort') {
if (isPaused()) {
logWarning(
Expand Down Expand Up @@ -320,6 +335,7 @@ export {
removeFromQueue,
getQueueInformation,
cancelCurrentDownload,
cancelQueueExtraction,
pauseCurrentDownload,
resumeCurrentDownload,
getFirstQueueElement
Expand Down
5 changes: 5 additions & 0 deletions src/backend/downloadmanager/ipc_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
removeFromQueue,
resumeCurrentDownload
} from './downloadqueue'
import { cancelExtraction } from 'backend/storeManagers/hyperplay/games'

ipcMain.handle('addToDMQueue', async (e, element) => {
await addToQueue(element)
Expand All @@ -26,4 +27,8 @@ ipcMain.on('cancelDownload', (e, removeDownloaded) => {
cancelCurrentDownload({ removeDownloaded })
})

ipcMain.on('cancelExtraction', (e, appName: string) => {
cancelExtraction(appName)
})

ipcMain.handle('getDMQueueInformation', getQueueInformation)
Loading
Loading