Skip to content

Commit

Permalink
chore: Refactor friendList.ts to improve message read logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jun 22, 2024
1 parent 95496cb commit 29c506d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions islands/Chats/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,9 @@ export default function Home(
),
)
setMessage("")
// deno-lint-ignore no-explicit-any
setFriendList(
(prev: any) => {
// deno-lint-ignore prefer-const
let temp = prev
// deno-lint-ignore no-explicit-any
temp.map(
(
data:
Expand All @@ -331,7 +328,7 @@ export default function Home(
data.roomid ==
roomid
) {
data.lastMessage =
data.latestMessage =
Message
data.latestMessageTime =
new Date()
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/chats/friendList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const handler = {
}).sort({ timestamp: -1 })
const isNewMessage = latestmessage?.read.find(
(read: User) =>
read.userid === ctx.state.data.userid && latestmessage.userid !== ctx.state.data.userid,
read.userid === ctx.state.data.userid || latestmessage.userid == ctx.state.data.userid,
)
const friendResult = {
roomName: friendName?.nickName,
Expand Down Expand Up @@ -185,7 +185,7 @@ export const handler = {
}).sort({ timestamp: -1 })
const isNewMessage = latestmessage?.read.find(
(read: User) =>
read.userid === ctx.state.data.userid && latestmessage.userid !== ctx.state.data.userid
read.userid === ctx.state.data.userid || latestmessage.userid == ctx.state.data.userid
)
if (OtherServerUserInfoJson.status === true) {
const remoteFriendResult = {
Expand Down

0 comments on commit 29c506d

Please sign in to comment.