Skip to content

Commit

Permalink
chore: bump iced version
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolk131 committed Sep 14, 2024
1 parent 389dc96 commit 4c6730a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fedimint-ln-client = "0.4.0"
fedimint-ln-common = "0.4.0"
fedimint-mint-client = "0.4.0"
fedimint-rocksdb = "0.4.0"
iced = { git = "https://github.com/iced-rs/iced", rev = "e50aa03", features = [
iced = { git = "https://github.com/iced-rs/iced", rev = "be06060", features = [
"advanced",
"qr_code",
"svg",
Expand Down
72 changes: 34 additions & 38 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, sync::Arc};

use fedimint_core::config::FederationId;
use iced::{
futures::{SinkExt, StreamExt},
futures::StreamExt,
widget::{column, container, row, scrollable},
Element, Length, Task,
};
Expand Down Expand Up @@ -132,54 +132,50 @@ impl App {
return iced::Subscription::none();
};

let db_clone = connected_state.db.clone();

let wallet = connected_state.wallet.clone();

let wallet_sub = iced::subscription::channel(
let db = connected_state.db.clone();

let wallet_sub = iced::Subscription::run_with_id(
std::any::TypeId::of::<Wallet>(),
100,
|mut output| async move {
loop {
let mut wallet_update_stream = wallet.get_update_stream();

while let Some(views) = wallet_update_stream.next().await {
output
.send(Message::UpdateFederationViews { views })
.await
.unwrap();
}
// We're wrapping `stream` in a `stream!` macro to make it lazy (meaning `stream` isn't
// created unless the outer `stream!` is actually used). This is necessary because the
// outer stream is created on every update, but will only be polled if the subscription
// ID is new.
async_stream::stream! {
let mut stream = wallet
.get_update_stream()
.map(|views| Message::UpdateFederationViews { views });

while let Some(msg) = stream.next().await {
yield msg;
}
},
);

let nip46_sub = iced::subscription::channel(
let nip46_sub = iced::Subscription::run_with_id(
std::any::TypeId::of::<Nip46OverNip55ServerStream>(),
100,
|mut output| async move {
loop {
let mut stream = Nip46OverNip55ServerStream::start(
"/tmp/nip55-kind24133.sock",
db_clone.clone(),
)
.unwrap();

while let Some((request_list, public_key, response_sender)) =
stream.next().await
{
output
.send(Message::IncomingNip46Request(Arc::new((
request_list,
public_key,
response_sender,
))))
.await
.unwrap();
}
// We're wrapping `stream` in a `stream!` macro so that `stream` isn't created unless
// a value is actually polled from it, making it lazy. This is necessary because
// the outer stream is created on every update, but will only be polled if the
// subscription ID is new.
async_stream::stream! {
let mut stream = Nip46OverNip55ServerStream::start("/tmp/nip55-kind24133.sock", db)
.unwrap()
.map(|(request_list, public_key, response_sender)| {
Message::IncomingNip46Request(Arc::new((
request_list,
public_key,
response_sender,
)))
});

while let Some(msg) = stream.next().await {
yield msg;
}
},
);

iced::subscription::Subscription::batch(vec![nip46_sub, wallet_sub])
iced::Subscription::batch(vec![nip46_sub, wallet_sub])
}
}

0 comments on commit 4c6730a

Please sign in to comment.