about summary refs log tree commit diff
path: root/MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-24 02:31:56 +0100
committerRory& <root@rory.gay>2024-01-24 17:05:25 +0100
commit03313562d21d5db9bf6a14ebbeab80e06c883d3a (patch)
treee000546a2ee8e6a886a7ed9fd01ad674178fb7cb /MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
parentMake RMU installable (diff)
downloadMatrixUtils-03313562d21d5db9bf6a14ebbeab80e06c883d3a.tar.xz
MRU->RMU, fixes, cleanup
Diffstat (limited to 'MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor')
-rw-r--r--MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor53
1 files changed, 53 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor b/MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
new file mode 100644
index 0000000..3b18b95
--- /dev/null
+++ b/MatrixUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
@@ -0,0 +1,53 @@
+@using ArcaneLibs.Extensions
+@using LibMatrix.EventTypes.Spec.State
+@using LibMatrix.Responses
+@inherits BaseTimelineItem
+
+@if (roomMemberData is not null) {
+    @switch (roomMemberData.Membership) {
+        case "ban":
+            <i>@Event.StateKey was banned</i>
+            break;
+        case "invite":
+            <i>@Event.StateKey was invited</i>
+            break;
+        case "join" when Event.ReplacesState is not null:
+            <i>@Event.StateKey changed their display name to @(roomMemberData.DisplayName ?? Event.Sender)</i>
+            break;
+        case "join":
+            @if (prevRoomMemberData is null) {
+                <i><InlineUserItem User="@(new UserProfileResponse() { DisplayName = roomMemberData.DisplayName, AvatarUrl = roomMemberData.AvatarUrl })" Homeserver="@Homeserver" UserId="@Event.StateKey"></InlineUserItem> joined</i>
+            }
+            else {
+                <i><InlineUserItem User="@(new UserProfileResponse() { DisplayName = prevRoomMemberData.DisplayName, AvatarUrl = prevRoomMemberData.AvatarUrl })" Homeserver="@Homeserver" UserId="@Event.StateKey"></InlineUserItem> changed their profile to <InlineUserItem User="@(new UserProfileResponse() { DisplayName = roomMemberData.DisplayName, AvatarUrl = roomMemberData.AvatarUrl })" Homeserver="@Homeserver" UserId="@Event.StateKey"></InlineUserItem></i>
+            }
+            break;
+        case "leave":
+            <i>@Event.StateKey left</i>
+            break;
+        case "knock":
+            <i>@Event.StateKey knocked</i>
+            break;
+        default:
+            <i>@Event.StateKey has an unknown state:</i>
+            <pre>
+                @Event.ToJson()
+            </pre>
+            break;
+    }
+}
+else {
+    <details>
+        <summary>Unknown membership event for @Event.StateKey</summary>
+        <pre>
+            @Event.ToJson()
+        </pre>
+    </details>
+}
+
+@code {
+
+    private RoomMemberEventContent? roomMemberData => Event.TypedContent as RoomMemberEventContent;
+    private RoomMemberEventContent? prevRoomMemberData => PreviousState?.TypedContent as RoomMemberEventContent;
+
+}