Update reading time HTML element after fetching the original web page

This commit is contained in:
Davide Masserut 2022-12-14 13:32:45 +01:00 committed by Frédéric Guillot
parent ce35b46fee
commit c0ee3ed375
3 changed files with 7 additions and 3 deletions

View File

@ -130,7 +130,7 @@
{{ end }}
{{ if and .user.ShowReadingTime (gt .entry.ReadingTime 0) }}
·
<span>
<span class="entry-reading-time">
{{ plural "entry.estimated_reading_time" .entry.ReadingTime .entry.ReadingTime }}
</span>
{{ end }}

View File

@ -9,6 +9,7 @@ import (
"miniflux.app/http/request"
"miniflux.app/http/response/json"
"miniflux.app/locale"
"miniflux.app/model"
"miniflux.app/proxy"
"miniflux.app/reader/processor"
@ -64,5 +65,7 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
json.ServerError(w, r, err)
}
json.OK(w, r, map[string]string{"content": proxy.ImageProxyRewriter(h.router, entry.Content)})
readingTime := locale.NewPrinter(user.Language).Plural("entry.estimated_reading_time", entry.ReadingTime, entry.ReadingTime)
json.OK(w, r, map[string]string{"content": proxy.ImageProxyRewriter(h.router, entry.Content), "reading_time": readingTime})
}

View File

@ -334,8 +334,9 @@ function handleFetchOriginalContent() {
element.innerHTML = previousInnerHTML;
response.json().then((data) => {
if (data.hasOwnProperty("content")) {
if (data.hasOwnProperty("content") && data.hasOwnProperty("reading_time")) {
document.querySelector(".entry-content").innerHTML = data.content;
document.querySelector(".entry-reading-time").innerHTML = data.reading_time;
}
});
});