Remove 'dm-composer' OOB template and replace it with a simple 'hx-on:htmx:after-request' attribute
This commit is contained in:
parent
73c89f70fb
commit
2a7a4e700e
@ -51,7 +51,6 @@ func (app *Application) message_detail(w http.ResponseWriter, r *http.Request) {
|
|||||||
// First send a message, if applicable
|
// First send a message, if applicable
|
||||||
if is_sending {
|
if is_sending {
|
||||||
app.message_send(w, r)
|
app.message_send(w, r)
|
||||||
app.buffered_render_htmx(w, "dm-composer", global_data, chat_view_data) // Wipe the chat box
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `LatestPollingTimestamp` sort of passes-through the function; if we're not updating it, it
|
// `LatestPollingTimestamp` sort of passes-through the function; if we're not updating it, it
|
||||||
|
@ -147,8 +147,9 @@
|
|||||||
hx-target="#new-messages-poller"
|
hx-target="#new-messages-poller"
|
||||||
hx-swap="outerHTML scroll:.chat-messages:bottom"
|
hx-swap="outerHTML scroll:.chat-messages:bottom"
|
||||||
hx-ext="json-enc"
|
hx-ext="json-enc"
|
||||||
|
hx-on:htmx:after-request="composer.innerText = ''; realInput.value = ''; "
|
||||||
>
|
>
|
||||||
{{template "dm-composer"}}
|
<span id="composer" role="textbox" contenteditable oninput="realInput.value = this.innerText"></span>
|
||||||
<input id="realInput" type="hidden" name="text" value="" />
|
<input id="realInput" type="hidden" name="text" value="" />
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
</form>
|
</form>
|
||||||
@ -246,23 +247,6 @@
|
|||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "dm-composer"}}
|
|
||||||
<span id="composer" role="textbox" contenteditable oninput="realInput.value = this.innerText"
|
|
||||||
{{if .}}
|
|
||||||
{{/*
|
|
||||||
This is a separate template so it can be OOB-swapped to clear the contents of the composer
|
|
||||||
box after a successful DM send. However, the chat-view itself also loads via HTMX call.
|
|
||||||
|
|
||||||
To prevent the composer from being OOB'd on the initial page load (and thus never rendering),
|
|
||||||
we guard the "hx-swap-oob" attr; so if this template is called with nothing as the arg, then
|
|
||||||
it will be inlined normally (i.e., not OOB'd), and if the arg is something (e.g., a DMTrove),
|
|
||||||
then it will be OOB'd, thus clearing the contents of the composer box.
|
|
||||||
*/}}
|
|
||||||
hx-swap-oob="true"
|
|
||||||
{{end}}
|
|
||||||
></span>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{define "conversation-top"}}
|
{{define "conversation-top"}}
|
||||||
<div class="show-more conversation-top">
|
<div class="show-more conversation-top">
|
||||||
{{if .Cursor.CursorPosition.IsEnd}}
|
{{if .Cursor.CursorPosition.IsEnd}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user