@@ -2,7 +2,27 @@ import { gql } from "@apollo/client";
|
||||
|
||||
export const UNREAD_CONVERSATION_COUNT = gql`
|
||||
query UNREAD_CONVERSATION_COUNT {
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false } }) {
|
||||
# How many conversations have at least one unread inbound, non-system message
|
||||
conversations_aggregate(
|
||||
where: {
|
||||
archived: { _eq: false }
|
||||
messages: { read: { _eq: false }, isoutbound: { _eq: false }, is_system: { _eq: false } }
|
||||
}
|
||||
) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
}
|
||||
|
||||
# How many unread inbound, non-system messages exist (excluding archived conversations)
|
||||
messages_aggregate(
|
||||
where: {
|
||||
read: { _eq: false }
|
||||
isoutbound: { _eq: false }
|
||||
is_system: { _eq: false }
|
||||
conversation: { archived: { _eq: false } }
|
||||
}
|
||||
) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
@@ -19,7 +39,7 @@ export const CONVERSATION_LIST_QUERY = gql`
|
||||
unreadcnt
|
||||
archived
|
||||
label
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false } }) {
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false }, is_system: { _eq: false } }) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
@@ -41,6 +61,7 @@ export const CONVERSATION_SUBSCRIPTION_BY_PK = gql`
|
||||
subscription CONVERSATION_SUBSCRIPTION_BY_PK($conversationId: uuid!) {
|
||||
messages(order_by: { created_at: asc_nulls_first }, where: { conversationid: { _eq: $conversationId } }) {
|
||||
id
|
||||
conversationid
|
||||
status
|
||||
text
|
||||
is_system
|
||||
@@ -76,6 +97,7 @@ export const GET_CONVERSATION_DETAILS = gql`
|
||||
}
|
||||
messages(order_by: { created_at: asc_nulls_first }) {
|
||||
id
|
||||
conversationid
|
||||
status
|
||||
text
|
||||
is_system
|
||||
@@ -110,7 +132,7 @@ export const CONVERSATION_ID_BY_PHONE = gql`
|
||||
ro_number
|
||||
}
|
||||
}
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false } }) {
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false }, is_system: { _eq: false } }) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
@@ -139,7 +161,7 @@ export const CREATE_CONVERSATION = gql`
|
||||
ro_number
|
||||
}
|
||||
}
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false } }) {
|
||||
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false }, is_system: { _eq: false } }) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user