Enable manual re-scraping of chat rooms

This commit is contained in:
Alessio 2024-05-12 17:37:08 -07:00
parent 827c15431c
commit 61404cf5b0
2 changed files with 16 additions and 0 deletions

View File

@ -82,6 +82,13 @@ func (app *Application) message_detail(w http.ResponseWriter, r *http.Request) {
app.message_send(w, r) app.message_send(w, r)
} }
if r.URL.Query().Has("scrape") && !app.IsScrapingDisabled {
max_id := scraper.DMMessageID(^uint(0) >> 1)
trove := scraper.GetConversation(room_id, max_id, 50) // TODO: parameterizable
app.Profile.SaveDMTrove(trove, false)
go app.Profile.SaveDMTrove(trove, true) // Download the content in the background
}
// `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
// goes out the same it came in. Hence, using a single variable for it // goes out the same it came in. Hence, using a single variable for it
chat_view_data.LatestPollingTimestamp = 0 chat_view_data.LatestPollingTimestamp = 0
@ -123,6 +130,12 @@ func (app *Application) message_detail(w http.ResponseWriter, r *http.Request) {
app.buffered_render_htmx(w, "messages-top", global_data, chat_view_data) app.buffered_render_htmx(w, "messages-top", global_data, chat_view_data)
return return
} }
// Reload the whole chat view pane
if r.URL.Query().Has("scrape") {
app.buffered_render_htmx(w, "chat-view", global_data, chat_view_data)
return
}
} }
app.buffered_render_page(w, "tpl/messages.tpl", global_data, chat_view_data) app.buffered_render_page(w, "tpl/messages.tpl", global_data, chat_view_data)

View File

@ -134,6 +134,9 @@
<a class="button" hx-post="/messages/{{ $room.ID }}/mark-as-read" title="Mark as read"> <a class="button" hx-post="/messages/{{ $room.ID }}/mark-as-read" title="Mark as read">
<img class="svg-icon" src="/static/icons/eye.svg" width="24" height="24" /> <img class="svg-icon" src="/static/icons/eye.svg" width="24" height="24" />
</a> </a>
<a class="button" hx-post="/messages/{{ $room.ID }}?scrape" hx-target="#chat-view" hx-swap="outerHTML" title="Refresh">
<img class="svg-icon" src="/static/icons/refresh.svg" width="24" height="24" />
</a>
</div> </div>
</div> </div>
{{end}} {{end}}