Skip to content

Commit

Permalink
feat: add speed to notification progress
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Jun 23, 2024
1 parent cd9e926 commit 2e8c305
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Ui/NotificationProgressManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ private State UpdateNotif(IActiveNotification notif, DownloadTask task) {
}
}

var speed = string.Empty;
if (task.State == State.DownloadingFiles) {
var bps = task.BytesPerSecond;
speed = bps switch {
>= 1_073_741_824 => $" ({bps / 1_073_741_824:N2} GiB/s)",
>= 1_048_576 => $" ({bps / 1_048_576:N2} MiB/s)",
>= 1_024 => $" ({bps / 1_024:N2} KiB/s)",
_ => $" ({bps:N2} B/s)",
};
}

var title = sb.ToString();

notif.Title = string.IsNullOrWhiteSpace(title) ? null : title;
Expand All @@ -151,8 +162,8 @@ private State UpdateNotif(IActiveNotification notif, DownloadTask task) {
? $"{state.Name()}"
: $"{state.Name()} ({error.GetType().Name})"
: sMax == 0
? $"{state.Name()} ({sData:N0})"
: $"{state.Name()} ({sData:N0} / {sMax:N0})";
? $"{state.Name()} ({sData:N0}){speed}"
: $"{state.Name()} ({sData:N0} / {sMax:N0}){speed}";
notif.Progress = sMax == 0
? 0
: (float) sData / sMax;
Expand Down

0 comments on commit 2e8c305

Please sign in to comment.