capsule: accept the open event breadbox can actually emit
An app may only publish inside its own bread.<app_id>.* namespace, so breadbox (app id 'box') cannot emit bread.command.box.open — bread-client refuses it and the redirect did nothing but log a warning. The capsule now also subscribes to bread.box.open_requested, which is what breadbox emits. bread.command.box.open is kept as well: that is the addressed-to-an-app command form an external trigger (the bread CLI, a keybind, another app) would legitimately send, so the capsule opens whether it was asked directly or told by breadbox.
This commit is contained in:
parent
a7db4d093d
commit
6c4df8813c
1 changed files with 18 additions and 4 deletions
|
|
@ -32,8 +32,22 @@ pub fn spawn(sender: ComponentSender<App>) {
|
|||
return;
|
||||
}
|
||||
let client = BreadClient::connect(crate::widgets::client::APP_ID);
|
||||
let subscription = client.subscribe("bread.command.box.open", move |_event| {
|
||||
sender.input(AppInput::OpenLauncher);
|
||||
});
|
||||
std::mem::forget(subscription);
|
||||
// Two verbs, deliberately.
|
||||
//
|
||||
// `bread.box.open_requested` is what breadbox actually emits when the
|
||||
// active theme is embedded: an app may only publish inside its own
|
||||
// `bread.<app_id>.*` namespace, so breadbox (app id `box`) cannot emit a
|
||||
// `bread.command.*` event at all — bread-client refuses it outright.
|
||||
//
|
||||
// `bread.command.box.open` is kept because it is the addressed-TO-an-app
|
||||
// command form, which is what an external trigger (the `bread` CLI, a
|
||||
// keybind, another app) would legitimately send. Honouring both means the
|
||||
// capsule opens whether it was asked directly or told by breadbox.
|
||||
for verb in ["bread.box.open_requested", "bread.command.box.open"] {
|
||||
let sender = sender.clone();
|
||||
let subscription = client.subscribe(verb, move |_event| {
|
||||
sender.input(AppInput::OpenLauncher);
|
||||
});
|
||||
std::mem::forget(subscription);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue