about summary refs log tree commit diff
path: root/ModerationClient/ViewModels/ClientViewModel.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-03-12 04:44:19 +0100
committerRory& <root@rory.gay>2025-03-12 04:44:19 +0100
commit1a224441228d07440f279ce4a15c9a043b8cda6d (patch)
tree3ea4f4e2b694bf4a64079b084ea41d3c363937bb /ModerationClient/ViewModels/ClientViewModel.cs
parentVarious work (diff)
downloadModerationClient-1a224441228d07440f279ce4a15c9a043b8cda6d.tar.xz
Part of event rendering
Diffstat (limited to 'ModerationClient/ViewModels/ClientViewModel.cs')
-rw-r--r--ModerationClient/ViewModels/ClientViewModel.cs20
1 files changed, 16 insertions, 4 deletions
diff --git a/ModerationClient/ViewModels/ClientViewModel.cs b/ModerationClient/ViewModels/ClientViewModel.cs

index ab4f2da..9403123 100644 --- a/ModerationClient/ViewModels/ClientViewModel.cs +++ b/ModerationClient/ViewModels/ClientViewModel.cs
@@ -175,7 +175,14 @@ public partial class ClientViewModel : ViewModelBase { if (string.IsNullOrWhiteSpace(AllRooms[room.Key].Name)) { AllRooms[room.Key].Name = "Loading..."; - tasks.Add(_authService.Homeserver!.GetRoom(room.Key).GetNameOrFallbackAsync().ContinueWith(r => AllRooms[room.Key].Name = r.Result)); + tasks.Add(_authService.Homeserver!.GetRoom(room.Key).GetNameOrFallbackAsync().ContinueWith(r => { + if (r.IsFaulted) { + _logger.LogError(r.Exception, "Error getting room name for {RoomKey}", room.Key); + return AllRooms[room.Key].Name = "Error loading room name"; + } + + return AllRooms[room.Key].Name = r.Result; + })); // Status = $"Getting room name for {room.Key}..."; // AllRooms[room.Key].Name = await _authService.Homeserver!.GetRoom(room.Key).GetNameOrFallbackAsync(); } @@ -196,7 +203,8 @@ public partial class ClientViewModel : ViewModelBase { await AwaitTasks(tasks, "Waiting for {0}/{1} tasks while applying room changes..."); } - private ExpiringSemaphoreCache<UserProfileResponse> _profileCache = new(); + private ExpiringSemaphoreCache<UserProfileResponse> _profileCache = new(); + private async Task ApplyDirectMessagesChanges(StateEventResponse evt) { _logger.LogCritical("Direct messages updated!"); var dms = evt.RawContent.Deserialize<Dictionary<string, string[]?>>(); @@ -207,9 +215,13 @@ public partial class ClientViewModel : ViewModelBase { if (space is null) { space = new SpaceNode { Name = userId, RoomID = userId }; // tasks.Add(_authService.Homeserver!.GetProfileAsync(userId) - // .ContinueWith(r => space.Name = string.IsNullOrWhiteSpace(r.Result.DisplayName) ? userId : r.Result.DisplayName)); + // .ContinueWith(r => space.Name = string.IsNullOrWhiteSpace(r.Result.DisplayName) ? userId : r.Result.DisplayName)); tasks.Add(_profileCache.GetOrAdd(userId, async () => await _authService.Homeserver!.GetProfileAsync(userId), TimeSpan.FromMinutes(5)) - .ContinueWith(r => string.IsNullOrWhiteSpace(r.Result.DisplayName) ? userId : r.Result.DisplayName)); + .ContinueWith(r => { + if (!r.IsFaulted) + return string.IsNullOrWhiteSpace(r.Result.DisplayName) ? userId : r.Result.DisplayName; + return userId; + })); DirectMessages.ChildSpaces.Add(space); }