From 52d962a6bb324ab850d6bc41aa0511e54d719d02 Mon Sep 17 00:00:00 2001 From: yuni Date: Sat, 26 Oct 2024 22:44:39 +0200 Subject: [PATCH] fix phonebook duplicates --- src/chat.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 945d2b0..964e423 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1025,8 +1025,11 @@ pub fn handle_chat_scripts( } "registercontact" => { if CONTACTS.contains(¶m1) { - prefs.contacts.push(param1.to_string()); - prefs.save(); + let param1_string = param1.to_string(); + if !prefs.contacts.contains(¶m1_string) { + prefs.contacts.push(param1_string); + prefs.save(); + } } else { error!("Can't register contact `{param1}', it doesn't exist in the chat::CONTACTS constant."); }