Skip to content

Commit

Permalink
Allow to install multiple apps (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel authored Aug 4, 2024
1 parent 17b9261 commit 8e1ba36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 17 additions & 6 deletions modules/firmware_apps/app_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self):
self.app_store_index = []
self.to_install_app = None
self.tarball = None
self.wait_one_cycle = False

def cleanup_ui_widgets(self):
widgets = [
Expand All @@ -69,7 +70,12 @@ def cleanup_ui_widgets(self):
for widget in widgets:
if widget:
widget._cleanup()
widget = None

self.menu = None
self.available_menu = None
self.installed_menu = None
self.update_menu = None
self.codeinstall = None

def get_index(self):
if not wifi.status():
Expand All @@ -86,8 +92,13 @@ def background_update(self, delta):
return
self.update_state("index_received")
if self.to_install_app:
self.install_app(self.to_install_app)
self.to_install_app = None
# We wait one cycle after background_update is called to ensure the
# installation screen is drawn
if self.wait_one_cycle:
self.install_app(self.to_install_app)
self.to_install_app = None
self.wait_one_cycle = False
self.wait_one_cycle = True

def handle_index(self):
if not self.response:
Expand Down Expand Up @@ -134,8 +145,7 @@ def prepare_available_menu(self):
def on_select(_, i):
self.to_install_app = self.app_store_index[i]
self.update_state("installing_app")
if self.available_menu:
self.available_menu._cleanup()
self.cleanup_ui_widgets()

def exit_available_menu():
self.cleanup_ui_widgets()
Expand All @@ -152,11 +162,12 @@ def exit_available_menu():

def prepare_main_menu(self):
def on_cancel():
self.cleanup_ui_widgets()
self.minimise()

def on_select(value, idx):
self.cleanup_ui_widgets()
if value == CODE_INSTALL:
self.cleanup_ui_widgets()
self.codeinstall = CodeInstall(
install_handler=lambda id: self.handle_code_input(id), app=self
)
Expand Down
6 changes: 6 additions & 0 deletions modules/system/eventbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ def remove(self, event_type, event_handler, app):
if app in self.handlers:
if event_type in self.handlers[app]:
if event_handler in self.handlers[app][event_type]:
print(
f"Removed event handler for {event_type.__name__}: {app.__class__.__name__} - {event_handler.__name__}"
)
self.handlers[app][event_type].remove(event_handler)
if app in self.async_handlers:
if event_type in self.async_handlers[app]:
if event_handler in self.async_handlers[app][event_type]:
print(
f"Removed event handler for {event_type.__name__}: {app.__class__.__name__} - {event_handler.__name__}"
)
self.async_handlers[app][event_type].remove(event_handler)

def deregister(self, app):
Expand Down

0 comments on commit 8e1ba36

Please sign in to comment.