Add download pausing, canceling and resuming
This commit is contained in:
6 files changed
+317
-91
No files matched your search
@@ -14,6 +14,7 @@ body {
|
||||
--col6: rgb(96, 96, 96);
|
||||
--col7: rgb(112, 112, 112);
|
||||
--col8: rgb(128, 128, 128);
|
||||
--col9: rgb(144, 144, 144);
|
||||
}
|
||||
|
||||
.red-theme {
|
||||
@@ -26,6 +27,7 @@ body {
|
||||
--col6: rgb(120, 96, 96);
|
||||
--col7: rgb(136, 112, 112);
|
||||
--col8: rgb(152, 128, 128);
|
||||
--col9: rgb(168, 144, 144);
|
||||
}
|
||||
|
||||
.blue-theme {
|
||||
@@ -38,6 +40,7 @@ body {
|
||||
--col6: rgb(96, 96, 120);
|
||||
--col7: rgb(112, 112, 136);
|
||||
--col8: rgb(128, 128, 152);
|
||||
--col9: rgb(144, 144, 168);
|
||||
}
|
||||
|
||||
.purple-theme {
|
||||
@@ -50,6 +53,7 @@ body {
|
||||
--col6: rgb(108, 96, 120);
|
||||
--col7: rgb(124, 112, 136);
|
||||
--col8: rgb(140, 128, 152);
|
||||
--col9: rgb(156, 144, 168);
|
||||
}
|
||||
|
||||
.button {
|
||||
|
||||
+74
-3
@@ -228,7 +228,7 @@ export default function RootLayout ({
|
||||
const i = prev.findIndex(d => d.version === displayName)
|
||||
if (i === -1) return prev
|
||||
const copy = [...prev]
|
||||
copy[i] = { ...copy[i], hash_checking: true }
|
||||
copy[i] = { ...copy[i], hash_checking: true, downloading: false }
|
||||
return copy
|
||||
})
|
||||
})
|
||||
@@ -266,6 +266,58 @@ export default function RootLayout ({
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
unlisteners.push(
|
||||
await listen<string>('download-start', event => {
|
||||
const displayName = event.payload
|
||||
setDownloadProgress(prev => {
|
||||
const i = prev.findIndex(d => d.version === displayName)
|
||||
if (i === -1) return prev
|
||||
const copy = [...prev]
|
||||
copy[i] = {
|
||||
...copy[i],
|
||||
downloading: true,
|
||||
paused: false,
|
||||
failed: false
|
||||
}
|
||||
return copy
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
unlisteners.push(
|
||||
await listen<string>('download-stop', event => {
|
||||
const displayName = event.payload
|
||||
setDownloadProgress(prev => {
|
||||
const i = prev.findIndex(d => d.version === displayName)
|
||||
if (i === -1) return prev
|
||||
const copy = [...prev]
|
||||
copy[i] = { ...copy[i], downloading: false }
|
||||
return copy
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
unlisteners.push(
|
||||
await listen<string>('download-cancelled', event => {
|
||||
const displayName = event.payload
|
||||
setDownloadProgress(prev => {
|
||||
const i = prev.findIndex(d => d.version === displayName)
|
||||
if (i === -1) return prev
|
||||
if (prev[i].canceled) {
|
||||
return prev.filter((_, idx) => idx !== i)
|
||||
}
|
||||
const copy = [...prev]
|
||||
copy[i] = {
|
||||
...copy[i],
|
||||
downloading: false,
|
||||
paused: true,
|
||||
failed: false
|
||||
}
|
||||
return copy
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
setupListeners()
|
||||
@@ -349,6 +401,9 @@ export default function RootLayout ({
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
0,
|
||||
@@ -356,7 +411,10 @@ export default function RootLayout ({
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
)
|
||||
|
||||
@@ -424,6 +482,19 @@ export default function RootLayout ({
|
||||
return
|
||||
}
|
||||
|
||||
setDownloadProgress(prev =>
|
||||
prev.map(d =>
|
||||
d.version === versionId
|
||||
? {
|
||||
...d,
|
||||
url: data.data.url,
|
||||
executable: info.executable,
|
||||
hash: data.data.hash
|
||||
}
|
||||
: d
|
||||
)
|
||||
)
|
||||
|
||||
const res = await invoke<string>('download', {
|
||||
url: data.data.url,
|
||||
name: info.id,
|
||||
@@ -447,7 +518,7 @@ export default function RootLayout ({
|
||||
writeVersionsConfig(updated)
|
||||
return updated
|
||||
})
|
||||
} else {
|
||||
} else if (res !== '0') {
|
||||
setDownloadProgress(prev =>
|
||||
prev.map(d =>
|
||||
d.version === versionId
|
||||
|
||||
Reference in new issue
Block a user