on master help sign in
Ninth-pass audit: SetBlocked clears stale error on unblock

SetBlocked did not clear model.error. If the user got "cannot send to a blocked contact" and then unblocked the peer via the chat menu, the error stayed visible in the chat composer until they navigated away or sent again. Now clears error at entry, same as send_text and SaveProfile (eighth pass). The block that caused the error is lifted, so the error that reported it should not outlive it. Test: unblocking_clears_the_stale_send_error

commit492430cc84892633d4c5b6d55dd19ccdfec12d69 authoriko <mail@iko.soy> dateTue 14 Jul 2026, 03:58 (3 months ago) parente894a24
1 file changed+27
core/src/app.rs+27
core/src/app.rs+27
@@ -917,6 +917,9 @@ impl App for Skrepka {
917917 if let Some(c) = model.contacts.get_mut(&peer) {
918918 c.blocked = blocked;
919919 }
920+ // Clear a stale error (e.g. "cannot send to a blocked contact")
921+ // when the user unblocks — the block that caused it is now lifted.
922+ model.error = None;
920923 if blocked {
921924 // Gating *ingest* on the block only stops the acks we have not
922925 // queued yet. Anything already sitting in the outbox for this
@@ -3442,6 +3445,30 @@ mod tests {
34423445 assert!(vm.contacts.iter().any(|c| c.pubkey == peer && c.blocked));
34433446 }
34443447
3448+ /// Unblocking clears a stale "cannot send to a blocked contact" error, so the
3449+ /// chat error display does not persist after the user lifts the block.
3450+ #[test]
3451+ fn unblocking_clears_the_stale_send_error() {
3452+ let app = Skrepka;
3453+ let mut m = with_identity();
3454+ let peer = peer_hex(9);
3455+ let mut contact = Contact::new(peer.clone(), "Bob".into(), 0);
3456+ contact.blocked = true;
3457+ m.contacts.insert(peer.clone(), contact);
3458+ m.error = Some("cannot send to a blocked contact".into());
3459+
3460+ let _ = app.update(
3461+ Event::SetBlocked {
3462+ peer: peer.clone(),
3463+ blocked: false,
3464+ },
3465+ &mut m,
3466+ );
3467+
3468+ assert!(!m.contacts[&peer].blocked);
3469+ assert!(m.error.is_none(), "unblocking clears the stale error");
3470+ }
3471+
34453472 /// Gating ingest stops the acks we have not queued yet — but the ack for the
34463473 /// message that made the user hit "block" is already in the outbox, and an ack
34473474 /// is exactly the "we are online and reading you" signal the block exists to