@@ -21,15 +21,18 @@ public sealed partial class AggregatedDataWidgetViewModel : BaseWidgetViewModel
2121 private ulong _pendingBytesWritten ;
2222 private ByteSize _bytesRead ;
2323 private ByteSize _bytesWritten ;
24+ private int _updateTicks ;
2425
2526 [ ObservableProperty ] private string ? _TotalRead ;
2627 [ ObservableProperty ] private string ? _TotalWrite ;
28+ [ ObservableProperty ] private bool _IsReading ;
29+ [ ObservableProperty ] private bool _IsWriting ;
2730
2831 public AggregatedDataWidgetViewModel ( UnlockedVaultViewModel unlockedVaultViewModel , IWidgetModel widgetModel )
2932 : base ( widgetModel )
3033 {
3134 _fileSystemStatistics = unlockedVaultViewModel . StorageRoot . Options . FileSystemStatistics ;
32- _periodicTimer = new ( TimeSpan . FromMilliseconds ( Constants . Widgets . Graphs . GRAPH_UPDATE_INTERVAL_MS ) ) ;
35+ _periodicTimer = new ( TimeSpan . FromMilliseconds ( Constants . Widgets . AggregatedData . UPDATE_INTERVAL_MS ) ) ;
3336 Title = "AggregatedDataWidget" . ToLocalized ( ) ;
3437 }
3538
@@ -46,14 +49,20 @@ public override Task InitAsync(CancellationToken cancellationToken = default)
4649 {
4750 _bytesReadSubscription = subscriber . SubscribeToBytesRead ( new Progress < long > ( x =>
4851 {
49- if ( x > 0 )
50- _pendingBytesRead += ( ulong ) x ;
52+ if ( x <= 0L )
53+ return ;
54+
55+ IsReading = true ;
56+ _pendingBytesRead += ( ulong ) x ;
5157 } ) ) ;
5258
5359 _bytesWrittenSubscription = subscriber . SubscribeToBytesWritten ( new Progress < long > ( x =>
5460 {
55- if ( x > 0 )
56- _pendingBytesWritten += ( ulong ) x ;
61+ if ( x <= 0L )
62+ return ;
63+
64+ IsWriting = true ;
65+ _pendingBytesWritten += ( ulong ) x ;
5766 } ) ) ;
5867 }
5968
@@ -80,6 +89,14 @@ private async Task InitializeBlockingTimer(CancellationToken cancellationToken)
8089 TotalWrite = _bytesWritten . ToString ( ) . Replace ( " " , string . Empty ) ;
8190 _pendingBytesWritten = 0UL ;
8291 }
92+
93+ _updateTicks ++ ;
94+ if ( _updateTicks >= Constants . Widgets . AggregatedData . REFRESH_RATE )
95+ {
96+ _updateTicks = 0 ;
97+ IsReading = false ;
98+ IsWriting = false ;
99+ }
83100 }
84101 }
85102
0 commit comments