From 0ad2a275ea9472cd31f6d118756b7478319ba051 Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Thu, 17 Dec 2020 11:56:13 +0200 Subject: [PATCH] Fix runtime error --- util.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util.go b/util.go index 98cf083..c2dd758 100644 --- a/util.go +++ b/util.go @@ -193,12 +193,14 @@ func parseTimeline(timeline *timeline) ([]*Tweet, string) { var cursor string var orderedTweets []*Tweet - for _, entry := range timeline.Timeline.Instructions[0].AddEntries.Entries { - if tweet, ok := tweets[entry.Content.Item.Content.Tweet.ID]; ok { - orderedTweets = append(orderedTweets, &tweet) - } - if entry.Content.Operation.Cursor.CursorType == "Bottom" { - cursor = entry.Content.Operation.Cursor.Value + if len(timeline.Timeline.Instructions) > 0 { + for _, entry := range timeline.Timeline.Instructions[0].AddEntries.Entries { + if tweet, ok := tweets[entry.Content.Item.Content.Tweet.ID]; ok { + orderedTweets = append(orderedTweets, &tweet) + } + if entry.Content.Operation.Cursor.CursorType == "Bottom" { + cursor = entry.Content.Operation.Cursor.Value + } } } return orderedTweets, cursor