about summary refs log tree commit diff
path: root/MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor')
-rw-r--r--MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor34
1 files changed, 34 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor b/MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
new file mode 100644
index 0000000..81956b0
--- /dev/null
+++ b/MatrixUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
@@ -0,0 +1,34 @@
+@using ArcaneLibs.Extensions
+@using LibMatrix.EventTypes.Spec
+@inherits BaseTimelineItem
+
+<span>
+    @if (!HasPreviousMessage) {
+        <span><InlineUserItem User="@CurrentSenderProfile" Homeserver="@Homeserver" UserId="@Event.StateKey"></InlineUserItem>:</span><br/>
+    }
+    @switch (currentEventContent.MessageType) {
+        case "m.text": {
+            @foreach (var line in currentEventContent.Body.Split('\n')) {
+                <span>@line</span><br/>
+            }
+            break;
+        }
+        case "m.image": {
+            <i>@currentEventContent.Body</i><br/>
+            <img src="@Homeserver.ResolveMediaUri(currentEventContent.Url)">
+            break;
+        }
+        default: {
+            <pre>
+               @Event.RawContent?.ToJson(indent: false)
+            </pre>
+            break;
+        }
+    }
+</span>
+
+@code {
+    private RoomMessageEventContent? previousEventContent => PreviousState?.TypedContent as RoomMessageEventContent;
+
+    private RoomMessageEventContent? currentEventContent => Event.TypedContent as RoomMessageEventContent;
+}
\ No newline at end of file