restored important part
This commit is contained in:
@@ -14,6 +14,7 @@ type ContactsListProps = {
|
||||
setCurrentContact: React.Dispatch<React.SetStateAction<string | null>>;
|
||||
updateContactStatus: (contactObj: ContactsProps, read: true) => void;
|
||||
};
|
||||
|
||||
function ContactsList({
|
||||
InitializeContact,
|
||||
contactsList,
|
||||
@@ -62,6 +63,15 @@ function ContactsList({
|
||||
};
|
||||
}, []);
|
||||
|
||||
function removeContact(usernamecontact: string) {
|
||||
deleteContact(usernamecontact); // Remove contact from server
|
||||
// Remove contact on client
|
||||
setContactsList((prevContacts) =>
|
||||
prevContacts.filter(
|
||||
(contact) => contact.usernamecontact !== usernamecontact,
|
||||
),
|
||||
);
|
||||
}
|
||||
const sortedContacts = [...contactsList].sort((a, b) => {
|
||||
if (a.read !== b.read) {
|
||||
return a.read ? 1 : -1;
|
||||
@@ -90,7 +100,7 @@ function ContactsList({
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
deleteContact(contact.usernamecontact);
|
||||
removeContact(contact.usernamecontact);
|
||||
setCurrentContact(null);
|
||||
localStorage.removeItem('contact');
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user