Merge pull request #726 from jasonrhansen/dialog-subscriptions

Fix crash for dialog in debug mode
This commit is contained in:
Jeremy Soller 2025-01-05 22:22:04 -07:00 committed by GitHub
commit 792c6400c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -251,7 +251,8 @@ impl<M: Send + 'static> Dialog<M> {
self.cosmic self.cosmic
.subscription() .subscription()
.map(DialogMessage) .map(DialogMessage)
.map(self.mapper) .with(self.mapper)
.map(|(mapper, message)| mapper(message))
} }
pub fn update(&mut self, message: DialogMessage) -> Task<M> { pub fn update(&mut self, message: DialogMessage) -> Task<M> {
@ -1709,16 +1710,17 @@ impl Application for App {
]; ];
for (key, mounter) in MOUNTERS.iter() { for (key, mounter) in MOUNTERS.iter() {
let key = *key; subscriptions.push(
subscriptions.push(mounter.subscription().map(move |mounter_message| { mounter.subscription().with(*key).map(
match mounter_message { |(key, mounter_message)| match mounter_message {
MounterMessage::Items(items) => Message::MounterItems(key, items), MounterMessage::Items(items) => Message::MounterItems(key, items),
_ => { _ => {
log::warn!("{:?} not supported in dialog mode", mounter_message); log::warn!("{:?} not supported in dialog mode", mounter_message);
Message::None Message::None
} }
} },
})); ),
);
} }
Subscription::batch(subscriptions) Subscription::batch(subscriptions)