Skip to content

Commit

Permalink
Reply functionality for Group Chat and DirectChat (#2142)
Browse files Browse the repository at this point in the history
* Initial commit

* Updated the UI of chat screen

* feat: added support to create group chat

* implemented group chats

* Implemented logic to send messages in group chat

* refactor chat functionality

* fix format

* refactor code

* fix failing tests

* removed unwanted code

* fix: formatting issues and reverted unwanted changes

* removed unwanted code

* implemented reply functionality for direct chat

* implemented reply functionality

* added test cases

* fix: test cases

* added test cases

* feat: improved code coverage

* fix: failed test cases

* fix: failed test cases

* improved code coverage

* fix: minor issues

* removed unused imports

* fix: variable name

* fix: confilts

* fix: formatting issues

* fix: type errors

* fix: failing test cases

* fix: failing tests
  • Loading branch information
disha1202 authored Oct 21, 2024
1 parent 036b92e commit ca7c569
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 445 deletions.
125 changes: 0 additions & 125 deletions src/GraphQl/Mutations/OrganizationMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,93 +110,11 @@ export const SEND_MESSAGE_TO_CHAT = gql`
$chatId: ID!
$replyTo: ID
$messageContent: String!
$type: String!
) {
sendMessageToChat(
chatId: $chatId
replyTo: $replyTo
messageContent: $messageContent
type: $type
) {
_id
createdAt
messageContent
replyTo {
_id
createdAt
messageContent
sender {
_id
firstName
lastName
}
updatedAt
}
sender {
_id
firstName
lastName
}
updatedAt
}
}
`;

export const SEND_MESSAGE_TO_DIRECT_CHAT = gql`
mutation sendMessageToDirectChat(
$chatId: ID!
$replyTo: ID
$messageContent: String!
) {
sendMessageToDirectChat(
chatId: $chatId
replyTo: $replyTo
messageContent: $messageContent
) {
_id
createdAt
messageContent
replyTo {
_id
createdAt
messageContent
receiver {
_id
firstName
lastName
}
sender {
_id
firstName
lastName
}
updatedAt
}
receiver {
_id
firstName
lastName
}
sender {
_id
firstName
lastName
}
updatedAt
}
}
`;

export const SEND_MESSAGE_TO_GROUP_CHAT = gql`
mutation sendMessageToGroupChat(
$chatId: ID!
$replyTo: ID
$messageContent: String!
) {
sendMessageToGroupChat(
chatId: $chatId
replyTo: $replyTo
messageContent: $messageContent
) {
_id
createdAt
Expand Down Expand Up @@ -240,30 +158,6 @@ export const CREATE_MESSAGE_CHAT = gql`
}
`;

export const MESSAGE_SENT_TO_DIRECT_CHAT = gql`
subscription messageSentToDirectChat($userId: ID!) {
messageSentToDirectChat(userId: $userId) {
_id
createdAt
directChatMessageBelongsTo {
_id
}
messageContent
receiver {
_id
firstName
lastName
}
sender {
_id
firstName
lastName
}
updatedAt
}
}
`;

export const MESSAGE_SENT_TO_CHAT = gql`
subscription messageSentToChat($userId: ID!) {
messageSentToChat(userId: $userId) {
Expand All @@ -284,7 +178,6 @@ export const MESSAGE_SENT_TO_CHAT = gql`
}
updatedAt
}
type
sender {
_id
firstName
Expand All @@ -295,24 +188,6 @@ export const MESSAGE_SENT_TO_CHAT = gql`
}
`;

export const MESSAGE_SENT_TO_GROUP_CHAT = gql`
subscription messageSentToGroupChat($userId: ID!) {
messageSentToGroupChat(userId: $userId) {
_id
createdAt
groupChatMessageBelongsTo {
_id
}
messageContent
sender {
_id
firstName
lastName
}
updatedAt
}
}
`;
//Plugin WebSocket listner

/**
Expand Down
198 changes: 0 additions & 198 deletions src/GraphQl/Queries/PlugInQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,83 +108,6 @@ export const ORGANIZATION_EVENTS_CONNECTION = gql`

// directChatsMessagesByChatID(id: ID!): [DirectChatMessage]

export const DIRECT_CHAT_MESSAGES_BY_CHAT_ID = gql`
query directChatsMessagesByChatID($id: ID!) {
directChatsMessagesByChatID(id: $id) {
_id
createdAt
messageContent
receiver {
_id
firstName
lastName
email
image
}
sender {
_id
firstName
lastName
email
image
}
}
}
`;

export const DIRECT_CHAT_BY_ID = gql`
query directChatById($id: ID!) {
directChatById(id: $id) {
_id
createdAt
messages {
_id
createdAt
messageContent
replyTo {
_id
createdAt
messageContent
receiver {
_id
firstName
lastName
email
image
}
sender {
_id
firstName
lastName
email
image
}
}
receiver {
_id
firstName
lastName
email
image
}
sender {
_id
firstName
lastName
email
image
}
}
users {
_id
firstName
lastName
email
}
}
}
`;

export const CHAT_BY_ID = gql`
query chatById($id: ID!) {
chatById(id: $id) {
Expand All @@ -195,47 +118,6 @@ export const CHAT_BY_ID = gql`
_id
}
createdAt
messages {
_id
createdAt
messageContent
replyTo {
_id
createdAt
messageContent
type
sender {
_id
firstName
lastName
email
image
}
}
sender {
_id
firstName
lastName
email
image
}
}
users {
_id
firstName
lastName
email
}
}
}
`;

export const GROUP_CHAT_BY_ID = gql`
query groupChatById($id: ID!) {
groupChatById(id: $id) {
_id
createdAt
title
messages {
_id
createdAt
Expand Down Expand Up @@ -265,7 +147,6 @@ export const GROUP_CHAT_BY_ID = gql`
firstName
lastName
email
image
}
}
}
Expand All @@ -278,43 +159,6 @@ export const CHATS_LIST = gql`
isGroup
name
creator {
_id
firstName
lastName
email
}
messages {
_id
type
createdAt
messageContent
sender {
_id
firstName
lastName
email
}
}
organization {
_id
name
}
users {
_id
firstName
lastName
email
image
}
}
}
`;

export const DIRECT_CHATS_LIST = gql`
query DirectChatsByUserID($id: ID!) {
directChatsByUserID(id: $id) {
_id
creator {
_id
firstName
Expand All @@ -325,12 +169,6 @@ export const DIRECT_CHATS_LIST = gql`
_id
createdAt
messageContent
receiver {
_id
firstName
lastName
email
}
sender {
_id
firstName
Expand All @@ -353,42 +191,6 @@ export const DIRECT_CHATS_LIST = gql`
}
`;

export const GROUP_CHAT_LIST = gql`
query GroupChatsByUserID($id: ID!) {
groupChatsByUserId(id: $id) {
_id
creator {
_id
firstName
lastName
email
}
title
messages {
_id
createdAt
messageContent
sender {
_id
firstName
lastName
email
}
}
organization {
_id
name
}
users {
_id
firstName
lastName
email
image
}
}
}
`;
/**
* GraphQL query to check if an organization is a sample organization.
*
Expand Down
Loading

0 comments on commit ca7c569

Please sign in to comment.