From 5132155714d3953a4a4fb0eba7fe2febe7e5e564 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Thu, 4 May 2023 00:40:55 +0200 Subject: Fix bugs in policy editor and state viewer --- MatrixRoomUtils.Web/Pages/PolicyListEditorPage.razor | 7 ++++++- MatrixRoomUtils.Web/Pages/PolicyListRoomList.razor | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'MatrixRoomUtils.Web/Pages') diff --git a/MatrixRoomUtils.Web/Pages/PolicyListEditorPage.razor b/MatrixRoomUtils.Web/Pages/PolicyListEditorPage.razor index ec452f3..66a5c9f 100644 --- a/MatrixRoomUtils.Web/Pages/PolicyListEditorPage.razor +++ b/MatrixRoomUtils.Web/Pages/PolicyListEditorPage.razor @@ -215,7 +215,12 @@ else // Console.WriteLine(JsonSerializer.Deserialize(content).ToJson()); // var stateEvents = JsonSerializer.Deserialize>(content); var room = await RuntimeCache.CurrentHomeServer.GetRoom(RoomId); - var stateEvents = (await room.GetStateAsync(""))!.Value.Deserialize>(); + var stateEventsQuery = await room.GetStateAsync(""); + if (stateEventsQuery == null) + { + Console.WriteLine("state events query is null!!!"); + } + var stateEvents = stateEventsQuery.Value.Deserialize>(); PolicyEvents = stateEvents.Where(x => x.type.StartsWith("m.policy.rule")) .Select(x => JsonSerializer.Deserialize>(JsonSerializer.Serialize(x))).ToList(); StateHasChanged(); diff --git a/MatrixRoomUtils.Web/Pages/PolicyListRoomList.razor b/MatrixRoomUtils.Web/Pages/PolicyListRoomList.razor index 924b68f..3af60b7 100644 --- a/MatrixRoomUtils.Web/Pages/PolicyListRoomList.razor +++ b/MatrixRoomUtils.Web/Pages/PolicyListRoomList.razor @@ -125,7 +125,9 @@ else // --- // var r = await RuntimeCache.CurrentHomeServer.GetRoom(room); - roomInfo.Shortcode = (await r.GetStateAsync("org.matrix.mjolnir.shortcode")).Value.GetProperty("shortcode").GetString(); + var shortcodeState = await r.GetStateAsync("org.matrix.mjolnir.shortcode"); + if(!shortcodeState.HasValue) return null; + roomInfo.Shortcode = shortcodeState.Value.TryGetProperty("shortcode", out JsonElement shortcode) ? shortcode.GetString() : null; if (roomInfo.Shortcode != null) { -- cgit 1.5.1