diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Users/UserService.cs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs index 58b14cec..3c3b6508 100644 --- a/src/slskd/Users/UserService.cs +++ b/src/slskd/Users/UserService.cs @@ -56,7 +56,7 @@ namespace slskd.Users ContextFactory = contextFactory; OptionsMonitor = optionsMonitor; - OptionsMonitor.OnChange(Configure); + OptionsMonitor.OnChange(options => Configure(options)); BindClientEvents(); Configure(OptionsMonitor.CurrentValue); @@ -252,29 +252,23 @@ namespace slskd.Users _ = GetStatisticsAsync(userStatus.Username); }; - Client.LoggedIn += (_, _) => WatchAllUsers(); + Client.LoggedIn += (_, _) => Configure(OptionsMonitor.CurrentValue, force: true); Client.Disconnected += (_, _) => { // when the client is disconnected, the watched user list resets server-side, - // so clear the watched dictionary to reflect this + // so clear the state to reflect this WatchedUsernamesDictionary.Clear(); + UserDictionary.Clear(); - // over the course of operation the application will watch users which are not explicitly - // configured as they enqueue uploads. these are considered transiently-tracked users, - // and we want to discard them upon disconnect to avoid re-watching them when the client - // is reconnected. to do this, purge the user dictionary of any entry lacking an explicit group. - foreach (var user in UserDictionary.Values.Where(user => user.Group == null)) - { - UserDictionary.TryRemove(user.Username, out _); - } + StateMutator.SetValue(state => state with { Users = Users.ToArray() }); }; } - private void Configure(Options options) + private void Configure(Options options, bool force = false) { var optionsHash = Compute.Sha1Hash(options.Groups.UserDefined.ToJson()); - if (optionsHash == LastOptionsHash) + if (optionsHash == LastOptionsHash && !force) { return; } |
