Skip to content

Commit 646a7c5

Browse files
committed
fix: tx ui on repost
1 parent 11a5a73 commit 646a7c5

File tree

4 files changed

+55
-40
lines changed

4 files changed

+55
-40
lines changed

src/gui/views/wallets/wallet/txs/content.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,26 @@ impl WalletTransactions {
175175
});
176176
}
177177

178-
let rebroadcast = tx.broadcasting_timed_out(wallet);
179-
180-
// Draw button to cancel transaction.
181-
if tx.can_cancel() || rebroadcast {
182-
let (icon, color) = (PROHIBIT, Some(Colors::red()));
183-
View::item_button(ui, CornerRadius::default(), icon, color, || {
184-
self.confirm_cancel_tx_id = Some(tx.data.id);
185-
// Show transaction cancellation confirmation modal.
186-
Modal::new(CANCEL_TX_CONFIRMATION_MODAL)
187-
.position(ModalPosition::Center)
188-
.title(t!("confirmation"))
189-
.show();
190-
});
191-
}
192-
193-
// Draw button to repeat transaction action.
194-
if tx.can_repeat_action() || rebroadcast {
195-
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast);
178+
if !tx.cancelled() && !tx.cancelling() && !tx.posting() {
179+
let rebroadcast = tx.broadcasting_timed_out(wallet);
180+
181+
// Draw button to cancel transaction.
182+
if tx.can_cancel() || rebroadcast {
183+
let (icon, color) = (PROHIBIT, Some(Colors::red()));
184+
View::item_button(ui, CornerRadius::default(), icon, color, || {
185+
self.confirm_cancel_tx_id = Some(tx.data.id);
186+
// Show transaction cancellation confirmation modal.
187+
Modal::new(CANCEL_TX_CONFIRMATION_MODAL)
188+
.position(ModalPosition::Center)
189+
.title(t!("confirmation"))
190+
.show();
191+
});
192+
}
193+
194+
// Draw button to repeat transaction action.
195+
if tx.can_repeat_action() || rebroadcast {
196+
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast);
197+
}
196198
}
197199
});
198200
}

src/gui/views/wallets/wallet/txs/tx.rs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -258,29 +258,31 @@ impl WalletTransactionContent {
258258
});
259259
}
260260

261-
let rebroadcast = tx.broadcasting_timed_out(&wallet);
262-
263-
// Draw button to cancel transaction.
264-
if tx.can_cancel() || rebroadcast {
265-
let r = if tx.can_finalize() {
266-
CornerRadius::default()
267-
} else {
268-
View::item_rounding(0, 2, true)
269-
};
270-
View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || {
271-
wallet.task(WalletTask::Cancel(tx.clone()));
272-
Modal::close();
273-
});
274-
}
261+
if !tx.cancelled() && !tx.cancelling() && !tx.posting() {
262+
let rebroadcast = tx.broadcasting_timed_out(&wallet);
263+
264+
// Draw button to cancel transaction.
265+
if tx.can_cancel() || rebroadcast {
266+
let r = if tx.can_finalize() {
267+
CornerRadius::default()
268+
} else {
269+
View::item_rounding(0, 2, true)
270+
};
271+
View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || {
272+
wallet.task(WalletTask::Cancel(tx.clone()));
273+
Modal::close();
274+
});
275+
}
275276

276-
// Draw button to repeat transaction action.
277-
if tx.can_repeat_action() || rebroadcast {
278-
let r = if tx.can_finalize() || tx.can_cancel() {
279-
CornerRadius::default()
280-
} else {
281-
View::item_rounding(0, 2, true)
282-
};
283-
WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast);
277+
// Draw button to repeat transaction action.
278+
if tx.can_repeat_action() || rebroadcast {
279+
let r = if tx.can_finalize() || tx.can_cancel() {
280+
CornerRadius::default()
281+
} else {
282+
View::item_rounding(0, 2, true)
283+
};
284+
WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast);
285+
}
284286
}
285287
});
286288

src/wallet/types.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,12 @@ impl WalletTransaction {
347347
self.data.tx_type != TxLogEntryType::TxSentCancelled
348348
}
349349

350+
/// Check if transaction was canceled.
351+
pub fn cancelled(&self) -> bool {
352+
self.data.tx_type == TxLogEntryType::TxReceivedCancelled ||
353+
self.data.tx_type == TxLogEntryType::TxSentCancelled
354+
}
355+
350356
/// Check if transaction is finalizing.
351357
pub fn finalizing(&self) -> bool {
352358
if let Some(a) = self.action.as_ref() {

src/wallet/wallet.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,13 +1373,18 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
13731373
}
13741374
}
13751375
WalletTask::Post(s, id) => {
1376+
w.on_tx_action(id.to_string(), Some(WalletTransactionAction::Posting));
1377+
13761378
let slate = match s {
13771379
None => &w.get_tx(*id).unwrap(),
13781380
Some(s) => s
13791381
};
13801382
w.on_tx_error(slate.id.to_string(), None);
13811383

13821384
// Cleanup broadcasting tx height.
1385+
let tx_height_store = TxHeightStore::new(w.get_config().get_extra_db_path());
1386+
tx_height_store.delete_broadcasting_height(*id);
1387+
13831388
let has_data = {
13841389
let r_data = w.data.read();
13851390
r_data.is_some()

0 commit comments

Comments
 (0)