diff --git a/CHANGELOG.md b/CHANGELOG.md index 822f3cf3..5475f24e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - build(packer): set `autologin-user` to `ubo` in `/etc/lightdm/lightdm.conf` - feat(core): improve update notification for phase-2 of the update process and add a spinner on top-left +- fix(core): avoid side-effects after `FinishEvent` is dispatched. ## Version 0.15.8 diff --git a/ubo_app/store/main.py b/ubo_app/store/main.py index 0b87d557..0cad87a9 100644 --- a/ubo_app/store/main.py +++ b/ubo_app/store/main.py @@ -7,7 +7,7 @@ from asyncio import Handle from datetime import datetime from pathlib import Path -from threading import current_thread, main_thread +from threading import Event, current_thread, main_thread from types import GenericAlias from typing import TYPE_CHECKING, Any, TypeVar, cast, get_origin, overload @@ -20,6 +20,7 @@ CombineReducerAction, CreateStoreOptions, FinishAction, + FinishEvent, InitAction, Store, combine_reducers, @@ -259,7 +260,9 @@ def action_middleware(action: ActionType) -> ActionType: return action -def event_middleware(event: EventType) -> EventType: +def event_middleware(event: EventType) -> EventType | None: + if is_finalizing.is_set(): + return None logger.debug( 'Event dispatched', extra={'event': event}, @@ -286,6 +289,11 @@ def event_middleware(event: EventType) -> EventType: subscribe_event = store.subscribe_event view = store.view + +is_finalizing = Event() + +subscribe_event(FinishEvent, lambda: is_finalizing.set()) + dispatch(InitAction()) if DEBUG_MODE: