Keep mini mode temporary and without a tray icon

Mini mode is a quick practice, so it no longer opens a tray icon and its
extra window, and it keeps nothing: finished practices, mood check-ins,
and changed settings stay in memory, and nothing is synced or counted
toward habits. The results page drops the save status and the mood
picker, which had nothing to record. Opening the full app from mini mode
saves as usual from then on.
This commit is contained in:
waozi committed 2026-09-30 06:08:40 -03:00
1 parent f2d24b167d
commit 425efb0cb3
10 files changed
+77 -11

No files matched your search

+3 -1
View File
@@ -60,6 +60,7 @@ using ModalType;
#import, file "exercise_types.zi";
#import, file "../storage/storage_core.zi";
#import, file "../storage/db.zi";
#import, file "../storage/temporary_data.zi";
using ExerciseType;
SyncCopyText :: (dst: *u8, capacity: s64, value: string) -> bool {
@@ -1044,7 +1045,8 @@ app_auto_sync :: (app: *InnerBreeze) -> s32 {
now: float64
url: [256] u8
if app == null || PreviewMode() != 0 || app_sync_url(*url[0], size_of(type_of(url))) == 0 {
if app == null || PreviewMode() != 0 || DataTemporary() ||
app_sync_url(*url[0], size_of(type_of(url))) == 0 {
return 0
}
now = GetTime()
+4
View File
@@ -1,5 +1,6 @@
#import, file "mini_mode_policy.zi";
#import, file "route_host.zi";
#import, file "../storage/temporary_data.zi";
// Whether Inbe runs in mini mode; see mini_mode_policy.zi. The expand button
// and the switch to the full app are in mini_mode_expand.zi.
@@ -27,9 +28,12 @@ AppMiniModeStart :: (args: []string) -> bool {
} else {
app_mini_mode = MiniModeArgument(args)
}
// A mini session is temporary; see DataTemporary.
DataSetTemporary(app_mini_mode)
return app_mini_mode
}
AppMiniModeEnd :: () {
app_mini_mode = false
DataSetTemporary(false)
}
+8
View File
@@ -4,6 +4,7 @@ c :: #system_library "c";
#import, file "text_buffers.zi";
#import, file "settings_cache.zi";
#import, file "../storage/setting_visitor.zi";
#import, file "../storage/temporary_data.zi";
storage_set_setting_int :: (key: string, value: s32) #foreign c;
storage_set_setting_text :: (key: string, value: string) #foreign c;
@@ -56,6 +57,10 @@ SettingsStoreKeyInt :: (key: SettingsKey, value: s32) -> bool {
if !SettingsKeyValid(key) {
return false
}
// Temporary data (mini mode) keeps settings only in memory.
if DataTemporary() {
return true
}
storage_set_setting_int(AppTextFromCString(*key.bytes[0], key.count + 1), value)
return true
}
@@ -75,6 +80,9 @@ SettingsStoreKeyText :: (key: SettingsKey, value: []u8) -> bool {
if length == cast(s32)value.count && length > 0 {
return false
}
if DataTemporary() {
return true
}
text: string = ""
if length > 0 {
text = AppTextFromCString(*value[0], length + 1)
+2 -1
View File
@@ -26,6 +26,7 @@ Tm :: struct {
#import, file "../storage/storage_habits.zi";
#import, file "../app/locale.zi";
#import, file "../storage/data.zi";
#import, file "../storage/temporary_data.zi";
#import, file "../storage/storage_core.zi";
@@ -647,7 +648,7 @@ habit_matches_activity :: (habit: *Habit, exercise_type: s32) -> s32 {
sync_habits_for_activity :: (app: *InnerBreeze, exercise_type: s32) {
changed: s32 = 0
if app == null {
if app == null || DataTemporary() {
return
}
+9 -4
View File
@@ -51,6 +51,7 @@ using ExerciseType;
using FrameStatus;
#import, file "platform/app_host.zi";
#import, file "platform/desktop_tray.zi";
#import, file "app/mini_mode.zi";
WEB_BUILD :: #defined(PLATFORM_WEB)
DESKTOP_TRAY_BUILD :: #defined(DESKTOP_TRAY_ENABLED)
@@ -289,10 +290,14 @@ run_application :: (argc: s32, argv: **u8) -> s32 {
InstallShutdownHandlers()
#if DESKTOP_TRAY_BUILD {
desktop_tray_init()
if ShouldStartHidden(*app) != 0 {
TraceLog(LOG_INFO, "APP: starting hidden in the tray (startup mode)")
desktop_tray_keep_running()
// The mini window is a quick practice with nothing to keep
// running, so it opens no tray icon.
if !AppMiniMode() {
desktop_tray_init()
if ShouldStartHidden(*app) != 0 {
TraceLog(LOG_INFO, "APP: starting hidden in the tray (startup mode)")
desktop_tray_keep_running()
}
}
}
+12 -5
View File
@@ -18,6 +18,7 @@
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/locale.zi";
#import, file "../storage/temporary_data.zi";
#import, file "../app/text_buffers.zi";
#import, file "../app/current_app.zi";
#import "button_widget"
@@ -523,7 +524,9 @@ session_result_content_height :: (result: *SessionResult) -> s32 {
} else {
h += AppScale(50 + session_result_other_count(result) * 38 + 14)
}
h += AppScale(50 + 14 + 124 + 14)
if !DataTemporary() {
h += AppScale(50 + 14 + 124 + 14)
}
if result.activity == EXERCISE_WIM_HOF && result.round_count > 1 {
h += AppScale(50 + ((result.round_count + 1) / 2) * 40 + 14)
}
@@ -556,10 +559,14 @@ session_result_draw_content :: (app: *InnerBreeze, result: *SessionResult,
content_y += AppScale(50 + session_result_other_count(result) * 38 + 14)
}
session_result_status(result, box_x, content_y, box_w)
content_y += AppScale(50 + 14)
session_result_mood_picker(app, box_x, content_y, box_w)
content_y += AppScale(124 + 14)
// Temporary results are not kept, so there is no save status and no
// mood to record.
if !DataTemporary() {
session_result_status(result, box_x, content_y, box_w)
content_y += AppScale(50 + 14)
session_result_mood_picker(app, box_x, content_y, box_w)
content_y += AppScale(124 + 14)
}
if result.activity == EXERCISE_WIM_HOF && result.round_count > 1 {
session_result_round_list(result, box_x, content_y, box_w)
}
+12
View File
@@ -11,6 +11,7 @@
#import, file "import.zi";
#import, file "../platform/environment.zi";
#import, file "storage_elist.zi";
#import, file "temporary_data.zi";
#import "file_linux"
using StorageImportMode;
c :: #system_library "c";
@@ -221,6 +222,10 @@ data_today_dir :: () -> string {
data_save_session_path :: (round_times: *s32, round_count: s32,
out_path: *u8, out_path_size: s64) -> s32 {
if DataTemporary() {
if out_path != null && out_path_size > 0 { out_path[0] = cast(u8)0 }
return 1
}
data_init()
return storage_save_session(round_times, round_count, out_path, out_path_size)
}
@@ -230,6 +235,10 @@ data_save_session_path_for_activity :: (round_times: *s32, round_count: s32,
topic: s32, activity: s32,
out_path: *u8,
out_path_size: s64) -> s32 {
if DataTemporary() {
if out_path != null && out_path_size > 0 { out_path[0] = cast(u8)0 }
return 1
}
data_init()
return storage_save_session_for_activity(round_times, round_count, topic, activity,
out_path, out_path_size)
@@ -254,6 +263,9 @@ data_discard_session :: (path: string) -> s32 {
data_save_session_checkin :: (path: string,
checkin: *SessionMoodCheckin) -> s32 {
if DataTemporary() {
return 1
}
data_init()
return storage_save_session_checkin(path, checkin)
}
+12
View File
@@ -0,0 +1,12 @@
// Temporary data is kept only while the app runs: mini mode's practices
// count as finished, but no session, check-in, or setting is written and
// nothing is synced.
data_temporary: bool;
DataSetTemporary :: (temporary: bool) {
data_temporary = temporary
}
DataTemporary :: () -> bool {
return data_temporary
}
+12
View File
@@ -1,4 +1,5 @@
#import, file "../src/app/settings_store.zi";
#import, file "../src/storage/temporary_data.zi";
#program_export
Answer :: () -> s32 {
@@ -11,3 +12,14 @@ Answer :: () -> s32 {
}
return 42
}
// Temporary data (mini mode) accepts settings without writing them.
#program_export
TemporaryAnswer :: () -> s32 {
DataSetTemporary(true)
if !SettingsStoreInt("speed", 9) { return 1 }
language: [3]u8 = .{100, 101, 0}
if !SettingsStoreText("language", language[:]) { return 2 }
DataSetTemporary(false)
return 42
}
+3
View File
@@ -103,5 +103,8 @@ main(void)
assert(strcmp(saved_key, "language") == 0);
assert(strcmp(saved_text, "zh") == 0);
assert(int_reads == 1);
assert(TemporaryAnswer() == 42);
assert(int_writes == 1 && saved_value == 7);
assert(text_writes == 1 && strcmp(saved_text, "zh") == 0);
return 0;
}