@@ -177,6 +177,7 @@ private void AuthenticationStateChanged(Task<AuthenticationState> task)
177177 //#if (signalR == true)
178178 private void SubscribeToSignalREventsMessages ( )
179179 {
180+ hubConnection . Remove ( SignalREvents . SHOW_MESSAGE ) ;
180181 signalROnDisposables . Add ( hubConnection . On < string , Dictionary < string , string ? > ? , bool > ( SignalREvents . SHOW_MESSAGE , async ( message , data ) =>
181182 {
182183 logger . LogInformation ( "SignalR Message {Message} received from server to show." , message ) ;
@@ -209,17 +210,20 @@ private void SubscribeToSignalREventsMessages()
209210 // You can also leverage IPubSubService to notify other components in the application.
210211 } ) ) ;
211212
213+ hubConnection . Remove ( SignalREvents . PUBLISH_MESSAGE ) ;
212214 signalROnDisposables . Add ( hubConnection . On < string , object ? > ( SignalREvents . PUBLISH_MESSAGE , async ( message , payload ) =>
213215 {
214216 logger . LogInformation ( "SignalR Message {Message} received from server to publish." , message ) ;
215217 PubSubService . Publish ( message , payload ) ;
216218 } ) ) ;
217219
220+ hubConnection . Remove ( SignalREvents . EXCEPTION_THROWN ) ;
218221 signalROnDisposables . Add ( hubConnection . On < AppProblemDetails > ( SignalREvents . EXCEPTION_THROWN , async ( appProblemDetails ) =>
219222 {
220223 ExceptionHandler . Handle ( appProblemDetails , displayKind : ExceptionDisplayKind . NonInterrupting ) ;
221224 } ) ) ;
222225
226+ hubConnection . Remove ( SignalRMethods . UPLOAD_DIAGNOSTIC_LOGGER_STORE ) ;
223227 signalROnDisposables . Add ( hubConnection . On ( SignalRMethods . UPLOAD_DIAGNOSTIC_LOGGER_STORE , async ( ) =>
224228 {
225229 return DiagnosticLogger . Store . ToArray ( ) ;
@@ -308,8 +312,6 @@ await storageService.GetItem("Culture") ?? // 2- User settings
308312 private List < IDisposable > signalROnDisposables = [ ] ;
309313 protected override async ValueTask DisposeAsync ( bool disposing )
310314 {
311- await base . DisposeAsync ( disposing ) ;
312-
313315 unsubscribe ? . Invoke ( ) ;
314316
315317 NavigationManager . LocationChanged -= NavigationManager_LocationChanged ;
@@ -320,6 +322,9 @@ protected override async ValueTask DisposeAsync(bool disposing)
320322 hubConnection . Reconnected -= HubConnectionConnected ;
321323 hubConnection . Reconnecting -= HubConnectionStateChange ;
322324 signalROnDisposables . ForEach ( d => d . Dispose ( ) ) ;
325+ signalROnDisposables = [ ] ;
323326 //#endif
327+
328+ await base . DisposeAsync ( disposing ) ;
324329 }
325330}
0 commit comments