feat(gui): PolicyPage subscribes to PolicyChanged for live refresh
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,25 @@ impl PolicyPage {
|
|||||||
glib::MainContext::default().spawn_local(async move {
|
glib::MainContext::default().spawn_local(async move {
|
||||||
p.refresh().await;
|
p.refresh().await;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Live-refresh subscriber: external `authforgectl policy set` invocations
|
||||||
|
// bypass the GUI; without subscribing the page would show stale state.
|
||||||
|
let p = page.clone();
|
||||||
|
glib::MainContext::default().spawn_local(async move {
|
||||||
|
let daemon = match p.ctx.daemon.borrow().clone() {
|
||||||
|
Some(d) => d,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
let mut stream = match daemon.subscribe_policy_changed().await {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
use futures_util::StreamExt;
|
||||||
|
while stream.next().await.is_some() {
|
||||||
|
p.refresh().await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
page
|
page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user