about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
blob: 8239367d2a2427fce0d356e07a4d42a8422b3195 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@using LibMatrix.StateEventTypes
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.Extensions
@inherits BaseTimelineItem

@if (roomMemberData is not null) {
    @if (roomMemberData.Membership == "ban") {
        <i>@Event.StateKey was banned</i>
    }
    else if (roomMemberData.Membership == "invite") {
        <i>@Event.StateKey was invited</i>
    }
    else if (roomMemberData.Membership == "join") {
        @if (Event.ReplacesState is not null) {
            <i>@Event.StateKey changed their display name to @(roomMemberData.Displayname ?? Event.Sender)</i>
        }
        else {
            <i><InlineUserItem User="new ProfileResponseEventData()" HomeServer="HomeServer" UserId="@Event.StateKey"></InlineUserItem> joined</i>
        }
    }
    else if (roomMemberData.Membership == "leave") {
        <i>@Event.StateKey left</i>
    }
    else if (roomMemberData.Membership == "knock") {
        <i>@Event.StateKey knocked</i>
    }
    else {
        <i>@Event.StateKey has an unknown state:</i>
        <pre>
        @Event.ToJson()
    </pre>
    }
}
else {
    <details>
        <summary>Unknown membership event for @Event.StateKey</summary>
        <pre>
            @Event.ToJson()
        </pre>
    </details>
}

@code {

    private RoomMemberEventData? roomMemberData => Event.TypedContent as RoomMemberEventData;

}