commit 349103432936b7c5ac8f3f0873984a640a5d9a26
parent 3d8cde01759b40d2b9a5dea1c30cfbceff34f66b
Author: Sylvia Ivory <git@sivory.net>
Date: Thu, 19 Jun 2025 19:24:47 -0700
Automatic unsplash changing
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/background.rs b/src/background.rs
@@ -176,9 +176,15 @@ impl BackgroundHandle {
return Task::none();
}
- state.current = (direction + (state.current as isize))
- .clamp(0, state.total as isize)
- as usize;
+ let mut new = state.current as isize + direction;
+
+ if new < 0 {
+ new = state.total as isize;
+ } else if new > state.total as isize {
+ new = 0;
+ }
+
+ state.current = new as usize;
let page = (state.current / 10) + 1;
diff --git a/src/main.rs b/src/main.rs
@@ -383,6 +383,8 @@ impl Fjordgard {
Subscription::batch([
time::every(time::Duration::from_secs(1)).map(|_| Message::Tick(Local::now())),
time::every(time::Duration::from_secs(60 * 15)).map(|_| Message::RequestForecastUpdate),
+ time::every(time::Duration::from_secs(60 * 15))
+ .map(|_| Message::Background(background::Message::RequestUnsplash(1))),
window::close_events().map(Message::WindowClosed),
])
}