Skip search requests when query is empty
This commit is contained in:
parent
1e1e034237
commit
aa2fed19d7
15
src/api.nim
15
src/api.nim
|
@ -67,11 +67,16 @@ proc getSearch*[T](query: Query; after=""): Future[Result[T]] {.async.} =
|
||||||
searchMode = ("tweet_search_mode", "live")
|
searchMode = ("tweet_search_mode", "live")
|
||||||
parse = parseTimeline
|
parse = parseTimeline
|
||||||
|
|
||||||
let
|
let q = genQueryParam(query)
|
||||||
q = genQueryParam(query)
|
if q.len == 0 or q == emptyQuery:
|
||||||
url = search ? genParams(searchParams & @[("q", q), searchMode], after)
|
return Result[T](beginning: true, query: query)
|
||||||
result = parse(await fetch(url), after)
|
|
||||||
result.query = query
|
let url = search ? genParams(searchParams & @[("q", q), searchMode], after)
|
||||||
|
try:
|
||||||
|
result = parse(await fetch(url), after)
|
||||||
|
result.query = query
|
||||||
|
except InternalError:
|
||||||
|
return Result[T](beginning: true, query: query)
|
||||||
|
|
||||||
proc getTweetImpl(id: string; after=""): Future[Conversation] {.async.} =
|
proc getTweetImpl(id: string; after=""): Future[Conversation] {.async.} =
|
||||||
let url = tweet / (id & ".json") ? genParams(cursor=after)
|
let url = tweet / (id & ".json") ? genParams(cursor=after)
|
||||||
|
|
|
@ -12,6 +12,8 @@ const
|
||||||
"verified", "safe"
|
"verified", "safe"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
emptyQuery* = "include:nativeretweets"
|
||||||
|
|
||||||
template `@`(param: string): untyped =
|
template `@`(param: string): untyped =
|
||||||
if param in pms: pms[param]
|
if param in pms: pms[param]
|
||||||
else: ""
|
else: ""
|
||||||
|
|
Loading…
Reference in New Issue