Attempt to fix occasional cursor error

This commit is contained in:
Zed 2021-12-28 08:07:15 +01:00
parent aa2fed19d7
commit c09a8d87d9
3 changed files with 9 additions and 5 deletions

View file

@ -14,10 +14,15 @@ proc genParams*(pars: openarray[(string, string)] = @[]; cursor="";
result &= p result &= p
if ext: if ext:
result &= ("ext", "mediaStats") result &= ("ext", "mediaStats")
if cursor.len > 0:
result &= ("cursor", cursor)
if count.len > 0: if count.len > 0:
result &= ("count", count) result &= ("count", count)
if cursor.len > 0:
# The raw cursor often has plus signs, which sometimes get turned into spaces,
# so we need to them back into a plus
if " " in cursor:
result &= ("cursor", cursor.replace(" ", "+"))
else:
result &= ("cursor", cursor)
proc genHeaders*(token: Token = nil): HttpHeaders = proc genHeaders*(token: Token = nil): HttpHeaders =
result = newHttpHeaders({ result = newHttpHeaders({

View file

@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
import uri
import karax/[karaxdsl, vdom] import karax/[karaxdsl, vdom]
import ".."/[types, formatters] import ".."/[types, formatters]
@ -38,7 +37,7 @@ proc renderReplies*(replies: Result[Chain]; prefs: Prefs; path: string): VNode =
renderReplyThread(thread, prefs, path) renderReplyThread(thread, prefs, path)
if replies.bottom.len > 0: if replies.bottom.len > 0:
renderMore(Query(), encodeUrl(replies.bottom), focus="#r") renderMore(Query(), replies.bottom, focus="#r")
proc renderConversation*(conv: Conversation; prefs: Prefs; path: string): VNode = proc renderConversation*(conv: Conversation; prefs: Prefs; path: string): VNode =
let hasAfter = conv.after.content.len > 0 let hasAfter = conv.after.content.len > 0

View file

@ -26,7 +26,7 @@ proc renderNewer*(query: Query; path: string; focus=""): VNode =
proc renderMore*(query: Query; cursor: string; focus=""): VNode = proc renderMore*(query: Query; cursor: string; focus=""): VNode =
buildHtml(tdiv(class="show-more")): buildHtml(tdiv(class="show-more")):
a(href=(&"?{getQuery(query)}cursor={encodeUrl(cursor)}{focus}")): a(href=(&"?{getQuery(query)}cursor={encodeUrl(cursor, usePlus=false)}{focus}")):
text "Load more" text "Load more"
proc renderNoMore(): VNode = proc renderNoMore(): VNode =