Skip to content

Commit

Permalink
fix remove account did not stop cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
moonheart committed Apr 2, 2024
1 parent 9cbf7a1 commit 0261fea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject IWritableOptions<AuthOption> authOption
@inject TimeZoneAwareJobRegister timeZoneAwareJobRegister;
@using MementoMori.Common.Localization
@using MementoMori.Jobs
@using MementoMori.Option
@using MementoMori.Ortega.Share
@inherits MementoMori.BlazorShared.Models.AccountComponent
Expand Down Expand Up @@ -177,7 +179,8 @@
{
return;
}
authOption.Update(opt => { opt.Accounts.RemoveAll(d => d.UserId == userId); });
AccountManager.RemoveAccount(userId);
await timeZoneAwareJobRegister.DeregisterJobs(userId);
AccountManager.CurrentUserId = 0;
_accounts = authOption.Value.Accounts.ToList();
StateHasChanged();
Expand Down
9 changes: 9 additions & 0 deletions MementoMori/AccountManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ public void UpdateAccountInfo(long userId)
{
Get(userId).AccountInfo = GetAccountInfo(userId);
}

public void RemoveAccount(long userId)
{
_accounts.TryRemove(userId, out _);
_authOption.Update(opt =>
{
opt.Accounts.RemoveAll(x => x.UserId == userId);
});
}
}

public class Account
Expand Down

0 comments on commit 0261fea

Please sign in to comment.