Skip to content

Commit 6334ccb

Browse files
committed
feat: Handle pages without icons in relations
When querying a related database, pages that do not have an icon were causing a crash. This commit adds a check to ensure that the icon property exists before attempting to access it, preventing the error.
1 parent 200bf5f commit 6334ccb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rofi_notion/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def filter_prop(property_tupple):
1919
def fmt_choices(title_prop):
2020
def func(page):
2121
text = page['properties'][title_prop]['title'][0]['plain_text']
22-
if page.get('icon', {}).get('type') == 'emoji':
23-
emoji = page['icon']['emoji']
22+
icon = page.get('icon')
23+
if icon and icon.get('type') == 'emoji':
24+
emoji = icon['emoji']
2425
return (f'{emoji} {text}', page['id'])
2526
return (text, page['id'])
2627
return func

0 commit comments

Comments
 (0)