Improved downloads modal CSS

This commit is contained in:
Geomitron
2021-04-07 11:08:02 -05:00
parent 1c860bd0d9
commit 30e6e0fc19
7 changed files with 54 additions and 34 deletions

View File

@@ -19,7 +19,7 @@ type EventCallback = {
}
type Callbacks = { [E in keyof EventCallback]: EventCallback[E] }
export type DownloadError = { header: string; body: string }
export type DownloadError = { header: string; body: string; isLink?: boolean }
export class ChartDownload {
@@ -98,7 +98,7 @@ export class ChartDownload {
/**
* Updates the GUI with new information about this chart download.
*/
private updateGUI(header: string, description: string, type: ProgressType) {
private updateGUI(header: string, description: string, type: ProgressType, isLink = false) {
if (this.wasCanceled) { return }
if (type == 'fastUpdate') {
if (this.dropFastUpdate) {
@@ -115,7 +115,8 @@ export class ChartDownload {
header: header,
description: description,
percent: this.percent,
type: type
type: type,
isLink
})
}
@@ -125,7 +126,7 @@ export class ChartDownload {
private handleError(err: DownloadError, retry: () => void) {
this._hasFailed = true
this.retryFn = retry
this.updateGUI(err.header, err.body, 'error')
this.updateGUI(err.header, err.body, 'error', err.isLink == true)
this.callbacks.error()
}
@@ -270,7 +271,7 @@ export class ChartDownload {
transfer.on('start', (_destinationFolder) => {
destinationFolder = _destinationFolder
this.updateGUI('Moving files to library folder...', destinationFolder, 'good')
this.updateGUI('Moving files to library folder...', destinationFolder, 'good', true)
})
transfer.on('error', this.handleError.bind(this))
@@ -278,7 +279,7 @@ export class ChartDownload {
return new Promise<void>(resolve => {
transfer.on('complete', () => {
this.percent = 100
this.updateGUI('Download complete.', destinationFolder, 'done')
this.updateGUI('Download complete.', destinationFolder, 'done', true)
resolve()
})
})

View File

@@ -21,7 +21,7 @@ const filesystemErrors = {
libraryFolder: () => { return { header: 'Library folder not specified', body: 'Please go to the settings to set your library folder.' } },
libraryAccess: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to access library folder.'),
destinationFolderExists: (destinationPath: string) => {
return { header: 'This chart already exists in your library folder.', body: destinationPath }
return { header: 'This chart already exists in your library folder.', body: destinationPath, isLink: true }
},
mkdirError: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to create temporary folder.')
}

View File

@@ -29,6 +29,7 @@ export interface DownloadProgress {
description: string
percent: number
type: ProgressType
isLink: boolean
}
export type ProgressType = 'good' | 'error' | 'cancel' | 'done' | 'fastUpdate'