Skip to content
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(webapp): show last message and unread count in room list #6595

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/src/graphql/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const messageQuery = () => {
indexId
content
senderId
author {
id
}
username
avatar
date
Expand Down
2 changes: 2 additions & 0 deletions backend/src/graphql/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const createRoomMutation = () => {
roomName
lastMessageAt
unreadCount
#avatar
ulfgebhardt marked this conversation as resolved.
Show resolved Hide resolved
users {
_id
id
Expand All @@ -29,6 +30,7 @@ export const roomQuery = () => {
id
roomId
roomName
avatar
lastMessageAt
unreadCount
lastMessage {
Expand Down
22 changes: 11 additions & 11 deletions webapp/graphql/Messages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import gql from 'graphql-tag'

export const createMessageMutation = () => {
return gql`
mutation ($roomId: ID!, $content: String!) {
CreateMessage(roomId: $roomId, content: $content) {
id
content
}
}
`
}

export const messageQuery = () => {
return gql`
query ($roomId: ID!, $first: Int, $offset: Int) {
Expand All @@ -23,17 +34,6 @@ export const messageQuery = () => {
`
}

export const createMessageMutation = () => {
return gql`
mutation ($roomId: ID!, $content: String!) {
CreateMessage(roomId: $roomId, content: $content) {
id
content
}
}
`
}

export const chatMessageAdded = () => {
return gql`
subscription chatMessageAdded($userId: ID!) {
Expand Down
32 changes: 23 additions & 9 deletions webapp/graphql/Rooms.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
import gql from 'graphql-tag'

export const createRoom = () => gql`
mutation ($userId: ID!) {
CreateRoom(userId: $userId) {
id
roomId
}
}
`

export const roomQuery = () => gql`
query Room($first: Int, $offset: Int, $id: ID) {
Room(first: $first, offset: $offset, id: $id, orderBy: lastMessageAt_desc) {
id
roomId
roomName
avatar
lastMessageAt
unreadCount
lastMessage {
_id
id
content
senderId
username
avatar
date
saved
distributed
seen
}
users {
_id
id
Expand All @@ -19,15 +42,6 @@ export const roomQuery = () => gql`
}
`

export const createRoom = () => gql`
mutation ($userId: ID!) {
CreateRoom(userId: $userId) {
id
roomId
}
}
`

export const unreadRoomsQuery = () => {
return gql`
query {
Expand Down