fix: chat history clearning existing chat on load
authorxangelo <me@xangelo.ca>
Mon, 21 Aug 2023 17:27:14 +0000 (13:27 -0400)
committerxangelo <me@xangelo.ca>
Mon, 21 Aug 2023 17:27:14 +0000 (13:27 -0400)
Since we delay chat history loading for 1s, when it does load there is
the possibility that the history messages wipe out any existing
messages. This ensures that they get prepended to the chat and appear
before any new messages.

public/index.html

index 746e2c36d2326f54fbecc2f850948bd87b5498e8..777ee8db40e68a56b66d1b2345cad42268ee8134 100644 (file)
@@ -66,7 +66,7 @@
       </div>
 
       <section id="chat">
-        <div id="chat-messages" hx-trigger="load delay:1s" hx-get="/chat/history" hx-swap="innerHTML"></div>
+        <div id="chat-messages" hx-trigger="load delay:1s" hx-get="/chat/history" hx-swap="afterbegin"></div>
         <form id="chat-form" hx-post="/chat">
           <input type="text" id="message" name="message" autocomplete="off"><button type="submit">Send</button>
         </form>