Skip to content

Commit

Permalink
Merge pull request #111 from emericklaw/app-store-fixes
Browse files Browse the repository at this point in the history
Fix app store loading and error messages
  • Loading branch information
hughrawlinson authored Jun 6, 2024
2 parents e675574 + 5d4c431 commit 6b2c29e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions modules/firmware_apps/app_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def file_exists(filename):
return False


APP_STORE_LISTING_LIVE_URL = "https://api.badge.emf.camp/v1/apps"
APP_STORE_LISTING_URL = "https://apps.badge.emfcamp.org/demo_api/apps.json"

CODE_INSTALL = "CodeInstall"
Expand Down Expand Up @@ -81,13 +80,10 @@ def get_index(self):
def background_update(self, delta):
if self.state == "refreshing_index":
try:
self.response = get(APP_STORE_LISTING_LIVE_URL)
self.response = get(APP_STORE_LISTING_URL)
except Exception:
try:
self.response = get(APP_STORE_LISTING_URL)
except Exception:
self.update_state("no_index")
return
self.update_state("no_index")
return
self.update_state("index_received")
if self.to_install_app:
self.install_app(self.to_install_app)
Expand Down Expand Up @@ -147,7 +143,6 @@ def exit_available_menu():
item_font_size=ten_pt,
)


def prepare_main_menu(self):
def on_cancel():
self.minimise()
Expand Down Expand Up @@ -217,8 +212,6 @@ def uninstall_app(self, app):
eventbus.emit(InstallNotificationEvent())
machine.reset()



def error_screen(self, ctx, message):
ctx.save()
ctx.text_align = ctx.CENTER
Expand Down Expand Up @@ -272,6 +265,8 @@ def draw(self, ctx):
clear_background(ctx)
if self.state == "main_menu" and self.menu:
self.menu.draw(ctx)
elif self.state == "main_menu" and not self.menu:
self.error_screen(ctx, "Loading...")
elif self.state == "available_menu" and self.available_menu:
self.available_menu.draw(ctx)
elif self.state == "installed_menu" and self.installed_menu:
Expand All @@ -288,6 +283,8 @@ def draw(self, ctx):
self.error_screen(ctx, "Connecting\nWi-Fi...\n")
elif self.state == "refreshing_index":
self.error_screen(ctx, "Refreshing\napp store\nindex")
elif self.state == "index_received":
self.error_screen(ctx, "App store\nindex\nreceived")
elif self.state == "install_oom":
self.error_screen(ctx, "Out of memory\n(app too big?)")
elif self.state == "code_install_input" and self.codeinstall:
Expand Down

0 comments on commit 6b2c29e

Please sign in to comment.