Skip to content

Commit

Permalink
[UI] Improve download speed chart (#3244)
Browse files Browse the repository at this point in the history
* update the amount of data points that avgdownloadspeed uses to represent the graph in downloads to be a higher number, changed the numbers to not jump around so much on the same row

* style change to be compliant
  • Loading branch information
RawToast225 authored Nov 22, 2023
1 parent fdaadf7 commit 630e523
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
.realtimeDownloadStat {
white-space: nowrap;
margin: 0px;
width: 6em;
text-align: start;
}

.realtimeDownloadStatLabel {
Expand All @@ -66,7 +68,6 @@
.realtimeDownloadStatContainer {
align-self: center;
margin: 1em;
box-sizing: border-box;
}

.downloadRateChart {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ export default function ProgressHeader(props: {
appName: string
state: DownloadManagerState
}) {
const sampleSize = 100
const { t } = useTranslation()
const [progress] = hasProgress(props.appName)
const [avgSpeed, setAvgDownloadSpeed] = useState<Point[]>(
Array<Point>(20).fill({ download: 0, disk: 0 })
Array<Point>(sampleSize).fill({ download: 0, disk: 0 })
)

useEffect(() => {
if (props.state === 'idle') {
setAvgDownloadSpeed(Array<Point>(20).fill({ download: 0, disk: 0 }))
setAvgDownloadSpeed(
Array<Point>(sampleSize).fill({ download: 0, disk: 0 })
)
return
}

if (avgSpeed.length > 19) {
if (avgSpeed.length > sampleSize - 1) {
avgSpeed.shift()
}

Expand Down

0 comments on commit 630e523

Please sign in to comment.