Skip to content

Commit

Permalink
Improve event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Dec 10, 2024
1 parent 49128f0 commit 5fb4b6e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions BTCPayApp.UI/StateMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Text.Json;
using BTCPayApp.Core.Auth;
using BTCPayApp.Core.BTCPayServer;
using BTCPayApp.Core.Contracts;
Expand Down Expand Up @@ -215,10 +214,15 @@ private async Task ListenIn(IDispatcher dispatcher)
if (serverEvent.StoreId != null)
{
await accountManager.CheckAuthenticated(true);
if (serverEvent.Type is "store-removed" or "user-store-removed" && currentStore != null && serverEvent.StoreId == currentStore.Id)
{
if (currentStore == null || serverEvent.StoreId != currentStore.Id) return;
if (serverEvent.Type is "store-removed" or "user-store-removed")
await accountManager.UnsetCurrentStore();
}
if (serverEvent.Type is "store-updated")
dispatcher.Dispatch(new StoreState.FetchStore(serverEvent.StoreId!));
if (serverEvent.Type.StartsWith("user-store-"))
dispatcher.Dispatch(new StoreState.FetchUsers(serverEvent.StoreId!));
if (serverEvent.Type.StartsWith("store-role-"))
dispatcher.Dispatch(new StoreState.FetchRoles(serverEvent.StoreId!));
}
break;
}
Expand Down

0 comments on commit 5fb4b6e

Please sign in to comment.