Part of event rendering
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);
}
|