Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app store loading and error messages #104

Closed
wants to merge 6 commits into from
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
Loading