From c09a8d87d9bf22117e17b107dfbb8cb2030f84ec Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 28 Dec 2021 08:07:15 +0100 Subject: [PATCH] Attempt to fix occasional cursor error --- src/apiutils.nim | 9 +++++++-- src/views/status.nim | 3 +-- src/views/timeline.nim | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/apiutils.nim b/src/apiutils.nim index d253c21..2ea4424 100644 --- a/src/apiutils.nim +++ b/src/apiutils.nim @@ -14,10 +14,15 @@ proc genParams*(pars: openarray[(string, string)] = @[]; cursor=""; result &= p if ext: result &= ("ext", "mediaStats") - if cursor.len > 0: - result &= ("cursor", cursor) if count.len > 0: 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 = result = newHttpHeaders({ diff --git a/src/views/status.nim b/src/views/status.nim index cc3aee4..ab2690a 100644 --- a/src/views/status.nim +++ b/src/views/status.nim @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-only -import uri import karax/[karaxdsl, vdom] import ".."/[types, formatters] @@ -38,7 +37,7 @@ proc renderReplies*(replies: Result[Chain]; prefs: Prefs; path: string): VNode = renderReplyThread(thread, prefs, path) 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 = let hasAfter = conv.after.content.len > 0 diff --git a/src/views/timeline.nim b/src/views/timeline.nim index 5b5e0dc..4a2f29c 100644 --- a/src/views/timeline.nim +++ b/src/views/timeline.nim @@ -26,7 +26,7 @@ proc renderNewer*(query: Query; path: string; focus=""): VNode = proc renderMore*(query: Query; cursor: string; focus=""): VNode = 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" proc renderNoMore(): VNode =