diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-02-23 09:28:32 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-02-23 09:28:32 -0600 |
| commit | a6508a390021f82ffd3c81f8001c914889f23f28 (patch) | |
| tree | 0931a5ba3a8d6ab1c00a3c01b88c9254f67540d8 /src/slskd/Users/UserService.cs | |
| parent | ec21875fb748bc91b4df85ea62c4813815e25b4a (diff) | |
| download | slskd-a6508a390021f82ffd3c81f8001c914889f23f28.tar.gz | |
use extensions over static factory methods
Diffstat (limited to 'src/slskd/Users/UserService.cs')
| -rw-r--r-- | src/slskd/Users/UserService.cs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs index 4e252f40..58b14cec 100644 --- a/src/slskd/Users/UserService.cs +++ b/src/slskd/Users/UserService.cs @@ -155,7 +155,7 @@ namespace slskd.Users public async Task<Statistics> GetStatisticsAsync(string username) { var soulseekStatistics = await Client.GetUserStatisticsAsync(username); - return Statistics.FromSoulseekUserStatistics(soulseekStatistics); + return soulseekStatistics.AsStatistics(); } /// <summary> @@ -166,7 +166,7 @@ namespace slskd.Users public async Task<Status> GetStatusAsync(string username) { var soulseekStatus = await Client.GetUserStatusAsync(username); - return Status.FromSoulseekUserStatus(soulseekStatus); + return soulseekStatus.AsStatus(); } /// <summary> @@ -223,33 +223,33 @@ namespace slskd.Users // it isn't completely clear what all causes the server to send this message. we know it is sent following an explicit // request, but it may be sent in an unsolicited manner as well. to be safe, we update internal stats for this user // only on this event, which should cover all bases (both solicited and unsolicited). - Client.UserStatisticsChanged += (_, e) => + Client.UserStatisticsChanged += (_, userStatistics) => { - var statistics = Statistics.FromSoulseekUserStatistics(e); + var statistics = userStatistics.AsStatistics(); UserDictionary.AddOrUpdate( - key: e.Username, + key: userStatistics.Username, addValue: new User() { Statistics = statistics }, - updateValueFactory: (key, user) => user with { Username = e.Username, Statistics = statistics }); + updateValueFactory: (key, user) => user with { Username = userStatistics.Username, Statistics = statistics }); StateMutator.SetValue(state => state with { Users = Users.ToArray() }); }; // the server sends this message in both solicited (we request status), and unsolicited (the user's status changes and // the server informs us without asking). we handle updates in this event handler to cover both cases. - Client.UserStatusChanged += (_, e) => + Client.UserStatusChanged += (_, userStatus) => { - var status = Status.FromSoulseekUserStatus(e); + var status = userStatus.AsStatus(); UserDictionary.AddOrUpdate( - key: e.Username, + key: userStatus.Username, addValue: new User() { Status = status }, - updateValueFactory: (key, user) => user with { Username = e.Username, Status = status }); + updateValueFactory: (key, user) => user with { Username = userStatus.Username, Status = status }); StateMutator.SetValue(state => state with { Users = Users.ToArray() }); // the server doesn't send statistics events by itself, so when a user status changes, fetch stats at the same time. - _ = GetStatisticsAsync(e.Username); + _ = GetStatisticsAsync(userStatus.Username); }; Client.LoggedIn += (_, _) => WatchAllUsers(); |
