@@ -881,6 +881,8 @@ impl App for Skrepka {
883 Event::AddContact { input, nickname } => {
883 Event::AddContact { input, nickname } => {
884+ // Clear a stale error from a previous failed add.
884 // A nickname is stored in the contacts kv blob, which is
886 // A nickname is stored in the contacts kv blob, which is
885 // rewritten in full on every change. An unbounded nickname
887 // rewritten in full on every change. An unbounded nickname
886 // bloats the blob and every subsequent write.
888 // bloats the blob and every subsequent write.
@@ -3354,6 +3356,28 @@ mod tests {
3354 assert!(m.error.is_some());
3356 assert!(m.error.is_some());
3359+ /// A stale error from a previous failed add is cleared on the next attempt,
3360+ /// so the AddContact form does not show an old error after the user fixes
3361+ /// the input and tries again.
3363+ fn add_contact_clears_a_stale_error_on_success() {
3365+ let mut m = with_identity();
3366+ m.error = Some("invalid public key".into());
3368+ let peer = peer_hex(9);
3369+ let _ = app.update(
3370+ Event::AddContact {
3371+ input: peer.clone(),
3372+ nickname: "Bob".into(),
3377+ assert!(m.error.is_none(), "a successful add clears the stale error");
3378+ assert!(m.contacts.contains_key(&peer));
3358 fn send_text_enqueues_message_profile_and_outbox() {
3382 fn send_text_enqueues_message_profile_and_outbox() {
3359 let app = Skrepka;
3383 let app = Skrepka;