Skip to content

Commit 0c38918

Browse files
committed
Freedesktop: prepend initial value to async stream
This allows downstream applications to respond to the system light/dark mode preference on application startup while continuing to react to changes of the preference.
1 parent 57974f4 commit 0c38918

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/platforms/freedesktop/detect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::Mode;
21
use super::initial_value;
2+
use crate::Mode;
33

44
pub fn detect() -> Mode {
55
pollster::block_on(initial_value())
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use ashpd::desktop::settings::Settings;
2-
use futures::{Stream, StreamExt};
2+
use futures::{stream, Stream, StreamExt};
33

44
use crate::Mode;
55

66
pub async fn subscribe() -> anyhow::Result<impl Stream<Item = Mode> + Send> {
7-
Ok(Settings::new()
7+
let initial = stream::once(super::initial_value()).boxed();
8+
let later_updates = Settings::new()
89
.await?
910
.receive_color_scheme_changed()
1011
.await?
1112
.map(Mode::from)
12-
.boxed())
13+
.boxed();
14+
Ok(initial.chain(later_updates))
1315
}

0 commit comments

Comments
 (0)