sorting contact to display unreaded firtst
This commit is contained in:
@@ -69,7 +69,14 @@ function ContactsList({
|
||||
});
|
||||
}
|
||||
|
||||
const addContactsList = contactsList.map((contact: ContactsProps, index) => (
|
||||
const sortedContats = [...contactsList].sort((a, b) => {
|
||||
if (a.read !== b.read) {
|
||||
return a.read ? 1 : -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
const addContactsList = sortedContats.map((contact: ContactsProps, index) => (
|
||||
<li
|
||||
className="flex hover:bg-green-700 p-2 rounded cursor-pointer justify-between items-center min-h-[40px]" // Added min-h-[40px]
|
||||
onClick={() => {
|
||||
|
||||
@@ -81,6 +81,7 @@ function Chat() {
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="text-white flex h-screen">
|
||||
|
||||
14
server/utils/authorize.js
Normal file
14
server/utils/authorize.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { verifyJwtToken } = require("../auth/jwt");
|
||||
|
||||
function authorizeUser(res, token) {
|
||||
if (!token) {
|
||||
return res.status(401).json({ message: "Unauthorized" });
|
||||
}
|
||||
try {
|
||||
const { username } = verifyJwtToken(token);
|
||||
if (username) {
|
||||
return res.status(200).json({ message: "Authorized", username: username });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user