Skip to content

Commit 881fa1c

Browse files
author
Ruslan
committed
Set the data on boot
1 parent 085b221 commit 881fa1c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,25 @@ pub fn main() {
4747
std::time::Duration::from_secs(60 * 60),
4848
move || {
4949
if let Some(app) = app_bin.upgrade() {
50-
let api = app.global::<Api>();
51-
api.set_is_yellow_bin(is_yellow_bin());
52-
api.set_days_to_bin(get_days_to_bin());
50+
set_bins(app.global::<Api>());
5351
}
5452
},
5553
);
5654

55+
// Set now instead of waiting for the timers to kick in
56+
let app_now = Arc::clone(&app_arc);
57+
if let Some(app) = app_now.upgrade() {
58+
set_bins(app.global::<Api>());
59+
}
60+
5761
app.run().expect("AppWindow::run() failed");
5862
}
5963

64+
pub fn set_bins(api: Api) {
65+
api.set_is_yellow_bin(is_yellow_bin());
66+
api.set_days_to_bin(get_days_to_bin());
67+
}
68+
6069
// Yellow alternate every week
6170
pub fn is_yellow_bin() -> bool {
6271
let known_yellow_bin_day = Local.with_ymd_and_hms(2024, 5, 13, 0, 0, 0).unwrap();

0 commit comments

Comments
 (0)