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 4e3cdb9
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 197 deletions.
284 changes: 133 additions & 151 deletions Cargo.lock

Large diffs are not rendered by default.

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 = "8fb939b", 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 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 = 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])
}
}
4 changes: 2 additions & 2 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Route {
]
.spacing(20),
)
.align_items(Alignment::Center)
.align_x(Alignment::Center)
.into();
}
}
Expand Down Expand Up @@ -277,5 +277,5 @@ impl<T> Loadable<T> {
fn container<'a>(title: &str) -> Column<'a, app::Message> {
column![text(title.to_string()).size(35)]
.spacing(20)
.align_items(iced::Alignment::Center)
.align_x(iced::Alignment::Center)
}
2 changes: 1 addition & 1 deletion src/routes/nostr_keypairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl List {
container = container.push(row![
Text::new(truncate_text(&public_key, 12, true))
.size(20)
.horizontal_alignment(iced::alignment::Horizontal::Center),
.align_x(iced::alignment::Horizontal::Center),
icon_button("Delete", SvgIcon::Delete, PaletteColor::Danger).on_press(
app::Message::Routes(super::Message::NostrKeypairsPage(
Message::DeleteKeypair { public_key }
Expand Down
2 changes: 1 addition & 1 deletion src/routes/nostr_relays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl List {
container = container.push(row![
Text::new(truncate_text(&relay.websocket_url, 12, true))
.size(20)
.horizontal_alignment(iced::alignment::Horizontal::Center),
.align_x(iced::alignment::Horizontal::Center),
icon_button("Delete", SvgIcon::Delete, PaletteColor::Danger).on_press(
app::Message::Routes(super::Message::NostrRelaysPage(Message::DeleteRelay {
websocket_url: relay.websocket_url
Expand Down
4 changes: 2 additions & 2 deletions src/ui_components/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn icon_button(
// TODO: Find a way to darken the icon color when the button is disabled.
let svg = icon.view(24.0, 24.0, Color::WHITE);
let content = row![svg, text(text_str).size(24.0)]
.align_items(iced::Alignment::Center)
.align_y(iced::Alignment::Center)
.spacing(8)
.padding(8);

Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn sidebar_button<'a>(
// TODO: Find a way to darken the icon color when the button is disabled.
let svg = icon.view(24.0, 24.0, Color::WHITE);
let content = row![svg, text(text_str).size(24.0)]
.align_items(iced::Alignment::Center)
.align_y(iced::Alignment::Center)
.spacing(8)
.padding(8);

Expand Down
2 changes: 1 addition & 1 deletion src/ui_components/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn sidebar(keystache: &app::App) -> Element<app::Message> {
))),
]
.spacing(8)
.align_items(Alignment::Start),
.align_x(Alignment::Start),
)
.padding(8)
.style(|theme| -> Style {
Expand Down

0 comments on commit 4e3cdb9

Please sign in to comment.