Skip to content

Commit

Permalink
Desktop: seaprate callbacks for dolphin and storage subscriptions (#3836
Browse files Browse the repository at this point in the history
)

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

Co-authored-by: hedger <[email protected]>
  • Loading branch information
skotopes and hedger authored Aug 12, 2024
1 parent 4f75d92 commit 702db89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions applications/services/desktop/animations/animation_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions applications/services/dolphin/dolphin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 702db89

Please sign in to comment.