Enable manual re-scraping of chat rooms
This commit is contained in:
parent
827c15431c
commit
61404cf5b0
@ -82,6 +82,13 @@ func (app *Application) message_detail(w http.ResponseWriter, r *http.Request) {
|
||||
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
|
||||
// goes out the same it came in. Hence, using a single variable for it
|
||||
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)
|
||||
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)
|
||||
|
@ -134,6 +134,9 @@
|
||||
<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" />
|
||||
</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>
|
||||
{{end}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user