From 6695784050605c77a301c0a66764fa9a9580a2f5 Mon Sep 17 00:00:00 2001 From: Zed Date: Fri, 11 Feb 2022 22:41:40 +0100 Subject: [PATCH] Fix user search parser --- src/experimental/parser/timeline.nim | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/experimental/parser/timeline.nim b/src/experimental/parser/timeline.nim index 351ca85..4663d00 100644 --- a/src/experimental/parser/timeline.nim +++ b/src/experimental/parser/timeline.nim @@ -15,14 +15,16 @@ proc parseUsers*(json: string; after=""): Result[User] = if raw.timeline.instructions.len == 0: return - for e in raw.timeline.instructions[0].addEntries.entries: - let id = e.entryId.getId - if e.entryId.startsWith("user"): - if id in raw.globalObjects.users: - result.content.add toUser raw.globalObjects.users[id] - elif e.entryId.startsWith("cursor"): - let cursor = e.content.operation.cursor - if cursor.cursorType == "Top": - result.top = cursor.value - elif cursor.cursorType == "Bottom": - result.bottom = cursor.value + for i in raw.timeline.instructions: + if i.addEntries.entries.len > 0: + for e in i.addEntries.entries: + let id = e.entryId.getId + if e.entryId.startsWith("user"): + if id in raw.globalObjects.users: + result.content.add toUser raw.globalObjects.users[id] + elif e.entryId.startsWith("cursor"): + let cursor = e.content.operation.cursor + if cursor.cursorType == "Top": + result.top = cursor.value + elif cursor.cursorType == "Bottom": + result.bottom = cursor.value