chiark / gitweb /
Cope with a timeline not containing any posts!
authorSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 15:56:31 +0000 (15:56 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 16:26:13 +0000 (16:26 +0000)
Of course, that's the first thing that happens when you log in to a
fresh Mastodon test instance.

client.py

index 6b171a4d517dc690b03ad7047b3224cfcc9120ed..e366fb963d90965fc44a93480375853d2d1af9fe 100644 (file)
--- a/client.py
+++ b/client.py
@@ -209,8 +209,8 @@ class IncrementalServerFeed(Feed):
             self.url, **self.params)
         self.data = list(self.get(d) for d in reversed(data))
         self.origin = len(self.data)
-        self.prev_link = links['prev']
-        self.next_link = links['next']
+        self.prev_link = links.get('prev')
+        self.next_link = links.get('next')
         self.started = True
 
     def min_index(self):
@@ -225,6 +225,8 @@ class IncrementalServerFeed(Feed):
     def extend_past(self):
         if not self.started:
             return None
+        if self.next_link is None:
+            return False
         data, links = self.client.get_incremental_cont(self.next_link)
         if len(data) == 0:
             return False
@@ -236,6 +238,8 @@ class IncrementalServerFeed(Feed):
     def extend_future(self):
         if not self.started:
             return None
+        if self.prev_link is None:
+            return False
         data, links = self.client.get_incremental_cont(self.prev_link)
         if len(data) == 0:
             return False