Просмотр исходного кода

Attempt to fix occasional cursor error

Zed 4 лет назад
Родитель
Сommit
c09a8d87d9
3 измененных файлов с 9 добавлено и 5 удалено
  1. 7 2
      src/apiutils.nim
  2. 1 2
      src/views/status.nim
  3. 1 1
      src/views/timeline.nim

+ 7 - 2
src/apiutils.nim

@@ -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({

+ 1 - 2
src/views/status.nim

@@ -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

+ 1 - 1
src/views/timeline.nim

@@ -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 =