mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-17 20:28:55 +00:00
fix: tx ui on repost
This commit is contained in:
@@ -175,24 +175,26 @@ impl WalletTransactions {
|
||||
});
|
||||
}
|
||||
|
||||
let rebroadcast = tx.broadcasting_timed_out(wallet);
|
||||
if !tx.cancelled() && !tx.cancelling() && !tx.posting() {
|
||||
let rebroadcast = tx.broadcasting_timed_out(wallet);
|
||||
|
||||
// Draw button to cancel transaction.
|
||||
if tx.can_cancel() || rebroadcast {
|
||||
let (icon, color) = (PROHIBIT, Some(Colors::red()));
|
||||
View::item_button(ui, CornerRadius::default(), icon, color, || {
|
||||
self.confirm_cancel_tx_id = Some(tx.data.id);
|
||||
// Show transaction cancellation confirmation modal.
|
||||
Modal::new(CANCEL_TX_CONFIRMATION_MODAL)
|
||||
.position(ModalPosition::Center)
|
||||
.title(t!("confirmation"))
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
// Draw button to repeat transaction action.
|
||||
if tx.can_repeat_action() || rebroadcast {
|
||||
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast);
|
||||
// Draw button to cancel transaction.
|
||||
if tx.can_cancel() || rebroadcast {
|
||||
let (icon, color) = (PROHIBIT, Some(Colors::red()));
|
||||
View::item_button(ui, CornerRadius::default(), icon, color, || {
|
||||
self.confirm_cancel_tx_id = Some(tx.data.id);
|
||||
// Show transaction cancellation confirmation modal.
|
||||
Modal::new(CANCEL_TX_CONFIRMATION_MODAL)
|
||||
.position(ModalPosition::Center)
|
||||
.title(t!("confirmation"))
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
// Draw button to repeat transaction action.
|
||||
if tx.can_repeat_action() || rebroadcast {
|
||||
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,29 +258,31 @@ impl WalletTransactionContent {
|
||||
});
|
||||
}
|
||||
|
||||
let rebroadcast = tx.broadcasting_timed_out(&wallet);
|
||||
if !tx.cancelled() && !tx.cancelling() && !tx.posting() {
|
||||
let rebroadcast = tx.broadcasting_timed_out(&wallet);
|
||||
|
||||
// Draw button to cancel transaction.
|
||||
if tx.can_cancel() || rebroadcast {
|
||||
let r = if tx.can_finalize() {
|
||||
CornerRadius::default()
|
||||
} else {
|
||||
View::item_rounding(0, 2, true)
|
||||
};
|
||||
View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || {
|
||||
wallet.task(WalletTask::Cancel(tx.clone()));
|
||||
Modal::close();
|
||||
});
|
||||
}
|
||||
// Draw button to cancel transaction.
|
||||
if tx.can_cancel() || rebroadcast {
|
||||
let r = if tx.can_finalize() {
|
||||
CornerRadius::default()
|
||||
} else {
|
||||
View::item_rounding(0, 2, true)
|
||||
};
|
||||
View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || {
|
||||
wallet.task(WalletTask::Cancel(tx.clone()));
|
||||
Modal::close();
|
||||
});
|
||||
}
|
||||
|
||||
// Draw button to repeat transaction action.
|
||||
if tx.can_repeat_action() || rebroadcast {
|
||||
let r = if tx.can_finalize() || tx.can_cancel() {
|
||||
CornerRadius::default()
|
||||
} else {
|
||||
View::item_rounding(0, 2, true)
|
||||
};
|
||||
WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast);
|
||||
// Draw button to repeat transaction action.
|
||||
if tx.can_repeat_action() || rebroadcast {
|
||||
let r = if tx.can_finalize() || tx.can_cancel() {
|
||||
CornerRadius::default()
|
||||
} else {
|
||||
View::item_rounding(0, 2, true)
|
||||
};
|
||||
WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -347,6 +347,12 @@ impl WalletTransaction {
|
||||
self.data.tx_type != TxLogEntryType::TxSentCancelled
|
||||
}
|
||||
|
||||
/// Check if transaction was canceled.
|
||||
pub fn cancelled(&self) -> bool {
|
||||
self.data.tx_type == TxLogEntryType::TxReceivedCancelled ||
|
||||
self.data.tx_type == TxLogEntryType::TxSentCancelled
|
||||
}
|
||||
|
||||
/// Check if transaction is finalizing.
|
||||
pub fn finalizing(&self) -> bool {
|
||||
if let Some(a) = self.action.as_ref() {
|
||||
|
||||
@@ -1373,6 +1373,8 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
|
||||
}
|
||||
}
|
||||
WalletTask::Post(s, id) => {
|
||||
w.on_tx_action(id.to_string(), Some(WalletTransactionAction::Posting));
|
||||
|
||||
let slate = match s {
|
||||
None => &w.get_tx(*id).unwrap(),
|
||||
Some(s) => s
|
||||
@@ -1380,6 +1382,9 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
|
||||
w.on_tx_error(slate.id.to_string(), None);
|
||||
|
||||
// Cleanup broadcasting tx height.
|
||||
let tx_height_store = TxHeightStore::new(w.get_config().get_extra_db_path());
|
||||
tx_height_store.delete_broadcasting_height(*id);
|
||||
|
||||
let has_data = {
|
||||
let r_data = w.data.read();
|
||||
r_data.is_some()
|
||||
|
||||
Reference in New Issue
Block a user