Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pending state while adding, fix remove bug #115

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion harbor-ui/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) {
error!("Error adding federation: {e}");
core.msg(msg.id, CoreUIMsg::AddFederationFailed(e.to_string())).await;
} else {
core.msg(msg.id, CoreUIMsg::AddFederationSuccess).await;
let new_federation_list = core.get_federation_items().await;
core.msg(msg.id, CoreUIMsg::FederationListUpdated(new_federation_list)).await;
core.msg(msg.id, CoreUIMsg::AddFederationSuccess).await;
}
}
UICoreMsg::RemoveFederation(id) => {
Expand Down
23 changes: 16 additions & 7 deletions harbor-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ impl HarborWallet {
let invite = InviteCode::from_str(&invite_code);
if let Ok(invite) = invite {
let id = Uuid::new_v4();
self.add_federation_status = AddFederationStatus::Adding;
Task::perform(
Self::async_add_federation(self.ui_handle.clone(), id, invite),
|_| Message::Noop,
Expand Down Expand Up @@ -657,7 +658,6 @@ impl HarborWallet {
}
}
Message::RemoveFederation(federation_id) => {
self.peek_status = PeekStatus::Peeking;
let id = Uuid::new_v4();
Task::perform(
Self::async_remove_federation(self.ui_handle.clone(), id, federation_id),
Expand Down Expand Up @@ -762,7 +762,7 @@ impl HarborWallet {
}
CoreUIMsg::AddFederationFailed(reason) => {
let reason = reason.clone();
self.peek_federation_item = None;
self.clear_add_federation_state();
Task::perform(async {}, move |_| {
Message::AddToast(Toast {
title: "Failed to join mint".to_string(),
Expand All @@ -773,7 +773,7 @@ impl HarborWallet {
}
CoreUIMsg::RemoveFederationFailed(reason) => {
let reason = reason.clone();
self.peek_federation_item = None;
self.clear_add_federation_state();
Task::perform(async {}, move |_| {
Message::AddToast(Toast {
title: "Failed to remove mint".to_string(),
Expand Down Expand Up @@ -816,13 +816,22 @@ impl HarborWallet {
Task::none()
}
CoreUIMsg::AddFederationSuccess => {
self.mint_invite_code_str = String::new();
self.clear_add_federation_state();
// Route to the mints list
self.active_route = Route::Mints(routes::MintSubroute::List);
self.peek_federation_item = None;
self.add_federation_status = AddFederationStatus::Idle;
Task::none()
Task::perform(async {}, |_| {
Message::AddToast(Toast {
title: "Mint added".to_string(),
// TODO: maybe we should make body optional
body: "...".to_string(),
status: ToastStatus::Neutral,
})
})
}
CoreUIMsg::RemoveFederationSuccess => {
self.clear_add_federation_state();
// Route to the mints list
self.active_route = Route::Mints(routes::MintSubroute::List);
Task::perform(async {}, |_| {
Message::AddToast(Toast {
title: "Mint removed".to_string(),
Expand Down
Loading