- {timeline.map(entry =>
)}
+
+ {timeline.map(entry => entry ?
: null)}
diff --git a/web/src/ui/timeline/content/EncryptedBody.tsx b/web/src/ui/timeline/content/EncryptedBody.tsx
new file mode 100644
index 0000000..54d2e61
--- /dev/null
+++ b/web/src/ui/timeline/content/EncryptedBody.tsx
@@ -0,0 +1,25 @@
+// gomuks - A Matrix client written in Go.
+// Copyright (C) 2024 Tulir Asokan
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see
.
+import { EventContentProps } from "./props.ts"
+
+const EncryptedBody = ({ event }: EventContentProps) => {
+ if (event.decryption_error) {
+ return `Failed to decrypt: ${event.decryption_error}`
+ }
+ return `Waiting for message`
+}
+
+export default EncryptedBody
diff --git a/web/src/ui/timeline/content/MessageBody.tsx b/web/src/ui/timeline/content/MessageBody.tsx
index 474c17c..27ad6d3 100644
--- a/web/src/ui/timeline/content/MessageBody.tsx
+++ b/web/src/ui/timeline/content/MessageBody.tsx
@@ -104,7 +104,7 @@ const MessageBody = ({ event }: EventContentProps) => {
>
}
}
- return
{`{ "type": "${event.type}" }`}
+ return
{`{ "type": "${event.type}", "content": { "msgtype": "${content.msgtype}" } }`}
}
export default MessageBody
diff --git a/web/src/ui/timeline/content/RedactedBody.tsx b/web/src/ui/timeline/content/RedactedBody.tsx
new file mode 100644
index 0000000..ec95dbc
--- /dev/null
+++ b/web/src/ui/timeline/content/RedactedBody.tsx
@@ -0,0 +1,20 @@
+// gomuks - A Matrix client written in Go.
+// Copyright (C) 2024 Tulir Asokan
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see
.
+const RedactedBody = () => {
+ return `Message deleted`
+}
+
+export default RedactedBody
diff --git a/websocket.go b/websocket.go
index 752e748..f9d2a7c 100644
--- a/websocket.go
+++ b/websocket.go
@@ -252,17 +252,18 @@ func (gmx *Gomuks) sendInitialData(ctx context.Context, conn *websocket.Conn) {
if err != nil {
log.Err(err).Msg("Failed to get preview event for room")
return
- } else if previewEvent != nil {
- syncRoom.Events = append(syncRoom.Events, previewEvent)
}
- if previewEvent != nil && previewEvent.LastEditRowID != nil {
- lastEdit, err := gmx.Client.DB.Event.GetByRowID(ctx, *previewEvent.LastEditRowID)
- if err != nil {
- log.Err(err).Msg("Failed to get last edit for preview event")
- return
- } else if lastEdit != nil {
- syncRoom.Events = append(syncRoom.Events, lastEdit)
+ if previewEvent != nil {
+ if previewEvent.LastEditRowID != nil {
+ lastEdit, err := gmx.Client.DB.Event.GetByRowID(ctx, *previewEvent.LastEditRowID)
+ if err != nil {
+ log.Err(err).Msg("Failed to get last edit for preview event")
+ return
+ } else if lastEdit != nil {
+ syncRoom.Events = append(syncRoom.Events, lastEdit)
+ }
}
+ syncRoom.Events = append(syncRoom.Events, previewEvent)
}
}
}