Reapply "fix: append chat messages instead of re-rendering entire game"
This reverts commit 513467470c.
This commit is contained in:
@@ -23,16 +23,21 @@ type Config struct {
|
||||
StopKeyPropagation bool
|
||||
}
|
||||
|
||||
// ChatMessage renders a single chat message. Used for appending new messages via SSE.
|
||||
templ ChatMessage(m chat.Message, cfg Config) {
|
||||
<div class={ cfg.CSSPrefix + "-chat-msg" }>
|
||||
<span style={ fmt.Sprintf("color:%s;font-weight:bold;", cfg.Color(m.Slot)) }>
|
||||
{ m.Nickname + ": " }
|
||||
</span>
|
||||
<span>{ m.Message }</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ Chat(messages []chat.Message, cfg Config) {
|
||||
<div id={ cfg.CSSPrefix + "-chat" } class={ cfg.CSSPrefix + "-chat" }>
|
||||
<div class={ cfg.CSSPrefix + "-chat-history" }>
|
||||
<div id={ cfg.CSSPrefix + "-chat-history" } class={ cfg.CSSPrefix + "-chat-history" }>
|
||||
for _, m := range messages {
|
||||
<div class={ cfg.CSSPrefix + "-chat-msg" }>
|
||||
<span style={ fmt.Sprintf("color:%s;font-weight:bold;", cfg.Color(m.Slot)) }>
|
||||
{ m.Nickname + ": " }
|
||||
</span>
|
||||
<span>{ m.Message }</span>
|
||||
</div>
|
||||
@ChatMessage(m, cfg)
|
||||
}
|
||||
</div>
|
||||
<div class={ cfg.CSSPrefix + "-chat-input" } data-morph-ignore>
|
||||
|
||||
Reference in New Issue
Block a user