diff --git a/applications/main/momentum_app/momentum_app.c b/applications/main/momentum_app/momentum_app.c index 58ae5034c..b0459c4e5 100644 --- a/applications/main/momentum_app/momentum_app.c +++ b/applications/main/momentum_app/momentum_app.c @@ -97,7 +97,7 @@ bool momentum_app_apply(MomentumApp* app) { } } - if(app->save_level || app->save_angry) { + if(app->save_dolphin) { Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); if(app->save_level) { int32_t xp = app->dolphin_level > 1 ? DOLPHIN_LEVELS[app->dolphin_level - 2] : 0; @@ -107,7 +107,8 @@ bool momentum_app_apply(MomentumApp* app) { dolphin->state->data.butthurt = app->dolphin_angry; } dolphin->state->dirty = true; - dolphin_state_save(dolphin->state); + dolphin_flush(dolphin); + dolphin_reload_state(dolphin); furi_record_close(RECORD_DOLPHIN); } diff --git a/applications/main/momentum_app/momentum_app.h b/applications/main/momentum_app/momentum_app.h index 85e4dd318..c346d8d78 100644 --- a/applications/main/momentum_app/momentum_app.h +++ b/applications/main/momentum_app/momentum_app.h @@ -75,6 +75,7 @@ typedef struct { bool save_name; bool save_level; bool save_angry; + bool save_dolphin; bool save_backlight; bool save_settings; bool apply_pack; diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_dolphin.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_dolphin.c index 49cbf0132..593424c4a 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_dolphin.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_dolphin.c @@ -18,6 +18,7 @@ static void momentum_app_scene_misc_dolphin_dolphin_level_changed(VariableItem* snprintf(level_str, 4, "%li", app->dolphin_level); variable_item_set_current_value_text(item, level_str); app->save_level = true; + app->save_dolphin = true; } static void momentum_app_scene_misc_dolphin_dolphin_angry_changed(VariableItem* item) { @@ -27,6 +28,7 @@ static void momentum_app_scene_misc_dolphin_dolphin_angry_changed(VariableItem* snprintf(angry_str, 4, "%li", app->dolphin_angry); variable_item_set_current_value_text(item, angry_str); app->save_angry = true; + app->save_dolphin = true; } const char* const butthurt_timer_names[] = { @@ -59,7 +61,7 @@ static void momentum_app_scene_misc_dolphin_butthurt_timer_changed(VariableItem* variable_item_set_current_value_text(item, butthurt_timer_names[index]); momentum_settings.butthurt_timer = butthurt_timer_values[index]; app->save_settings = true; - app->require_reboot = true; + app->save_dolphin = true; } void momentum_app_scene_misc_dolphin_on_enter(void* context) { diff --git a/applications/services/dolphin/application.fam b/applications/services/dolphin/application.fam index 2860b67a8..78a097e67 100644 --- a/applications/services/dolphin/application.fam +++ b/applications/services/dolphin/application.fam @@ -6,5 +6,5 @@ App( cdefines=["SRV_DOLPHIN"], stack_size=1 * 1024, order=50, - sdk_headers=["dolphin.h", "helpers/dolphin_state.h"], + sdk_headers=["dolphin.h"], ) diff --git a/applications/services/dolphin/dolphin.c b/applications/services/dolphin/dolphin.c index 6748268c8..47b878180 100644 --- a/applications/services/dolphin/dolphin.c +++ b/applications/services/dolphin/dolphin.c @@ -85,6 +85,15 @@ FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) { return dolphin->pubsub; } +void dolphin_reload_state(Dolphin* dolphin) { + furi_check(dolphin); + + DolphinEvent event; + event.type = DolphinEventTypeReloadState; + + dolphin_event_send_wait(dolphin, &event); +} + // Private functions static void dolphin_butthurt_timer_callback(void* context) { @@ -228,6 +237,7 @@ static bool dolphin_process_event(FuriMessageQueue* queue, void* context) { !dolphin_state_xp_to_levelup(dolphin->state->data.icounter); } else if(event.type == DolphinEventTypeFlush) { + dolphin_flush_timer_callback(dolphin); furi_event_loop_timer_start(dolphin->flush_timer, FLUSH_TIMEOUT_TICKS); } else if(event.type == DolphinEventTypeLevel) { diff --git a/applications/services/dolphin/dolphin.h b/applications/services/dolphin/dolphin.h index 01da7f3f2..e66113021 100644 --- a/applications/services/dolphin/dolphin.h +++ b/applications/services/dolphin/dolphin.h @@ -45,6 +45,8 @@ void dolphin_upgrade_level(Dolphin* dolphin); FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin); +void dolphin_reload_state(Dolphin* dolphin); + #ifdef __cplusplus } #endif