Desktop: seaprate callbacks for dolphin and storage subscriptions (#3836)

* Desktop: seaprate callbacks for dolphin and storage subscriptions
* dolphin: renamed local variable to prevent unintended overrides

Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
あく 2024-08-12 09:51:43 +09:00 committed by GitHub
parent 4f75d92747
commit 702db8925f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 5 deletions

View File

@ -104,7 +104,7 @@ void animation_manager_set_dummy_mode_state(AnimationManager* animation_manager,
}
}
static void animation_manager_check_blocking_callback(const void* message, void* context) {
static void animation_manager_storage_callback(const void* message, void* context) {
const StorageEvent* storage_event = message;
switch(storage_event->type) {
@ -123,6 +123,22 @@ static void animation_manager_check_blocking_callback(const void* message, void*
}
}
static void animation_manager_dolphin_callback(const void* message, void* context) {
const DolphinPubsubEvent* dolphin_event = message;
switch(*dolphin_event) {
case DolphinPubsubEventUpdate:
furi_assert(context);
AnimationManager* animation_manager = context;
if(animation_manager->check_blocking_callback) {
animation_manager->check_blocking_callback(animation_manager->context);
}
break;
default:
break;
}
}
static void animation_manager_timer_callback(void* context) {
furi_assert(context);
AnimationManager* animation_manager = context;
@ -300,12 +316,12 @@ AnimationManager* animation_manager_alloc(void) {
Storage* storage = furi_record_open(RECORD_STORAGE);
animation_manager->pubsub_subscription_storage = furi_pubsub_subscribe(
storage_get_pubsub(storage), animation_manager_check_blocking_callback, animation_manager);
storage_get_pubsub(storage), animation_manager_storage_callback, animation_manager);
furi_record_close(RECORD_STORAGE);
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
animation_manager->pubsub_subscription_dolphin = furi_pubsub_subscribe(
dolphin_get_pubsub(dolphin), animation_manager_check_blocking_callback, animation_manager);
dolphin_get_pubsub(dolphin), animation_manager_dolphin_callback, animation_manager);
furi_record_close(RECORD_DOLPHIN);
animation_manager->blocking_shown_sd_ok = true;

View File

@ -204,8 +204,8 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
if(event.type == DolphinEventTypeDeed) {
dolphin_state_on_deed(dolphin->state, event.deed);
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
furi_pubsub_publish(dolphin->pubsub, &event);
DolphinPubsubEvent pubsub_event = DolphinPubsubEventUpdate;
furi_pubsub_publish(dolphin->pubsub, &pubsub_event);
furi_event_loop_timer_start(dolphin->butthurt_timer, BUTTHURT_INCREASE_PERIOD_TICKS);
furi_event_loop_timer_start(dolphin->flush_timer, FLUSH_TIMEOUT_TICKS);