]> git.cworth.org Git - turbot/commitdiff
Turbot home: Report "you do not belong to any hunts" if that is the case
authorCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 16:41:45 +0000 (09:41 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 16:55:34 +0000 (09:55 -0700)
Instead of having the header "Hunts you belong to" followed by nothing.

turbot/events.py

index 64430e5527a0a72395c3a818223f2eb115494dcf..a118835d3b8eb0b42a5e04f6483abbebaf95a74b 100644 (file)
@@ -91,11 +91,20 @@ def home(turb, user_id):
             continue
         hunt_blocks += hunt_block(turb, hunt)
 
+    if len(hunt_blocks):
+        hunt_blocks = [
+            section_block(text_block("*Hunts you belong to*")),
+            divider_block(),
+            * hunt_blocks
+        ]
+    else:
+        hunt_blocks = [
+            section_block(text_block("You do not belong to any hunts"))
+        ]
+
     return {
         "type": "home",
         "blocks": [
-            section_block(text_block("*Hunts you belong to*")),
-            divider_block(),
             * hunt_blocks,
             actions_block(button_block("New hunt", "new_hunt"))
         ]