-
-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: functionality to view unread messages and mark messages as read. #2353
base: develop
Are you sure you want to change the base?
Changes from all commits
1ca936b
c42da5e
3742346
06f4af4
c18b97b
cbde8f7
9950269
77a392c
eb54545
09427e6
6fbaaa2
8fffdc5
f76dc3e
d4864a8
75fa6c3
58086e2
4d6f9a6
a68dcb4
3df2541
15385ae
1ee07f3
4525924
f4b6fd0
74899fd
450b587
b1790e2
fe66f0a
352b6b5
9a661e5
580260a
182eded
e6e5c24
426f34c
11265e0
85f698c
d541812
635a115
9d581e8
4b3850a
da51531
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,34 +57,6 @@ export const REMOVE_SAMPLE_ORGANIZATION_MUTATION = gql` | |
* @returns The created direct chat object. | ||
*/ | ||
|
||
export const CREATE_GROUP_CHAT = gql` | ||
mutation createGroupChat( | ||
$userIds: [ID!]! | ||
$organizationId: ID! | ||
$title: String! | ||
) { | ||
createGroupChat( | ||
data: { | ||
userIds: $userIds | ||
organizationId: $organizationId | ||
title: $title | ||
} | ||
) { | ||
_id | ||
} | ||
} | ||
`; | ||
|
||
export const CREATE_DIRECT_CHAT = gql` | ||
mutation createDirectChat($userIds: [ID!]!, $organizationId: ID) { | ||
createDirectChat( | ||
data: { userIds: $userIds, organizationId: $organizationId } | ||
) { | ||
_id | ||
} | ||
} | ||
`; | ||
|
||
export const CREATE_CHAT = gql` | ||
mutation createChat( | ||
$userIds: [ID!]! | ||
|
@@ -105,6 +77,14 @@ export const CREATE_CHAT = gql` | |
} | ||
`; | ||
|
||
export const MARK_CHAT_MESSAGES_AS_READ = gql` | ||
mutation markChatMessagesAsRead($chatId: ID!, $userId: ID!) { | ||
markChatMessagesAsRead(chatId: $chatId, userId: $userId) { | ||
_id | ||
} | ||
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider expanding the mutation return fields. The mutation currently returns only the markChatMessagesAsRead(chatId: $chatId, userId: $userId) {
_id
+ updatedAt
+ isRead
}
|
||
} | ||
`; | ||
|
||
export const SEND_MESSAGE_TO_CHAT = gql` | ||
mutation sendMessageToChat( | ||
$chatId: ID! | ||
|
@@ -178,6 +158,7 @@ export const MESSAGE_SENT_TO_CHAT = gql` | |
} | ||
updatedAt | ||
} | ||
type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification The 'type' field in the subscription needs to be documented in the schema The
🔗 Analysis chainDocument the purpose of the 'type' field. The new 'type' field has been added to the subscription, but its purpose and possible values are not documented. Let's check the GraphQL schema for the possible values of this field: Let me search for more context about the type field in the codebase: Let me check the actual content of those files that might contain message type definitions: Let me check the subscription definition in the mutations file: Let me check the schema for the message type field: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for the Message type definition and possible type values
rg -A 10 "type Message" || rg -A 10 "enum MessageType"
Length of output: 663 Script: #!/bin/bash
# Search for message type related fields or enums in the schema
rg -l "type.*Message|enum.*Message"
# Search for type field usage in mutations/subscriptions
rg -A 5 "type:.*Message" || rg -A 5 "type.*Message.*subscription"
# Look for message type related constants or enums in the codebase
rg -A 5 "MessageType|MESSAGE_TYPE"
Length of output: 241 Script: #!/bin/bash
# Check content of the identified files for message type related code
echo "=== ChatRoom.tsx ===="
cat src/components/UserPortal/ChatRoom/ChatRoom.tsx
echo -e "\n=== Chat.tsx ===="
cat src/screens/UserPortal/Chat/Chat.tsx
# Also check the subscription definition
echo -e "\n=== Subscription definition ===="
rg -A 10 "MESSAGE_SENT_TO_CHAT" schema.graphql
Length of output: 24582 Script: #!/bin/bash
# Check the mutation file for MESSAGE_SENT_TO_CHAT subscription
cat src/GraphQl/Mutations/OrganizationMutations.ts
Length of output: 5999 Script: #!/bin/bash
# Look for message type related enums or type definitions in schema
rg -B 5 -A 5 "type Message|enum.*Message|type.*message" schema.graphql
Length of output: 386 |
||
sender { | ||
_id | ||
firstName | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ export const CHAT_BY_ID = gql` | |
lastName | ||
} | ||
unseenMessagesByUsers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the search results, I can now provide a final response about the type information for The type for From the codebase analysis:
🔗 Analysis chainConsider adding type information for unseenMessagesByUsers. The type of Let's verify the type definition in the schema: Also applies to: 191-191 Let me search for the GraphQL schema definition to understand the type information better. Let me try to read the schema file directly and look for Chat type definitions. Let me check the TypeScript interfaces or types since we found the Chat types but not the unseenMessagesByUsers field. Let me try one more search without file type restriction since the typescript flag isn't working. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for type definitions related to unseenMessagesByUsers
rg -A 5 "type.*Chat.*{"
rg "unseenMessagesByUsers"
Length of output: 10851 Script: #!/bin/bash
# Search for GraphQL schema files and type definitions
fd schema.graphql
fd "schema.*" --extension graphql
rg -A 5 "type.*Chat" --type graphql
Length of output: 155 Script: #!/bin/bash
# Read the schema file and look for Chat type definitions
cat schema.graphql | grep -A 10 "type.*Chat"
# Also search for unseenMessagesByUsers in the schema
cat schema.graphql | grep -A 3 -B 3 "unseenMessagesByUsers"
Length of output: 1470 Script: #!/bin/bash
# Search for TypeScript interfaces or types related to Chat
rg -t typescript "interface.*Chat|type.*Chat" -A 10
# Search for unseenMessagesByUsers in TypeScript files
rg -t typescript "unseenMessagesByUsers.*:" -A 2
Length of output: 174 Script: #!/bin/bash
# Search for TypeScript interfaces or types related to Chat
rg "interface.*Chat|type.*Chat" --type ts -A 10
# Look at the actual usage of unseenMessagesByUsers in the code
rg "unseenMessagesByUsers.*:" -B 2 -A 2
Length of output: 45404 |
||
} | ||
} | ||
`; | ||
|
@@ -187,6 +188,7 @@ export const CHATS_LIST = gql` | |
image | ||
} | ||
unseenMessagesByUsers | ||
} | ||
} | ||
`; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Missing read status tracking fields in Chat and ChatMessage types
The mutation
markChatMessagesAsRead
is added but the schema doesn't have the necessary fields to track message read status. The Chat and ChatMessage types should include fields to store which messages have been read by which users.Suggested additions needed:
readBy: [User!]
)🔗 Analysis chain
LGTM! Added mutation for marking messages as read.
The new mutation properly handles message read status tracking by taking both chatId and userId parameters, which is essential for multi-user chat scenarios.
Let's verify the mutation is properly integrated with the Chat type:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 72
Script:
Length of output: 425
Script:
Length of output: 93