mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Restructure; use DaisyUI
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Comparators from 'comparators'
|
||||
import Comparators, { Comparator } from 'comparators'
|
||||
|
||||
import { emitIPCEvent } from '../../main'
|
||||
import { emitIpcEvent } from '../../main'
|
||||
import { ChartDownload } from './ChartDownload'
|
||||
|
||||
export class DownloadQueue {
|
||||
@@ -8,11 +8,11 @@ export class DownloadQueue {
|
||||
private downloadQueue: ChartDownload[] = []
|
||||
|
||||
isDownloadingLink(filesHash: string) {
|
||||
return this.downloadQueue.some(download => download.hash == filesHash)
|
||||
return this.downloadQueue.some(download => download.hash === filesHash)
|
||||
}
|
||||
|
||||
isEmpty() {
|
||||
return this.downloadQueue.length == 0
|
||||
return this.downloadQueue.length === 0
|
||||
}
|
||||
|
||||
push(chartDownload: ChartDownload) {
|
||||
@@ -25,27 +25,27 @@ export class DownloadQueue {
|
||||
}
|
||||
|
||||
get(versionID: number) {
|
||||
return this.downloadQueue.find(download => download.versionID == versionID)
|
||||
return this.downloadQueue.find(download => download.versionID === versionID)
|
||||
}
|
||||
|
||||
remove(versionID: number) {
|
||||
const index = this.downloadQueue.findIndex(download => download.versionID == versionID)
|
||||
if (index != -1) {
|
||||
const index = this.downloadQueue.findIndex(download => download.versionID === versionID)
|
||||
if (index !== -1) {
|
||||
this.downloadQueue[index].cancel()
|
||||
this.downloadQueue.splice(index, 1)
|
||||
emitIPCEvent('queue-updated', this.downloadQueue.map(download => download.versionID))
|
||||
emitIpcEvent('queueUpdated', this.downloadQueue.map(download => download.versionID))
|
||||
}
|
||||
}
|
||||
|
||||
private sort() {
|
||||
let comparator = Comparators.comparing('allFilesProgress', { reversed: true })
|
||||
let comparator: Comparator<unknown> | undefined = Comparators.comparing('allFilesProgress', { reversed: true })
|
||||
|
||||
const prioritizeArchives = true
|
||||
if (prioritizeArchives) {
|
||||
comparator = comparator.thenComparing('isArchive', { reversed: true })
|
||||
comparator = comparator.thenComparing?.('isArchive', { reversed: true }) || undefined
|
||||
}
|
||||
|
||||
this.downloadQueue.sort(comparator)
|
||||
emitIPCEvent('queue-updated', this.downloadQueue.map(download => download.versionID))
|
||||
emitIpcEvent('queueUpdated', this.downloadQueue.map(download => download.versionID))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user