{{define "message"}} {{$user := (user .SenderID)}} {{$is_us := (eq .SenderID (active_user).ID)}}
{{template "circle-profile-img" $user}}
{{if (ne .InReplyToID 0)}}
{{ (user (dm_message .InReplyToID).SenderID).DisplayName }}
{{(dm_message .InReplyToID).Text}}
{{end}} {{if (ne .EmbeddedTweetID 0)}}
{{template "tweet" (dict "TweetID" .EmbeddedTweetID "RetweetID" 0 "QuoteNestingLevel" 1) }}
{{end}} {{range .Images}} {{end}} {{range .Videos}} {{end}} {{range .Urls}} {{template "embedded-link" .}} {{end}} {{if .Text}}
{{template "text-with-entities" .Text}}
{{end}}
{{range .Reactions}} {{$sender := (user .SenderID)}} {{.Emoji}} {{end}}

{{.SentAt.Time.Format "Jan 2, 2006 @ 3:04 pm"}}

{{end}} {{define "messages"}} {{range .MessageIDs}} {{template "message" (dm_message .)}} {{end}} {{end}} {{define "messages-with-poller"}} {{template "messages" .}}
{{end}} {{define "chat-view"}}
{{if .ActiveRoomID}}
{{ $room := (index $.Rooms $.ActiveRoomID) }} {{template "chat-profile-image" $room}}
{{if (ne $room.Type "ONE_TO_ONE")}} {{end}}
{{end}}
{{if .ActiveRoomID}} {{template "conversation-top" .}} {{template "messages-with-poller" .}} {{end}}
{{if .ActiveRoomID}}
{{/* TODO: replying-to CSS re-use is a mess */}}
Lorem ipsum dolor sit amet
{{ $room := (index $.Rooms $.ActiveRoomID) }} {{if (ne $room.Type "ONE_TO_ONE")}}

People

{{template "list" (dict "UserIDs" $room.GetParticipantIDs)}}
{{end}} {{end}}
{{end}} {{define "conversation-top"}}
{{if .Cursor.CursorPosition.IsEnd}} {{else}} Show more {{end}}
{{end}} {{/* convenience template for htmx requests */}} {{define "messages-top"}} {{template "conversation-top" .}} {{template "messages" .}} {{end}}