Retro Bulletin Board Systems on atproto. Web app and TUI. lazy mirror of alyraffauf/atbbs atbbs.xyz
forums python tui atproto bbs
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

tui/home: fetch discover concurrently

+21 -14
+21 -14
tui/screens/home.py
··· 1 + import asyncio 1 2 import random 2 3 3 4 from textual import work ··· 146 147 dids = [repo["did"] for repo in repos] 147 148 authors = await resolve_identities_batch(client, dids) 148 149 149 - items = [] 150 - for repo in repos: 151 - did = repo["did"] 152 - if did not in authors: 153 - continue 150 + resolved_dids = [did for did in dids if did in authors] 151 + 152 + async def fetch_site(did: str): 154 153 try: 155 - site_record = await get_record(client, did, lexicon.SITE, "self") 156 - name = site_record.value.get("name", "") 157 - desc = site_record.value.get("description", "") 154 + return did, await get_record(client, did, lexicon.SITE, "self") 158 155 except Exception: 156 + return None 157 + 158 + results = await asyncio.gather(*[fetch_site(did) for did in resolved_dids]) 159 + 160 + items = [] 161 + for result in results: 162 + if result is None: 159 163 continue 164 + did, site_record = result 165 + name = site_record.value.get("name", "") 160 166 handle = authors[did].handle 161 - items.append((handle, name, desc)) 167 + items.append((handle, name)) 162 168 163 169 if not items: 164 170 return 165 171 166 172 discover_list = self.query_one("#discover-list", ListView) 167 - for handle, name, desc in items: 168 - await discover_list.append( 169 - ListItem(Static(f" {name or handle}"), name=handle) 170 - ) 173 + list_items = [ 174 + ListItem(Static(f" {name or handle}"), name=handle) 175 + for handle, name in items 176 + ] 177 + await discover_list.mount(*list_items) 171 178 172 179 self.query_one("#discover-label").display = True 173 180 discover_list.display = True 174 - lv.index = 0 # select first bbs 181 + discover_list.index = 0 175 182 176 183 except Exception: 177 184 pass