From 0b42497ad7366047428b8e819ffc685461081ba8 Mon Sep 17 00:00:00 2001 From: Philipp Schmitt Date: Mon, 20 Jan 2025 16:25:37 +0100 Subject: [PATCH 1/4] BA-2054 removing a member --- ...RoomParticipantsPaginationQuery.graphql.ts | 17 +- .../__generated__/ChatRoomQuery.graphql.ts | 118 +++--- .../__generated__/ChatRoomsQuery.graphql.ts | 303 ++++--------- .../CreateChatRoomMutation.graphql.ts | 311 ++++---------- .../GroupDetailsQuery.graphql.ts | 111 +++-- .../GroupTitleFragment.graphql.ts | 86 ++++ .../LastMessageFragment.graphql.ts | 80 ++++ .../MembersListFragment.graphql.ts | 18 +- .../ReadMessagesMutation.graphql.ts | 372 +--------------- .../__generated__/RoomFragment.graphql.ts | 157 +++---- ...raphql.ts => RoomTitleFragment.graphql.ts} | 102 ++--- .../RoomsListFragment.graphql.ts | 22 +- .../__generated__/TitleFragment.graphql.ts | 62 +++ .../UnreadChatMutation.graphql.ts | 62 ++- .../UnreadMessagesCountFragment.graphql.ts | 75 ++++ .../UpdateChatRoomMutation.graphql.ts | 397 +++++++----------- .../chatRoomsPaginationQuery.graphql.ts | 339 +++++---------- .../useRoomListSubscription.graphql.ts | 375 +++++++---------- .../ChatRoom/ChatRoomHeader/index.tsx | 9 +- .../messages/ChatRoom/ChatRoomHeader/types.ts | 5 +- .../modules/messages/ChatRoom/index.tsx | 3 +- .../ChatRoomsList/ChatRoomItem/index.tsx | 56 ++- .../ChatRoomsList/ChatRoomItem/types.ts | 9 +- .../modules/messages/ChatRoomsList/index.tsx | 8 +- .../ChatRoomListItem/index.tsx | 2 + .../modules/messages/CreateGroup/index.tsx | 2 + .../modules/messages/EditGroup/index.tsx | 30 +- .../modules/messages/EditGroup/types.ts | 3 +- .../ProfileCard/AdminOptionsMenu/index.tsx | 13 +- .../ProfileCard/AdminOptionsMenu/types.ts | 4 +- .../GroupDetails/ProfileCard/index.tsx | 28 +- .../GroupDetails/ProfileCard/types.ts | 10 +- .../modules/messages/GroupDetails/index.tsx | 142 +++++-- .../modules/messages/GroupDetails/types.ts | 4 - .../MessagesGroup/MessageItem/index.tsx | 2 +- .../modules/messages/MessagesList/index.tsx | 2 +- .../messages/graphql/fragments/GroupTitle.ts | 11 + .../messages/graphql/fragments/LastMessage.ts | 12 + .../{queries => fragments}/MembersList.ts | 2 +- .../{queries => fragments}/MessageItem.ts | 0 .../{queries => fragments}/MessagesList.ts | 0 .../messages/graphql/fragments/Room.ts | 15 + .../RoomTitle.ts} | 13 +- .../{queries => fragments}/RoomsList.ts | 6 +- .../messages/graphql/fragments/Title.ts | 15 + .../graphql/fragments/UnreadMessagesCount.ts | 11 + .../graphql/mutations/CreateChatRoom.ts | 5 +- .../graphql/mutations/ReadMessages.ts | 6 +- .../messages/graphql/mutations/UnreadChat.ts | 5 +- .../graphql/mutations/UpdateChatRoom.ts | 10 +- .../messages/graphql/queries/ChatRoomQuery.ts | 3 +- .../graphql/queries/GroupDetailsQuery.ts | 6 +- .../modules/messages/graphql/queries/Room.ts | 18 - .../useMessageCountUpdateSubscription.tsx | 1 + .../useMessagesListSubscription.tsx | 2 +- .../subscriptions/useRoomListSubscription.tsx | 101 ++++- packages/components/modules/messages/index.ts | 21 +- packages/components/modules/messages/utils.ts | 51 ++- packages/components/package.json | 1 + packages/components/schema.graphql | 22 +- packages/graphql/config/environment.ts | 14 + packages/graphql/package.json | 1 + pnpm-lock.yaml | 228 +++++----- 63 files changed, 1722 insertions(+), 2197 deletions(-) create mode 100644 packages/components/__generated__/GroupTitleFragment.graphql.ts create mode 100644 packages/components/__generated__/LastMessageFragment.graphql.ts rename packages/components/__generated__/{ChatRoomHeaderFragment.graphql.ts => RoomTitleFragment.graphql.ts} (65%) create mode 100644 packages/components/__generated__/TitleFragment.graphql.ts create mode 100644 packages/components/__generated__/UnreadMessagesCountFragment.graphql.ts create mode 100644 packages/components/modules/messages/graphql/fragments/GroupTitle.ts create mode 100644 packages/components/modules/messages/graphql/fragments/LastMessage.ts rename packages/components/modules/messages/graphql/{queries => fragments}/MembersList.ts (97%) rename packages/components/modules/messages/graphql/{queries => fragments}/MessageItem.ts (100%) rename packages/components/modules/messages/graphql/{queries => fragments}/MessagesList.ts (100%) create mode 100644 packages/components/modules/messages/graphql/fragments/Room.ts rename packages/components/modules/messages/graphql/{queries/ChatRoomHeaderFragment.ts => fragments/RoomTitle.ts} (53%) rename packages/components/modules/messages/graphql/{queries => fragments}/RoomsList.ts (88%) create mode 100644 packages/components/modules/messages/graphql/fragments/Title.ts create mode 100644 packages/components/modules/messages/graphql/fragments/UnreadMessagesCount.ts delete mode 100644 packages/components/modules/messages/graphql/queries/Room.ts diff --git a/packages/components/__generated__/ChatRoomParticipantsPaginationQuery.graphql.ts b/packages/components/__generated__/ChatRoomParticipantsPaginationQuery.graphql.ts index b9f1ccce..1fe20371 100644 --- a/packages/components/__generated__/ChatRoomParticipantsPaginationQuery.graphql.ts +++ b/packages/components/__generated__/ChatRoomParticipantsPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -161,6 +161,7 @@ const node: ConcreteRequest = (function () { name: 'node', plural: false, selections: [ + v3 /*: any*/, { alias: null, args: null, @@ -235,7 +236,6 @@ const node: ConcreteRequest = (function () { name: 'role', storageKey: null, }, - v3 /*: any*/, v2 /*: any*/, ], storageKey: null, @@ -275,13 +275,6 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, ], storageKey: null, }, @@ -304,16 +297,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '8962f61a90250e6d4d8d42f1dc7cc320', + cacheID: '8cb8f1bdc2aa4700b94a7e47557c0da4', id: null, metadata: {}, name: 'ChatRoomParticipantsPaginationQuery', operationKind: 'query', - text: 'query ChatRoomParticipantsPaginationQuery(\n $count: Int = 5\n $cursor: String\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...MembersListFragment_1G22uz\n id\n }\n}\n\nfragment MembersListFragment_1G22uz on ChatRoom {\n id\n participants(first: $count, after: $cursor) {\n edges {\n node {\n profile {\n id\n ...ProfileItemFragment\n }\n role\n id\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n totalCount\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n', + text: 'query ChatRoomParticipantsPaginationQuery(\n $count: Int = 5\n $cursor: String\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...MembersListFragment_1G22uz\n id\n }\n}\n\nfragment MembersListFragment_1G22uz on ChatRoom {\n id\n participants(first: $count, after: $cursor) {\n edges {\n node {\n id\n profile {\n id\n ...ProfileItemFragment\n }\n role\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n', }, } })() -;(node as any).hash = '4aad0edd43aec1e87daea42f647a59d3' +;(node as any).hash = '49f7bb8685111dd9a1075b9147c84abb' export default node diff --git a/packages/components/__generated__/ChatRoomQuery.graphql.ts b/packages/components/__generated__/ChatRoomQuery.graphql.ts index bf120318..7a6ae13c 100644 --- a/packages/components/__generated__/ChatRoomQuery.graphql.ts +++ b/packages/components/__generated__/ChatRoomQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<4397d26af79aa7dbd7fe435d3aa8d090>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -18,9 +18,8 @@ export type ChatRoomQuery$data = { readonly chatRoom: | { readonly id: string - readonly ' $fragmentSpreads': FragmentRefs< - 'ChatRoomHeaderFragment' | 'MessagesListFragment' - > + readonly participantsCount: number + readonly ' $fragmentSpreads': FragmentRefs<'MessagesListFragment' | 'TitleFragment'> } | null | undefined @@ -52,29 +51,29 @@ const node: ConcreteRequest = (function () { name: 'id', storageKey: null, }, - v3 = [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'url', - storageKey: null, - }, - ], - v4 = { + v3 = { alias: null, args: null, kind: 'ScalarField', - name: 'totalCount', + name: 'participantsCount', storageKey: null, }, - v5 = { + v4 = { alias: null, args: null, kind: 'ScalarField', name: 'name', storageKey: null, }, + v5 = [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'url', + storageKey: null, + }, + ], v6 = [ { kind: 'Literal', @@ -98,10 +97,11 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, + v3 /*: any*/, { args: null, kind: 'FragmentSpread', - name: 'ChatRoomHeaderFragment', + name: 'TitleFragment', }, { args: null, @@ -130,34 +130,7 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, - { - kind: 'Literal', - name: 'width', - value: 144, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v3 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', - storageKey: null, - }, + v3 /*: any*/, { alias: null, args: null, @@ -171,7 +144,7 @@ const node: ConcreteRequest = (function () { { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -179,7 +152,6 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v4 /*: any*/, { alias: null, args: null, @@ -205,7 +177,7 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - v5 /*: any*/, + v4 /*: any*/, { alias: null, args: [ @@ -224,7 +196,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v3 /*: any*/, + selections: v5 /*: any*/, storageKey: 'image(height:100,width:100)', }, ], @@ -238,7 +210,35 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', + }, + { + alias: null, + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v5 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, }, { alias: null, @@ -274,7 +274,13 @@ const node: ConcreteRequest = (function () { name: 'allMessages', plural: false, selections: [ - v4 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'totalCount', + storageKey: null, + }, { alias: null, args: null, @@ -308,7 +314,7 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - v5 /*: any*/, + v4 /*: any*/, { alias: null, args: [ @@ -327,7 +333,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v3 /*: any*/, + selections: v5 /*: any*/, storageKey: 'image(height:32,width:32)', }, ], @@ -441,16 +447,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '7fb10eae239d3ac574a1c385e51dce5b', + cacheID: '418e1900e952253a01398308df1c9875', id: null, metadata: {}, name: 'ChatRoomQuery', operationKind: 'query', - text: 'query ChatRoomQuery(\n $roomId: ID!\n) {\n chatRoom(id: $roomId) {\n id\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n', + text: 'query ChatRoomQuery(\n $roomId: ID!\n) {\n chatRoom(id: $roomId) {\n id\n participantsCount\n ...TitleFragment\n ...MessagesListFragment\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n', }, } })() -;(node as any).hash = 'f4a1b2a556f517a2f2e3016bfb38f7b5' +;(node as any).hash = '998cbccbc4fba49d248f69c77ca826fd' export default node diff --git a/packages/components/__generated__/ChatRoomsQuery.graphql.ts b/packages/components/__generated__/ChatRoomsQuery.graphql.ts index 6b9fb309..fcc30c73 100644 --- a/packages/components/__generated__/ChatRoomsQuery.graphql.ts +++ b/packages/components/__generated__/ChatRoomsQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<5c7c8b48fa68485c737bbcfbb826aafd>> + * @generated SignedSource<<8ef0beddf36004152e35b57685261dd0>> * @lightSyntaxTransform * @nogrep */ @@ -55,13 +55,6 @@ const node: ConcreteRequest = (function () { }, ], v3 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - v4 = { alias: null, args: null, concreteType: 'PageInfo', @@ -86,14 +79,14 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v5 = { + v4 = { alias: null, args: null, kind: 'ScalarField', name: 'name', storageKey: null, }, - v6 = [ + v5 = [ { alias: null, args: null, @@ -102,7 +95,7 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - v7 = { + v6 = { alias: null, args: [ { @@ -120,24 +113,24 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v6 /*: any*/, + selections: v5 /*: any*/, storageKey: 'image(height:100,width:100)', }, - v8 = { + v7 = { alias: null, args: null, kind: 'ScalarField', name: '__typename', storageKey: null, }, - v9 = { + v8 = { alias: null, args: null, kind: 'ScalarField', name: 'cursor', storageKey: null, }, - v10 = [ + v9 = [ { kind: 'Literal', name: 'archived', @@ -146,22 +139,13 @@ const node: ConcreteRequest = (function () { v1 /*: any*/, { kind: 'Literal', - name: 'unreadMessages', - value: false, + name: 'q', + value: '', }, - ], - v11 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, - v12 = [ { kind: 'Literal', - name: 'first', - value: 20, + name: 'unreadMessages', + value: false, }, ] return { @@ -223,8 +207,14 @@ const node: ConcreteRequest = (function () { name: 'allProfiles', plural: false, selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'totalCount', + storageKey: null, + }, v3 /*: any*/, - v4 /*: any*/, { alias: null, args: null, @@ -242,8 +232,8 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v0 /*: any*/, - v5 /*: any*/, - v7 /*: any*/, + v4 /*: any*/, + v6 /*: any*/, { alias: null, args: null, @@ -263,11 +253,11 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v8 /*: any*/, + v7 /*: any*/, ], storageKey: null, }, - v9 /*: any*/, + v8 /*: any*/, ], storageKey: null, }, @@ -306,7 +296,7 @@ const node: ConcreteRequest = (function () { selections: [ { alias: null, - args: v10 /*: any*/, + args: v9 /*: any*/, concreteType: 'ChatRoomConnection', kind: 'LinkedField', name: 'chatRooms', @@ -329,32 +319,6 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v0 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v0 /*: any*/, - ], - storageKey: null, - }, { alias: null, args: null, @@ -369,35 +333,16 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v0 /*: any*/, v11 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, + selections: [ + v0 /*: any*/, { - kind: 'Literal', - name: 'width', - value: 144, + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, }, ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v6 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', storageKey: null, }, { @@ -409,13 +354,18 @@ const node: ConcreteRequest = (function () { }, { alias: null, - args: [v1 /*: any*/], + args: [ + { + kind: 'Literal', + name: 'first', + value: 2, + }, + ], concreteType: 'ChatRoomParticipantConnection', kind: 'LinkedField', name: 'participants', plural: false, selections: [ - v3 /*: any*/, { alias: null, args: null, @@ -441,8 +391,8 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v0 /*: any*/, - v5 /*: any*/, - v7 /*: any*/, + v4 /*: any*/, + v6 /*: any*/, ], storageKey: null, }, @@ -454,150 +404,77 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', }, { alias: null, - args: v12 /*: any*/, - concreteType: 'MessageConnection', + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v5 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'UnreadMessageCount', kind: 'LinkedField', - name: 'allMessages', + name: 'unreadMessages', plural: false, selections: [ - v3 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v0 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v0 /*: any*/, - v5 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v6 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v11 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v0 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - v8 /*: any*/, - ], - storageKey: null, - }, - v9 /*: any*/, - ], + kind: 'ScalarField', + name: 'count', storageKey: null, }, - v4 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'markedUnread', + storageKey: null, + }, + v0 /*: any*/, ], - storageKey: 'allMessages(first:20)', - }, - { - alias: null, - args: v12 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + storageKey: null, }, - v8 /*: any*/, + v7 /*: any*/, ], storageKey: null, }, - v9 /*: any*/, + v8 /*: any*/, ], storageKey: null, }, - v4 /*: any*/, + v3 /*: any*/, ], - storageKey: 'chatRooms(archived:false,first:5,unreadMessages:false)', + storageKey: 'chatRooms(archived:false,first:5,q:"",unreadMessages:false)', }, { alias: null, - args: v10 /*: any*/, + args: v9 /*: any*/, filters: ['q', 'unreadMessages', 'archived'], handle: 'connection', key: 'roomsList_chatRooms', @@ -617,12 +494,12 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '5bf319d6b9c8e3e09069eb00258d1e21', + cacheID: 'b7aec8f21dba53c91ee4320c81d17a52', id: null, metadata: {}, name: 'ChatRoomsQuery', operationKind: 'query', - text: 'query ChatRoomsQuery {\n ...AllProfilesListFragment\n me {\n id\n profile {\n id\n ...RoomsListFragment\n }\n }\n}\n\nfragment AllProfilesListFragment on Query {\n allProfiles(first: 5, orderBy: "-created") {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n id\n ...ProfileItemFragment\n __typename\n }\n cursor\n }\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: 5, unreadMessages: false, archived: false) {\n edges {\n node {\n id\n ...RoomFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n id\n}\n', + text: 'query ChatRoomsQuery {\n ...AllProfilesListFragment\n me {\n id\n profile {\n id\n ...RoomsListFragment\n }\n }\n}\n\nfragment AllProfilesListFragment on Query {\n allProfiles(first: 5, orderBy: "-created") {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n id\n ...ProfileItemFragment\n __typename\n }\n cursor\n }\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment LastMessageFragment on ChatRoom {\n id\n lastMessageTime\n lastMessage {\n id\n content\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment RoomsListFragment on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: 5, q: "", unreadMessages: false, archived: false) {\n edges {\n node {\n id\n ...LastMessageFragment\n ...TitleFragment\n ...UnreadMessagesCountFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n id\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() diff --git a/packages/components/__generated__/CreateChatRoomMutation.graphql.ts b/packages/components/__generated__/CreateChatRoomMutation.graphql.ts index 795acd18..8abb12a1 100644 --- a/packages/components/__generated__/CreateChatRoomMutation.graphql.ts +++ b/packages/components/__generated__/CreateChatRoomMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<364ec1cd3393126f102a67586debe78f>> + * @generated SignedSource<<50f38d77bf34b9af4a05c8f95b5bf9e0>> * @lightSyntaxTransform * @nogrep */ @@ -41,7 +41,9 @@ export type CreateChatRoomMutation$data = { readonly node: | { readonly id: string - readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> + readonly ' $fragmentSpreads': FragmentRefs< + 'LastMessageFragment' | 'TitleFragment' | 'UnreadMessagesCountFragment' + > } | null | undefined @@ -107,14 +109,7 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v5 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, - v6 = [ + v5 = [ { alias: null, args: null, @@ -122,27 +117,6 @@ const node: ConcreteRequest = (function () { name: 'url', storageKey: null, }, - ], - v7 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - v8 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'name', - storageKey: null, - }, - v9 = [ - { - kind: 'Literal', - name: 'first', - value: 20, - }, ] return { fragment: { @@ -179,7 +153,17 @@ const node: ConcreteRequest = (function () { { args: null, kind: 'FragmentSpread', - name: 'RoomFragment', + name: 'LastMessageFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'TitleFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'UnreadMessagesCountFragment', }, ], storageKey: null, @@ -226,32 +210,6 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v3 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v3 /*: any*/, - ], - storageKey: null, - }, { alias: null, args: null, @@ -266,35 +224,16 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v3 /*: any*/, v5 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, + selections: [ + v3 /*: any*/, { - kind: 'Literal', - name: 'width', - value: 144, + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, }, ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v6 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', storageKey: null, }, { @@ -310,7 +249,7 @@ const node: ConcreteRequest = (function () { { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -318,7 +257,6 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v7 /*: any*/, { alias: null, args: null, @@ -344,7 +282,13 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v3 /*: any*/, - v8 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'name', + storageKey: null, + }, { alias: null, args: [ @@ -363,7 +307,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v6 /*: any*/, + selections: v5 /*: any*/, storageKey: 'image(height:100,width:100)', }, ], @@ -377,170 +321,61 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', + }, + { + alias: null, + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v5 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, }, { alias: null, - args: v9 /*: any*/, - concreteType: 'MessageConnection', + args: null, + concreteType: 'UnreadMessageCount', kind: 'LinkedField', - name: 'allMessages', + name: 'unreadMessages', plural: false, selections: [ - v7 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v3 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v3 /*: any*/, - v8 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v6 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v5 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v3 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: '__typename', - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'cursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'count', storageKey: null, }, { alias: null, args: null, - concreteType: 'PageInfo', - kind: 'LinkedField', - name: 'pageInfo', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'hasNextPage', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'endCursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'markedUnread', storageKey: null, }, + v3 /*: any*/, ], - storageKey: 'allMessages(first:20)', - }, - { - alias: null, - args: v9 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + storageKey: null, }, ], storageKey: null, @@ -571,16 +406,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '7fe3711de74ea7163a4547c5a528ef6e', + cacheID: 'f180343b233d0cf61738ce2e0b866977', id: null, metadata: {}, name: 'CreateChatRoomMutation', operationKind: 'mutation', - text: 'mutation CreateChatRoomMutation(\n $input: ChatRoomCreateInput!\n) {\n chatRoomCreate(input: $input) {\n room {\n node {\n id\n ...RoomFragment\n }\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n', + text: 'mutation CreateChatRoomMutation(\n $input: ChatRoomCreateInput!\n) {\n chatRoomCreate(input: $input) {\n room {\n node {\n id\n ...LastMessageFragment\n ...TitleFragment\n ...UnreadMessagesCountFragment\n }\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment LastMessageFragment on ChatRoom {\n id\n lastMessageTime\n lastMessage {\n id\n content\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '5005ae78d2089bd950489282945277de' +;(node as any).hash = '304767b39c282d78401577a512369b3e' export default node diff --git a/packages/components/__generated__/GroupDetailsQuery.graphql.ts b/packages/components/__generated__/GroupDetailsQuery.graphql.ts index f68f5033..062cc975 100644 --- a/packages/components/__generated__/GroupDetailsQuery.graphql.ts +++ b/packages/components/__generated__/GroupDetailsQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<7adac7e29d44bc73844d4a4ef4d02d8e>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -18,14 +18,8 @@ export type GroupDetailsQuery$data = { readonly chatRoom: | { readonly id: string - readonly image: - | { - readonly url: string - } - | null - | undefined - readonly title: string | null | undefined - readonly ' $fragmentSpreads': FragmentRefs<'MembersListFragment'> + readonly participantsCount: number + readonly ' $fragmentSpreads': FragmentRefs<'GroupTitleFragment' | 'MembersListFragment'> } | null | undefined @@ -57,7 +51,14 @@ const node: ConcreteRequest = (function () { name: 'id', storageKey: null, }, - v3 = [ + v3 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'participantsCount', + storageKey: null, + }, + v4 = [ { alias: null, args: null, @@ -66,35 +67,7 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - v4 = { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, - { - kind: 'Literal', - name: 'width', - value: 144, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v3 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - v5 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', - storageKey: null, - }, - v6 = [ + v5 = [ { kind: 'Literal', name: 'first', @@ -117,8 +90,12 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - v4 /*: any*/, - v5 /*: any*/, + v3 /*: any*/, + { + args: null, + kind: 'FragmentSpread', + name: 'GroupTitleFragment', + }, { args: null, kind: 'FragmentSpread', @@ -146,11 +123,38 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - v4 /*: any*/, - v5 /*: any*/, + v3 /*: any*/, { alias: null, - args: v6 /*: any*/, + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v4 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: v5 /*: any*/, concreteType: 'ChatRoomParticipantConnection', kind: 'LinkedField', name: 'participants', @@ -172,6 +176,7 @@ const node: ConcreteRequest = (function () { name: 'node', plural: false, selections: [ + v2 /*: any*/, { alias: null, args: null, @@ -206,7 +211,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v3 /*: any*/, + selections: v4 /*: any*/, storageKey: 'image(height:100,width:100)', }, { @@ -238,7 +243,6 @@ const node: ConcreteRequest = (function () { name: 'role', storageKey: null, }, - v2 /*: any*/, { alias: null, args: null, @@ -284,19 +288,12 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, ], storageKey: 'participants(first:5)', }, { alias: null, - args: v6 /*: any*/, + args: v5 /*: any*/, filters: null, handle: 'connection', key: 'ChatRoom_participants', @@ -309,16 +306,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: 'a17bedc781c37b8ffa4bb803b1acefca', + cacheID: '6989f29aa2fb2a66b1bbaa0655b8371b', id: null, metadata: {}, name: 'GroupDetailsQuery', operationKind: 'query', - text: 'query GroupDetailsQuery(\n $roomId: ID!\n) {\n chatRoom(id: $roomId) {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n ...MembersListFragment\n }\n}\n\nfragment MembersListFragment on ChatRoom {\n id\n participants(first: 5) {\n edges {\n node {\n profile {\n id\n ...ProfileItemFragment\n }\n role\n id\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n totalCount\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n', + text: 'query GroupDetailsQuery(\n $roomId: ID!\n) {\n chatRoom(id: $roomId) {\n id\n participantsCount\n ...GroupTitleFragment\n ...MembersListFragment\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment MembersListFragment on ChatRoom {\n id\n participants(first: 5) {\n edges {\n node {\n id\n profile {\n id\n ...ProfileItemFragment\n }\n role\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment ProfileItemFragment on Profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n urlPath {\n path\n id\n }\n}\n', }, } })() -;(node as any).hash = '64b42456eb22d1caa9b7d4432d69ed00' +;(node as any).hash = '9ee8b8ab9e1dd4679a2b518e8193f1c2' export default node diff --git a/packages/components/__generated__/GroupTitleFragment.graphql.ts b/packages/components/__generated__/GroupTitleFragment.graphql.ts new file mode 100644 index 00000000..1ef7ed51 --- /dev/null +++ b/packages/components/__generated__/GroupTitleFragment.graphql.ts @@ -0,0 +1,86 @@ +/** + * @generated SignedSource<<2bee0b25aad7bd9395d4f3183680b1be>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ + +/* eslint-disable */ +// @ts-nocheck +import { Fragment, ReaderFragment } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' + +export type GroupTitleFragment$data = { + readonly id: string + readonly image: + | { + readonly url: string + } + | null + | undefined + readonly title: string | null | undefined + readonly ' $fragmentType': 'GroupTitleFragment' +} +export type GroupTitleFragment$key = { + readonly ' $data'?: GroupTitleFragment$data + readonly ' $fragmentSpreads': FragmentRefs<'GroupTitleFragment'> +} + +const node: ReaderFragment = { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'GroupTitleFragment', + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + }, + { + alias: null, + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'url', + storageKey: null, + }, + ], + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + ], + type: 'ChatRoom', + abstractKey: null, +} + +;(node as any).hash = 'ebf3753368c34b19880bd97c408df707' + +export default node diff --git a/packages/components/__generated__/LastMessageFragment.graphql.ts b/packages/components/__generated__/LastMessageFragment.graphql.ts new file mode 100644 index 00000000..a0dd18b3 --- /dev/null +++ b/packages/components/__generated__/LastMessageFragment.graphql.ts @@ -0,0 +1,80 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ + +/* eslint-disable */ +// @ts-nocheck +import { Fragment, ReaderFragment } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' + +export type LastMessageFragment$data = { + readonly id: string + readonly lastMessage: + | { + readonly content: string | null | undefined + readonly id: string + } + | null + | undefined + readonly lastMessageTime: any | null | undefined + readonly ' $fragmentType': 'LastMessageFragment' +} +export type LastMessageFragment$key = { + readonly ' $data'?: LastMessageFragment$data + readonly ' $fragmentSpreads': FragmentRefs<'LastMessageFragment'> +} + +const node: ReaderFragment = (function () { + var v0 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + } + return { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'LastMessageFragment', + selections: [ + v0 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'lastMessageTime', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'Message', + kind: 'LinkedField', + name: 'lastMessage', + plural: false, + selections: [ + v0 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, + }, + ], + storageKey: null, + }, + ], + type: 'ChatRoom', + abstractKey: null, + } +})() + +;(node as any).hash = '6aa67bb28e1946c5fb70f4ebf6213e7b' + +export default node diff --git a/packages/components/__generated__/MembersListFragment.graphql.ts b/packages/components/__generated__/MembersListFragment.graphql.ts index 9aba85e4..99c532f6 100644 --- a/packages/components/__generated__/MembersListFragment.graphql.ts +++ b/packages/components/__generated__/MembersListFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<4538f21a2c43f1393fe96f42f844c6a0>> + * @generated SignedSource<<7f07ba9c3e069b0f8d6d3e0c80d4963f>> * @lightSyntaxTransform * @nogrep */ @@ -11,6 +11,8 @@ import { ReaderFragment, RefetchableFragment } from 'relay-runtime' import { FragmentRefs } from 'relay-runtime' +export type ChatRoomParticipantRoles = 'ADMIN' | 'MEMBER' | '%future added value' + export type MembersListFragment$data = { readonly id: string readonly participants: @@ -19,6 +21,7 @@ export type MembersListFragment$data = { | { readonly node: | { + readonly id: string readonly profile: | { readonly id: string @@ -26,7 +29,7 @@ export type MembersListFragment$data = { } | null | undefined - readonly role: string | null | undefined + readonly role: ChatRoomParticipantRoles | null | undefined } | null | undefined @@ -38,7 +41,6 @@ export type MembersListFragment$data = { readonly endCursor: string | null | undefined readonly hasNextPage: boolean } - readonly totalCount: number | null | undefined } | null | undefined @@ -125,6 +127,7 @@ const node: ReaderFragment = (function () { name: 'node', plural: false, selections: [ + v1 /*: any*/, { alias: null, args: null, @@ -194,13 +197,6 @@ const node: ReaderFragment = (function () { ], storageKey: null, }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, ], storageKey: null, }, @@ -210,6 +206,6 @@ const node: ReaderFragment = (function () { } })() -;(node as any).hash = '4aad0edd43aec1e87daea42f647a59d3' +;(node as any).hash = '49f7bb8685111dd9a1075b9147c84abb' export default node diff --git a/packages/components/__generated__/ReadMessagesMutation.graphql.ts b/packages/components/__generated__/ReadMessagesMutation.graphql.ts index 7adfb4d8..0f90873b 100644 --- a/packages/components/__generated__/ReadMessagesMutation.graphql.ts +++ b/packages/components/__generated__/ReadMessagesMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<0e42194a05df9fad184303545a034de3>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -37,14 +37,7 @@ export type ReadMessagesMutation$data = { readonly room: | { readonly id: string - readonly unreadMessages: - | { - readonly count: number - readonly markedUnread: boolean - } - | null - | undefined - readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> + readonly ' $fragmentSpreads': FragmentRefs<'UnreadMessagesCountFragment'> } | null | undefined @@ -80,20 +73,6 @@ const node: ConcreteRequest = (function () { storageKey: null, }, v3 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - v4 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v5 = { alias: null, args: null, concreteType: 'ErrorType', @@ -117,44 +96,7 @@ const node: ConcreteRequest = (function () { }, ], storageKey: null, - }, - v6 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, - v7 = [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'url', - storageKey: null, - }, - ], - v8 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - v9 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'name', - storageKey: null, - }, - v10 = [ - { - kind: 'Literal', - name: 'first', - value: 20, - }, - ] + } return { fragment: { argumentDefinitions: v0 /*: any*/, @@ -179,25 +121,15 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v2 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [v3 /*: any*/, v4 /*: any*/], - storageKey: null, - }, { args: null, kind: 'FragmentSpread', - name: 'RoomFragment', + name: 'UnreadMessagesCountFragment', }, ], storageKey: null, }, - v5 /*: any*/, + v3 /*: any*/, ], storageKey: null, }, @@ -235,319 +167,45 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'unreadMessages', plural: false, - selections: [v3 /*: any*/, v4 /*: any*/, v2 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'lastMessageTime', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'lastMessage', - plural: false, - selections: [v2 /*: any*/, v6 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, - { - kind: 'Literal', - name: 'width', - value: 144, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v7 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isGroup', - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'first', - value: 5, - }, - ], - concreteType: 'ChatRoomParticipantConnection', - kind: 'LinkedField', - name: 'participants', - plural: false, - selections: [ - v8 /*: any*/, - { - alias: null, - args: null, - concreteType: 'ChatRoomParticipantEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'ChatRoomParticipant', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v2 /*: any*/, - v9 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 100, - }, - { - kind: 'Literal', - name: 'width', - value: 100, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v7 /*: any*/, - storageKey: 'image(height:100,width:100)', - }, - ], - storageKey: null, - }, - v2 /*: any*/, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: 'participants(first:5)', - }, - { - alias: null, - args: v10 /*: any*/, - concreteType: 'MessageConnection', - kind: 'LinkedField', - name: 'allMessages', - plural: false, selections: [ - v8 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v2 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v2 /*: any*/, - v9 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v7 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v6 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v2 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: '__typename', - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'cursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'count', storageKey: null, }, { alias: null, args: null, - concreteType: 'PageInfo', - kind: 'LinkedField', - name: 'pageInfo', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'hasNextPage', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'endCursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'markedUnread', storageKey: null, }, + v2 /*: any*/, ], - storageKey: 'allMessages(first:20)', - }, - { - alias: null, - args: v10 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + storageKey: null, }, ], storageKey: null, }, - v5 /*: any*/, + v3 /*: any*/, ], storageKey: null, }, ], }, params: { - cacheID: '100c02e0413e3dc1a5824d52f16eebb6', + cacheID: '4bebc93464740f3be7c5f5fdd1a3d6df', id: null, metadata: {}, name: 'ReadMessagesMutation', operationKind: 'mutation', - text: 'mutation ReadMessagesMutation(\n $input: ChatRoomReadMessagesInput!\n) {\n chatRoomReadMessages(input: $input) {\n room {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n ...RoomFragment\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n', + text: 'mutation ReadMessagesMutation(\n $input: ChatRoomReadMessagesInput!\n) {\n chatRoomReadMessages(input: $input) {\n room {\n id\n ...UnreadMessagesCountFragment\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '74e8ca248a5168c5ce8623b79103f75d' +;(node as any).hash = 'eeed77ccb23fc338a5f401cb106e66fb' export default node diff --git a/packages/components/__generated__/RoomFragment.graphql.ts b/packages/components/__generated__/RoomFragment.graphql.ts index 7f56ba2e..0f2a563c 100644 --- a/packages/components/__generated__/RoomFragment.graphql.ts +++ b/packages/components/__generated__/RoomFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<079ffe5d4b40e76be8d5e7e152e4e441>> + * @generated SignedSource<<8af33bd4cbd98a8efc5eb4bdfbc354d1>> * @lightSyntaxTransform * @nogrep */ @@ -13,22 +13,11 @@ import { FragmentRefs } from 'relay-runtime' export type RoomFragment$data = { readonly id: string - readonly lastMessage: - | { - readonly content: string | null | undefined - readonly id: string - } - | null - | undefined - readonly lastMessageTime: any | null | undefined - readonly unreadMessages: - | { - readonly count: number - readonly markedUnread: boolean - } - | null - | undefined - readonly ' $fragmentSpreads': FragmentRefs<'ChatRoomHeaderFragment' | 'MessagesListFragment'> + readonly isGroup: boolean + readonly participantsCount: number + readonly ' $fragmentSpreads': FragmentRefs< + 'LastMessageFragment' | 'MessagesListFragment' | 'TitleFragment' | 'UnreadMessagesCountFragment' + > readonly ' $fragmentType': 'RoomFragment' } export type RoomFragment$key = { @@ -36,88 +25,58 @@ export type RoomFragment$key = { readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> } -const node: ReaderFragment = (function () { - var v0 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'id', - storageKey: null, - } - return { - argumentDefinitions: [], - kind: 'Fragment', - metadata: null, - name: 'RoomFragment', - selections: [ - v0 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'lastMessageTime', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'lastMessage', - plural: false, - selections: [ - v0 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, - ], - storageKey: null, - }, - { - args: null, - kind: 'FragmentSpread', - name: 'ChatRoomHeaderFragment', - }, - { - args: null, - kind: 'FragmentSpread', - name: 'MessagesListFragment', - }, - ], - type: 'ChatRoom', - abstractKey: null, - } -})() +const node: ReaderFragment = { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'RoomFragment', + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'isGroup', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'participantsCount', + storageKey: null, + }, + { + args: null, + kind: 'FragmentSpread', + name: 'LastMessageFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'MessagesListFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'TitleFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'UnreadMessagesCountFragment', + }, + ], + type: 'ChatRoom', + abstractKey: null, +} -;(node as any).hash = '07844e29548083b80a887e96cfddd508' +;(node as any).hash = 'eaa59457c134fb1f7bad4797532926da' export default node diff --git a/packages/components/__generated__/ChatRoomHeaderFragment.graphql.ts b/packages/components/__generated__/RoomTitleFragment.graphql.ts similarity index 65% rename from packages/components/__generated__/ChatRoomHeaderFragment.graphql.ts rename to packages/components/__generated__/RoomTitleFragment.graphql.ts index 6a972a78..8ab59b6b 100644 --- a/packages/components/__generated__/ChatRoomHeaderFragment.graphql.ts +++ b/packages/components/__generated__/RoomTitleFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<2cd670197e6d509befc2130de4f31474>> * @lightSyntaxTransform * @nogrep */ @@ -11,15 +11,8 @@ import { Fragment, ReaderFragment } from 'relay-runtime' import { FragmentRefs } from 'relay-runtime' -export type ChatRoomHeaderFragment$data = { +export type RoomTitleFragment$data = { readonly id: string - readonly image: - | { - readonly url: string - } - | null - | undefined - readonly isGroup: boolean readonly participants: | { readonly edges: ReadonlyArray< @@ -46,84 +39,38 @@ export type ChatRoomHeaderFragment$data = { | null | undefined > - readonly totalCount: number | null | undefined } | null | undefined - readonly title: string | null | undefined - readonly ' $fragmentType': 'ChatRoomHeaderFragment' + readonly ' $fragmentType': 'RoomTitleFragment' } -export type ChatRoomHeaderFragment$key = { - readonly ' $data'?: ChatRoomHeaderFragment$data - readonly ' $fragmentSpreads': FragmentRefs<'ChatRoomHeaderFragment'> +export type RoomTitleFragment$key = { + readonly ' $data'?: RoomTitleFragment$data + readonly ' $fragmentSpreads': FragmentRefs<'RoomTitleFragment'> } const node: ReaderFragment = (function () { var v0 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'id', - storageKey: null, - }, - v1 = [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'url', - storageKey: null, - }, - ] + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + } return { argumentDefinitions: [], kind: 'Fragment', metadata: null, - name: 'ChatRoomHeaderFragment', + name: 'RoomTitleFragment', selections: [ v0 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, - { - kind: 'Literal', - name: 'width', - value: 144, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v1 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isGroup', - storageKey: null, - }, { alias: null, args: [ { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -131,13 +78,6 @@ const node: ReaderFragment = (function () { name: 'participants', plural: false, selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, { alias: null, args: null, @@ -188,7 +128,15 @@ const node: ReaderFragment = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v1 /*: any*/, + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'url', + storageKey: null, + }, + ], storageKey: 'image(height:100,width:100)', }, ], @@ -201,7 +149,7 @@ const node: ReaderFragment = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', }, ], type: 'ChatRoom', @@ -209,6 +157,6 @@ const node: ReaderFragment = (function () { } })() -;(node as any).hash = 'aefc48a15953094b0593795e3ce5ba37' +;(node as any).hash = '89160f172288e6c8c11de9207b13170b' export default node diff --git a/packages/components/__generated__/RoomsListFragment.graphql.ts b/packages/components/__generated__/RoomsListFragment.graphql.ts index 754c17ab..81f0fb50 100644 --- a/packages/components/__generated__/RoomsListFragment.graphql.ts +++ b/packages/components/__generated__/RoomsListFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -19,7 +19,9 @@ export type RoomsListFragment$data = { readonly node: | { readonly id: string - readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> + readonly ' $fragmentSpreads': FragmentRefs< + 'LastMessageFragment' | 'TitleFragment' | 'UnreadMessagesCountFragment' + > } | null | undefined @@ -69,7 +71,7 @@ const node: ReaderFragment = (function () { name: 'cursor', }, { - defaultValue: null, + defaultValue: '', kind: 'LocalArgument', name: 'q', }, @@ -152,7 +154,17 @@ const node: ReaderFragment = (function () { { args: null, kind: 'FragmentSpread', - name: 'RoomFragment', + name: 'LastMessageFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'TitleFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'UnreadMessagesCountFragment', }, { alias: null, @@ -209,6 +221,6 @@ const node: ReaderFragment = (function () { } })() -;(node as any).hash = '7fe57d53d40a4295a9eb2ea600d96f11' +;(node as any).hash = '3a66898cb96bbf4ce999aa5ad9822ca0' export default node diff --git a/packages/components/__generated__/TitleFragment.graphql.ts b/packages/components/__generated__/TitleFragment.graphql.ts new file mode 100644 index 00000000..799ba1a3 --- /dev/null +++ b/packages/components/__generated__/TitleFragment.graphql.ts @@ -0,0 +1,62 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ + +/* eslint-disable */ +// @ts-nocheck +import { Fragment, ReaderFragment } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' + +export type TitleFragment$data = { + readonly id: string + readonly isGroup: boolean + readonly ' $fragmentSpreads': FragmentRefs<'GroupTitleFragment' | 'RoomTitleFragment'> + readonly ' $fragmentType': 'TitleFragment' +} +export type TitleFragment$key = { + readonly ' $data'?: TitleFragment$data + readonly ' $fragmentSpreads': FragmentRefs<'TitleFragment'> +} + +const node: ReaderFragment = { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'TitleFragment', + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'isGroup', + storageKey: null, + }, + { + args: null, + kind: 'FragmentSpread', + name: 'RoomTitleFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'GroupTitleFragment', + }, + ], + type: 'ChatRoom', + abstractKey: null, +} + +;(node as any).hash = '0b053ad212f52bdfe86f56b46c3873bf' + +export default node diff --git a/packages/components/__generated__/UnreadChatMutation.graphql.ts b/packages/components/__generated__/UnreadChatMutation.graphql.ts index 1501215c..be824171 100644 --- a/packages/components/__generated__/UnreadChatMutation.graphql.ts +++ b/packages/components/__generated__/UnreadChatMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<5aa83cdec1d1f95ae9653aaf4fe87d36>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -9,6 +9,7 @@ /* eslint-disable */ // @ts-nocheck import { ConcreteRequest, Mutation } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' export type ChatRoomUnreadInput = { clientMutationId?: string | null | undefined @@ -35,13 +36,7 @@ export type UnreadChatMutation$data = { readonly room: | { readonly id: string - readonly unreadMessages: - | { - readonly count: number - readonly markedUnread: boolean - } - | null - | undefined + readonly ' $fragmentSpreads': FragmentRefs<'UnreadMessagesCountFragment'> } | null | undefined @@ -77,20 +72,6 @@ const node: ConcreteRequest = (function () { storageKey: null, }, v3 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - v4 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v5 = { alias: null, args: null, concreteType: 'ErrorType', @@ -140,19 +121,14 @@ const node: ConcreteRequest = (function () { selections: [ v2 /*: any*/, { - alias: null, args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [v3 /*: any*/, v4 /*: any*/], - storageKey: null, + kind: 'FragmentSpread', + name: 'UnreadMessagesCountFragment', }, ], storageKey: null, }, - v5 /*: any*/, + v3 /*: any*/, ], storageKey: null, }, @@ -190,29 +166,45 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'unreadMessages', plural: false, - selections: [v3 /*: any*/, v4 /*: any*/, v2 /*: any*/], + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'count', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'markedUnread', + storageKey: null, + }, + v2 /*: any*/, + ], storageKey: null, }, ], storageKey: null, }, - v5 /*: any*/, + v3 /*: any*/, ], storageKey: null, }, ], }, params: { - cacheID: 'a95fee2710fb461b830252379ad489f5', + cacheID: 'b5c9682f04c174e181c522db06feb0a5', id: null, metadata: {}, name: 'UnreadChatMutation', operationKind: 'mutation', - text: 'mutation UnreadChatMutation(\n $input: ChatRoomUnreadInput!\n) {\n chatRoomUnread(input: $input) {\n room {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n }\n errors {\n field\n messages\n }\n }\n}\n', + text: 'mutation UnreadChatMutation(\n $input: ChatRoomUnreadInput!\n) {\n chatRoomUnread(input: $input) {\n room {\n id\n ...UnreadMessagesCountFragment\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '82a5073d544e44997f36bec7b9547edc' +;(node as any).hash = 'fb95629ed4c89ffb9689a72b91d6cefa' export default node diff --git a/packages/components/__generated__/UnreadMessagesCountFragment.graphql.ts b/packages/components/__generated__/UnreadMessagesCountFragment.graphql.ts new file mode 100644 index 00000000..8d90ae31 --- /dev/null +++ b/packages/components/__generated__/UnreadMessagesCountFragment.graphql.ts @@ -0,0 +1,75 @@ +/** + * @generated SignedSource<<19f40b24ac8ca99201010ad3a7d437bd>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ + +/* eslint-disable */ +// @ts-nocheck +import { Fragment, ReaderFragment } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' + +export type UnreadMessagesCountFragment$data = { + readonly id: string + readonly unreadMessages: + | { + readonly count: number + readonly markedUnread: boolean + } + | null + | undefined + readonly ' $fragmentType': 'UnreadMessagesCountFragment' +} +export type UnreadMessagesCountFragment$key = { + readonly ' $data'?: UnreadMessagesCountFragment$data + readonly ' $fragmentSpreads': FragmentRefs<'UnreadMessagesCountFragment'> +} + +const node: ReaderFragment = { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'UnreadMessagesCountFragment', + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'id', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'UnreadMessageCount', + kind: 'LinkedField', + name: 'unreadMessages', + plural: false, + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'count', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'markedUnread', + storageKey: null, + }, + ], + storageKey: null, + }, + ], + type: 'ChatRoom', + abstractKey: null, +} + +;(node as any).hash = '153dd01c7e0a3cfb050cbc4215409310' + +export default node diff --git a/packages/components/__generated__/UpdateChatRoomMutation.graphql.ts b/packages/components/__generated__/UpdateChatRoomMutation.graphql.ts index aec00779..21ff329a 100644 --- a/packages/components/__generated__/UpdateChatRoomMutation.graphql.ts +++ b/packages/components/__generated__/UpdateChatRoomMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<38492937ede5a38d6dd9cc7dd9180ac3>> * @lightSyntaxTransform * @nogrep */ @@ -21,6 +21,7 @@ export type ChatRoomUpdateInput = { title?: string | null | undefined } export type UpdateChatRoomMutation$variables = { + connections: ReadonlyArray input: ChatRoomUpdateInput } export type UpdateChatRoomMutation$data = { @@ -37,12 +38,24 @@ export type UpdateChatRoomMutation$data = { > | null | undefined + readonly removedParticipants: + | ReadonlyArray< + | { + readonly id: string + } + | null + | undefined + > + | null + | undefined readonly room: | { readonly node: | { readonly id: string - readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> + readonly ' $fragmentSpreads': FragmentRefs< + 'LastMessageFragment' | 'TitleFragment' | 'UnreadMessagesCountFragment' + > } | null | undefined @@ -59,28 +72,31 @@ export type UpdateChatRoomMutation = { } const node: ConcreteRequest = (function () { - var v0 = [ - { - defaultValue: null, - kind: 'LocalArgument', - name: 'input', - }, - ], - v1 = [ + var v0 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'connections', + }, + v1 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'input', + }, + v2 = [ { kind: 'Variable', name: 'input', variableName: 'input', }, ], - v2 = { + v3 = { alias: null, args: null, kind: 'ScalarField', name: 'id', storageKey: null, }, - v3 = { + v4 = { alias: null, args: null, concreteType: 'ErrorType', @@ -105,13 +121,6 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v4 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, v5 = [ { alias: null, @@ -120,38 +129,17 @@ const node: ConcreteRequest = (function () { name: 'url', storageKey: null, }, - ], - v6 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - v7 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'name', - storageKey: null, - }, - v8 = [ - { - kind: 'Literal', - name: 'first', - value: 20, - }, ] return { fragment: { - argumentDefinitions: v0 /*: any*/, + argumentDefinitions: [v0 /*: any*/, v1 /*: any*/], kind: 'Fragment', metadata: null, name: 'UpdateChatRoomMutation', selections: [ { alias: null, - args: v1 /*: any*/, + args: v2 /*: any*/, concreteType: 'ChatRoomUpdatePayload', kind: 'LinkedField', name: 'chatRoomUpdate', @@ -173,11 +161,21 @@ const node: ConcreteRequest = (function () { name: 'node', plural: false, selections: [ - v2 /*: any*/, + v3 /*: any*/, + { + args: null, + kind: 'FragmentSpread', + name: 'LastMessageFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'TitleFragment', + }, { args: null, kind: 'FragmentSpread', - name: 'RoomFragment', + name: 'UnreadMessagesCountFragment', }, ], storageKey: null, @@ -185,7 +183,17 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v3 /*: any*/, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipant', + kind: 'LinkedField', + name: 'removedParticipants', + plural: true, + selections: [v3 /*: any*/], + storageKey: null, + }, + v4 /*: any*/, ], storageKey: null, }, @@ -195,13 +203,13 @@ const node: ConcreteRequest = (function () { }, kind: 'Request', operation: { - argumentDefinitions: v0 /*: any*/, + argumentDefinitions: [v1 /*: any*/, v0 /*: any*/], kind: 'Operation', name: 'UpdateChatRoomMutation', selections: [ { alias: null, - args: v1 /*: any*/, + args: v2 /*: any*/, concreteType: 'ChatRoomUpdatePayload', kind: 'LinkedField', name: 'chatRoomUpdate', @@ -223,33 +231,7 @@ const node: ConcreteRequest = (function () { name: 'node', plural: false, selections: [ - v2 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v2 /*: any*/, - ], - storageKey: null, - }, + v3 /*: any*/, { alias: null, args: null, @@ -264,35 +246,16 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v2 /*: any*/, v4 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, + selections: [ + v3 /*: any*/, { - kind: 'Literal', - name: 'width', - value: 144, + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, }, ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v5 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', storageKey: null, }, { @@ -308,7 +271,7 @@ const node: ConcreteRequest = (function () { { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -316,7 +279,6 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v6 /*: any*/, { alias: null, args: null, @@ -341,8 +303,14 @@ const node: ConcreteRequest = (function () { name: 'profile', plural: false, selections: [ - v2 /*: any*/, - v7 /*: any*/, + v3 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'name', + storageKey: null, + }, { alias: null, args: [ @@ -367,7 +335,7 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v2 /*: any*/, + v3 /*: any*/, ], storageKey: null, }, @@ -375,194 +343,113 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', }, { alias: null, - args: v8 /*: any*/, - concreteType: 'MessageConnection', + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', kind: 'LinkedField', - name: 'allMessages', + name: 'image', + plural: false, + selections: v5 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'UnreadMessageCount', + kind: 'LinkedField', + name: 'unreadMessages', plural: false, selections: [ - v6 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v2 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v2 /*: any*/, - v7 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v5 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v4 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v2 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: '__typename', - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'cursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'count', storageKey: null, }, { alias: null, args: null, - concreteType: 'PageInfo', - kind: 'LinkedField', - name: 'pageInfo', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'hasNextPage', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'endCursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'markedUnread', storageKey: null, }, + v3 /*: any*/, ], - storageKey: 'allMessages(first:20)', + storageKey: null, }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipant', + kind: 'LinkedField', + name: 'removedParticipants', + plural: true, + selections: [ + v3 /*: any*/, + { + alias: null, + args: null, + filters: null, + handle: 'deleteEdge', + key: '', + kind: 'ScalarHandle', + name: 'id', + handleArgs: [ { - alias: null, - args: v8 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + kind: 'Variable', + name: 'connections', + variableName: 'connections', }, ], - storageKey: null, }, ], storageKey: null, }, - v3 /*: any*/, + v4 /*: any*/, ], storageKey: null, }, ], }, params: { - cacheID: '5c0ef63c9db6b08fe729bb04aef94b75', + cacheID: '02ee6230858c1fc8bfc1d3cdff0ff168', id: null, metadata: {}, name: 'UpdateChatRoomMutation', operationKind: 'mutation', - text: 'mutation UpdateChatRoomMutation(\n $input: ChatRoomUpdateInput!\n) {\n chatRoomUpdate(input: $input) {\n room {\n node {\n id\n ...RoomFragment\n }\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n', + text: 'mutation UpdateChatRoomMutation(\n $input: ChatRoomUpdateInput!\n) {\n chatRoomUpdate(input: $input) {\n room {\n node {\n id\n ...LastMessageFragment\n ...TitleFragment\n ...UnreadMessagesCountFragment\n }\n }\n removedParticipants {\n id\n }\n errors {\n field\n messages\n }\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment LastMessageFragment on ChatRoom {\n id\n lastMessageTime\n lastMessage {\n id\n content\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '185a438c9dcbf08ccb129010469add25' +;(node as any).hash = '814ba3e87407537b5be32eb40c45a80d' export default node diff --git a/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts b/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts index b20dda09..a1bfd747 100644 --- a/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts +++ b/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -54,7 +54,7 @@ const node: ConcreteRequest = (function () { name: 'id', }, v4 = { - defaultValue: null, + defaultValue: '', kind: 'LocalArgument', name: 'q', }, @@ -114,14 +114,7 @@ const node: ConcreteRequest = (function () { v8 /*: any*/, v9 /*: any*/, ], - v13 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'content', - storageKey: null, - }, - v14 = [ + v13 = [ { alias: null, args: null, @@ -129,60 +122,7 @@ const node: ConcreteRequest = (function () { name: 'url', storageKey: null, }, - ], - v15 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - v16 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'name', - storageKey: null, - }, - v17 = [ - { - kind: 'Literal', - name: 'first', - value: 20, - }, - ], - v18 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'cursor', - storageKey: null, - }, - v19 = { - alias: null, - args: null, - concreteType: 'PageInfo', - kind: 'LinkedField', - name: 'pageInfo', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'hasNextPage', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'endCursor', - storageKey: null, - }, - ], - storageKey: null, - } + ] return { fragment: { argumentDefinitions: [ @@ -282,32 +222,6 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v11 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v11 /*: any*/, - ], - storageKey: null, - }, { alias: null, args: null, @@ -322,35 +236,16 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v11 /*: any*/, v13 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, + selections: [ + v11 /*: any*/, { - kind: 'Literal', - name: 'width', - value: 144, + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, }, ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v14 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', storageKey: null, }, { @@ -366,7 +261,7 @@ const node: ConcreteRequest = (function () { { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -374,7 +269,6 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v15 /*: any*/, { alias: null, args: null, @@ -400,7 +294,13 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v11 /*: any*/, - v16 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'name', + storageKey: null, + }, { alias: null, args: [ @@ -419,7 +319,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v14 /*: any*/, + selections: v13 /*: any*/, storageKey: 'image(height:100,width:100)', }, ], @@ -433,144 +333,101 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', }, { alias: null, - args: v17 /*: any*/, - concreteType: 'MessageConnection', + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', kind: 'LinkedField', - name: 'allMessages', + name: 'image', + plural: false, + selections: v13 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'UnreadMessageCount', + kind: 'LinkedField', + name: 'unreadMessages', plural: false, selections: [ - v15 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v11 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v11 /*: any*/, - v16 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v14 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v13 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v11 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - v10 /*: any*/, - ], - storageKey: null, - }, - v18 /*: any*/, - ], + kind: 'ScalarField', + name: 'count', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'markedUnread', storageKey: null, }, - v19 /*: any*/, + v11 /*: any*/, ], - storageKey: 'allMessages(first:20)', - }, - { - alias: null, - args: v17 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + storageKey: null, }, v10 /*: any*/, ], storageKey: null, }, - v18 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'cursor', + storageKey: null, + }, + ], + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'PageInfo', + kind: 'LinkedField', + name: 'pageInfo', + plural: false, + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'hasNextPage', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'endCursor', + storageKey: null, + }, ], storageKey: null, }, - v19 /*: any*/, ], storageKey: null, }, @@ -593,16 +450,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: 'bbe83915f2e296ceb9c92843a4abab6b', + cacheID: 'b1100ee4f24d18cdd232451eaaf87847', id: null, metadata: {}, name: 'chatRoomsPaginationQuery', operationKind: 'query', - text: 'query chatRoomsPaginationQuery(\n $archived: Boolean = false\n $count: Int = 5\n $cursor: String\n $q: String = null\n $unreadMessages: Boolean = false\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RoomsListFragment_3I5PKK\n id\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment_3I5PKK on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: $count, after: $cursor, q: $q, unreadMessages: $unreadMessages, archived: $archived) {\n edges {\n node {\n id\n ...RoomFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n id\n}\n', + text: 'query chatRoomsPaginationQuery(\n $archived: Boolean = false\n $count: Int = 5\n $cursor: String\n $q: String = ""\n $unreadMessages: Boolean = false\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RoomsListFragment_3I5PKK\n id\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment LastMessageFragment on ChatRoom {\n id\n lastMessageTime\n lastMessage {\n id\n content\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment RoomsListFragment_3I5PKK on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: $count, after: $cursor, q: $q, unreadMessages: $unreadMessages, archived: $archived) {\n edges {\n node {\n id\n ...LastMessageFragment\n ...TitleFragment\n ...UnreadMessagesCountFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n id\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '7fe57d53d40a4295a9eb2ea600d96f11' +;(node as any).hash = '3a66898cb96bbf4ce999aa5ad9822ca0' export default node diff --git a/packages/components/__generated__/useRoomListSubscription.graphql.ts b/packages/components/__generated__/useRoomListSubscription.graphql.ts index 806bf7c4..80f0a53b 100644 --- a/packages/components/__generated__/useRoomListSubscription.graphql.ts +++ b/packages/components/__generated__/useRoomListSubscription.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<9a09648b01689f6049fc8b2c04119bd3>> + * @generated SignedSource<<7f5339b06e4da843c62ab00d6f096c7e>> * @lightSyntaxTransform * @nogrep */ @@ -18,12 +18,33 @@ export type useRoomListSubscription$variables = { export type useRoomListSubscription$data = { readonly chatRoomOnRoomUpdate: | { + readonly removedParticipants: + | ReadonlyArray< + | { + readonly id: string + readonly profile: + | { + readonly id: string + } + | null + | undefined + } + | null + | undefined + > + | null + | undefined readonly room: | { readonly node: | { readonly id: string - readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> + readonly isArchived: boolean | null | undefined + readonly participantsCount: number + readonly title: string | null | undefined + readonly ' $fragmentSpreads': FragmentRefs< + 'LastMessageFragment' | 'TitleFragment' | 'UnreadMessagesCountFragment' + > } | null | undefined @@ -68,37 +89,40 @@ const node: ConcreteRequest = (function () { alias: null, args: null, kind: 'ScalarField', - name: 'content', + name: 'isArchived', + storageKey: null, + }, + v5 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'participantsCount', storageKey: null, }, - v5 = [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'url', - storageKey: null, - }, - ], v6 = { alias: null, args: null, kind: 'ScalarField', - name: 'totalCount', + name: 'title', storageKey: null, }, v7 = { alias: null, args: null, - kind: 'ScalarField', - name: 'name', + concreteType: 'Profile', + kind: 'LinkedField', + name: 'profile', + plural: false, + selections: [v3 /*: any*/], storageKey: null, }, v8 = [ { - kind: 'Literal', - name: 'first', - value: 20, + alias: null, + args: null, + kind: 'ScalarField', + name: 'url', + storageKey: null, }, ] return { @@ -133,10 +157,23 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v3 /*: any*/, + v4 /*: any*/, + v5 /*: any*/, + v6 /*: any*/, { args: null, kind: 'FragmentSpread', - name: 'RoomFragment', + name: 'LastMessageFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'TitleFragment', + }, + { + args: null, + kind: 'FragmentSpread', + name: 'UnreadMessagesCountFragment', }, ], storageKey: null, @@ -144,6 +181,16 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipant', + kind: 'LinkedField', + name: 'removedParticipants', + plural: true, + selections: [v3 /*: any*/, v7 /*: any*/], + storageKey: null, + }, ], storageKey: null, }, @@ -182,32 +229,9 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v3 /*: any*/, - { - alias: null, - args: null, - concreteType: 'UnreadMessageCount', - kind: 'LinkedField', - name: 'unreadMessages', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'count', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'markedUnread', - storageKey: null, - }, - v3 /*: any*/, - ], - storageKey: null, - }, + v4 /*: any*/, + v5 /*: any*/, + v6 /*: any*/, { alias: null, args: null, @@ -222,35 +246,16 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v3 /*: any*/, v4 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 144, - }, + selections: [ + v3 /*: any*/, { - kind: 'Literal', - name: 'width', - value: 144, + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, }, ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v5 /*: any*/, - storageKey: 'image(height:144,width:144)', - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'title', storageKey: null, }, { @@ -266,7 +271,7 @@ const node: ConcreteRequest = (function () { { kind: 'Literal', name: 'first', - value: 5, + value: 2, }, ], concreteType: 'ChatRoomParticipantConnection', @@ -274,7 +279,6 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v6 /*: any*/, { alias: null, args: null, @@ -300,7 +304,13 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v3 /*: any*/, - v7 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'name', + storageKey: null, + }, { alias: null, args: [ @@ -319,7 +329,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v5 /*: any*/, + selections: v8 /*: any*/, storageKey: 'image(height:100,width:100)', }, ], @@ -333,170 +343,54 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - storageKey: 'participants(first:5)', + storageKey: 'participants(first:2)', }, { alias: null, - args: v8 /*: any*/, - concreteType: 'MessageConnection', + args: [ + { + kind: 'Literal', + name: 'height', + value: 144, + }, + { + kind: 'Literal', + name: 'width', + value: 144, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v8 /*: any*/, + storageKey: 'image(height:144,width:144)', + }, + { + alias: null, + args: null, + concreteType: 'UnreadMessageCount', kind: 'LinkedField', - name: 'allMessages', + name: 'unreadMessages', plural: false, selections: [ - v6 /*: any*/, { alias: null, args: null, - concreteType: 'MessageEdge', - kind: 'LinkedField', - name: 'edges', - plural: true, - selections: [ - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v3 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'created', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v3 /*: any*/, - v7 /*: any*/, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 32, - }, - { - kind: 'Literal', - name: 'width', - value: 32, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: v5 /*: any*/, - storageKey: 'image(height:32,width:32)', - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'isRead', - storageKey: null, - }, - v4 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'extraData', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'Message', - kind: 'LinkedField', - name: 'inReplyTo', - plural: false, - selections: [v3 /*: any*/], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'pk', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'verb', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: '__typename', - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'cursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'count', storageKey: null, }, { alias: null, args: null, - concreteType: 'PageInfo', - kind: 'LinkedField', - name: 'pageInfo', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'hasNextPage', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'endCursor', - storageKey: null, - }, - ], + kind: 'ScalarField', + name: 'markedUnread', storageKey: null, }, + v3 /*: any*/, ], - storageKey: 'allMessages(first:20)', - }, - { - alias: null, - args: v8 /*: any*/, - filters: null, - handle: 'connection', - key: 'chatRoom_allMessages', - kind: 'LinkedHandle', - name: 'allMessages', + storageKey: null, }, ], storageKey: null, @@ -507,18 +401,31 @@ const node: ConcreteRequest = (function () { { alias: null, args: null, - filters: null, - handle: 'prependEdge', - key: '', - kind: 'LinkedHandle', - name: 'room', - handleArgs: [ + concreteType: 'ChatRoomParticipant', + kind: 'LinkedField', + name: 'removedParticipants', + plural: true, + selections: [ + v3 /*: any*/, { - kind: 'Variable', - name: 'connections', - variableName: 'connections', + alias: null, + args: null, + filters: null, + handle: 'deleteEdge', + key: '', + kind: 'ScalarHandle', + name: 'id', + handleArgs: [ + { + kind: 'Variable', + name: 'connections', + variableName: 'connections', + }, + ], }, + v7 /*: any*/, ], + storageKey: null, }, ], storageKey: null, @@ -526,16 +433,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: 'a9c64dad04dd0b89eda6ee87718f80b9', + cacheID: 'b33e570c1e964cbbf0ebdbe2cf54b30b', id: null, metadata: {}, name: 'useRoomListSubscription', operationKind: 'subscription', - text: 'subscription useRoomListSubscription(\n $profileId: ID!\n) {\n chatRoomOnRoomUpdate(profileId: $profileId) {\n room {\n node {\n id\n ...RoomFragment\n }\n }\n }\n}\n\nfragment ChatRoomHeaderFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n isGroup\n participants(first: 5) {\n totalCount\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment MessageItemFragment on Message {\n id\n content\n created\n extraData\n inReplyTo {\n id\n }\n isRead\n pk\n profile {\n id\n }\n verb\n}\n\nfragment MessagesListFragment on ChatRoom {\n id\n isGroup\n unreadMessages {\n count\n markedUnread\n id\n }\n allMessages(first: 20) {\n totalCount\n edges {\n node {\n id\n created\n profile {\n id\n name\n image(height: 32, width: 32) {\n url\n }\n }\n isRead\n ...MessageItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n\nfragment RoomFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n ...ChatRoomHeaderFragment\n ...MessagesListFragment\n}\n', + text: 'subscription useRoomListSubscription(\n $profileId: ID!\n) {\n chatRoomOnRoomUpdate(profileId: $profileId) {\n room {\n node {\n id\n isArchived\n participantsCount\n title\n ...LastMessageFragment\n ...TitleFragment\n ...UnreadMessagesCountFragment\n }\n }\n removedParticipants {\n id\n profile {\n id\n }\n }\n }\n}\n\nfragment GroupTitleFragment on ChatRoom {\n id\n image(width: 144, height: 144) {\n url\n }\n title\n}\n\nfragment LastMessageFragment on ChatRoom {\n id\n lastMessageTime\n lastMessage {\n id\n content\n }\n}\n\nfragment RoomTitleFragment on ChatRoom {\n id\n participants(first: 2) {\n edges {\n node {\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n id\n }\n }\n }\n}\n\nfragment TitleFragment on ChatRoom {\n id\n isGroup\n ...RoomTitleFragment\n ...GroupTitleFragment\n}\n\nfragment UnreadMessagesCountFragment on ChatRoom {\n id\n unreadMessages {\n count\n markedUnread\n id\n }\n}\n', }, } })() -;(node as any).hash = '0464ef194cb3243175a497ff51e98cf5' +;(node as any).hash = '1a6290e220a68b34641d01ea3ab017a1' export default node diff --git a/packages/components/modules/messages/ChatRoom/ChatRoomHeader/index.tsx b/packages/components/modules/messages/ChatRoom/ChatRoomHeader/index.tsx index 83906ab0..9b134c0b 100644 --- a/packages/components/modules/messages/ChatRoom/ChatRoomHeader/index.tsx +++ b/packages/components/modules/messages/ChatRoom/ChatRoomHeader/index.tsx @@ -11,22 +11,23 @@ import { Box, Typography } from '@mui/material' import { useFragment } from 'react-relay' import { useChatRoom } from '../../context' -import { ChatRoomHeaderFragment } from '../../graphql/queries/ChatRoomHeaderFragment' +import { TitleFragment } from '../../graphql/fragments/Title' import { getParticipantCountString, useNameAndAvatar } from '../../utils' import { BackButtonContainer, ChatHeaderContainer, ChatTitleContainer } from './styled' import { ChatRoomHeaderProps } from './types' const ChatRoomHeader: FC = ({ - roomHeaderRef, + participantsCount, + roomTitleRef, onDisplayGroupDetailsClicked, }) => { - const roomHeader = useFragment(ChatRoomHeaderFragment, roomHeaderRef) + const roomHeader = useFragment(TitleFragment, roomTitleRef) const isUpToMd = useResponsive('up', 'md') const { resetChatRoom } = useChatRoom() const { title, avatar } = useNameAndAvatar(roomHeader) - const members = getParticipantCountString(roomHeader.participants?.totalCount) + const members = getParticipantCountString(participantsCount) return ( diff --git a/packages/components/modules/messages/ChatRoom/ChatRoomHeader/types.ts b/packages/components/modules/messages/ChatRoom/ChatRoomHeader/types.ts index 42507de7..22b0ee11 100644 --- a/packages/components/modules/messages/ChatRoom/ChatRoomHeader/types.ts +++ b/packages/components/modules/messages/ChatRoom/ChatRoomHeader/types.ts @@ -1,9 +1,10 @@ import { BoxProps } from '@mui/material' -import { ChatRoomHeaderFragment$key } from '../../../../__generated__/ChatRoomHeaderFragment.graphql' +import { TitleFragment$key } from '../../../../__generated__/TitleFragment.graphql' export interface ChatRoomHeaderProps { - roomHeaderRef: ChatRoomHeaderFragment$key + participantsCount: number + roomTitleRef: TitleFragment$key onDisplayGroupDetailsClicked: () => void } diff --git a/packages/components/modules/messages/ChatRoom/index.tsx b/packages/components/modules/messages/ChatRoom/index.tsx index 60e9cba4..3f259d5b 100644 --- a/packages/components/modules/messages/ChatRoom/index.tsx +++ b/packages/components/modules/messages/ChatRoom/index.tsx @@ -43,7 +43,8 @@ const ChatRoom: FC = ({ return ( diff --git a/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx b/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx index 01737882..c1fb75b9 100644 --- a/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx +++ b/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx @@ -12,14 +12,16 @@ import { Box, Badge as DefaultBadge, Typography } from '@mui/material' import { ConnectionHandler, useFragment } from 'react-relay' import { RecordSourceSelectorProxy } from 'relay-runtime' -import { ChatRoomHeaderFragment$key } from '../../../../__generated__/ChatRoomHeaderFragment.graphql' -import { RoomFragment$key } from '../../../../__generated__/RoomFragment.graphql' +import { LastMessageFragment$key } from '../../../../__generated__/LastMessageFragment.graphql' +import { TitleFragment$key } from '../../../../__generated__/TitleFragment.graphql' +import { UnreadMessagesCountFragment$key } from '../../../../__generated__/UnreadMessagesCountFragment.graphql' import ActionsOverlay from '../../../__shared__/ActionsOverlay' +import { LastMessageFragment } from '../../graphql/fragments/LastMessage' +import { TitleFragment } from '../../graphql/fragments/Title' +import { UnreadMessagesCountFragment } from '../../graphql/fragments/UnreadMessagesCount' import { useArchiveChatRoomMutation } from '../../graphql/mutations/ArchiveChatRoom' import { useUnreadChatMutation } from '../../graphql/mutations/UnreadChat' -import { ChatRoomHeaderFragment } from '../../graphql/queries/ChatRoomHeaderFragment' -import { RoomFragment } from '../../graphql/queries/Room' -import { useNameAndAvatar } from '../../utils' +import { getChatRoomConnections, useNameAndAvatar } from '../../utils' import { StyledChatCard } from './styled' import { ChatRoomItemProps } from './types' import { formatDate } from './utils' @@ -31,9 +33,13 @@ const ChatRoomItem: FC = ({ Badge = DefaultBadge, BadgeProps = {}, isInArchivedTab = false, - isInUnreadTab = false, }) => { - const room = useFragment(RoomFragment, roomRef) + const lastMessageFragment = useFragment(LastMessageFragment, roomRef) + const headerFragment = useFragment(TitleFragment, roomRef) + const unreadMessagesCountFragment = useFragment( + UnreadMessagesCountFragment, + roomRef, + ) const [commitMutation] = useUnreadChatMutation() const handleCardClick = (event: SyntheticEvent) => { @@ -44,25 +50,25 @@ const ChatRoomItem: FC = ({ const chatCardRef = useRef(null) const { currentProfile } = useCurrentProfile() + const { title, avatar } = useNameAndAvatar(headerFragment) - const header = useFragment(ChatRoomHeaderFragment, room) - const { title, avatar } = useNameAndAvatar(header) - - const lastMessage = room.lastMessage?.content - const { lastMessageTime } = room + const { lastMessageTime } = lastMessageFragment + const lastMessage = lastMessageFragment.lastMessage?.content - const hasUnreadMessages = room.unreadMessages?.markedUnread || !!room.unreadMessages?.count + const hasUnreadMessages = + unreadMessagesCountFragment.unreadMessages?.markedUnread || + !!unreadMessagesCountFragment.unreadMessages?.count const unreadChat = useCallback(() => { commitMutation({ variables: { input: { - roomId: room.id, + roomId: roomRef.id, profileId: currentProfile?.id as string, }, }, }) - }, [room.id, currentProfile]) + }, [roomRef.id, currentProfile]) const [commit, isMutationInFlight] = useArchiveChatRoomMutation() @@ -80,24 +86,16 @@ const ChatRoomItem: FC = ({ commit({ variables: { input: { - roomId: room.id, + roomId: roomRef.id, profileId: currentProfile.id, archive: !isInArchivedTab, }, }, updater: (store: RecordSourceSelectorProxy, data: any) => { if (!data?.errors) { - const storyRecord = store.get(currentProfile.id) - if (storyRecord) { - const connectionRecord = ConnectionHandler.getConnection( - storyRecord, - 'roomsList_chatRooms', - { unreadMessages: isInUnreadTab, archived: isInArchivedTab }, - ) - if (connectionRecord) { - ConnectionHandler.deleteNode(connectionRecord, room.id) - } - } + getChatRoomConnections(store, currentProfile.id).forEach((connectionRecord) => + ConnectionHandler.deleteNode(connectionRecord, roomRef.id), + ) } }, }) @@ -120,7 +118,7 @@ const ChatRoomItem: FC = ({ ref={chatCardRef} > = ({ void Badge?: FC BadgeProps?: Partial isInArchivedTab: boolean - isInUnreadTab: boolean } export interface StyledChatCardProps extends BoxProps { diff --git a/packages/components/modules/messages/ChatRoomsList/index.tsx b/packages/components/modules/messages/ChatRoomsList/index.tsx index b536d126..1b016d0b 100644 --- a/packages/components/modules/messages/ChatRoomsList/index.tsx +++ b/packages/components/modules/messages/ChatRoomsList/index.tsx @@ -11,7 +11,7 @@ import { Virtuoso } from 'react-virtuoso' import { RoomsListFragment$key } from '../../../__generated__/RoomsListFragment.graphql' import SearchNotFoundState from '../../__shared__/SearchNotFoundState' import { useChatRoom } from '../context' -import { useRoomsList } from '../graphql/queries/RoomsList' +import { useRoomsList } from '../graphql/fragments/RoomsList' import useRoomListSubscription from '../graphql/subscriptions/useRoomListSubscription' import DefaultChatRoomItem from './ChatRoomItem' import DefaultEmptyChatRoomsState from './EmptyChatRoomsState' @@ -38,7 +38,6 @@ const ChatRoomsList: FC = ({ const [isPending, startTransition] = useTransition() const { control, reset, watch } = useForm({ defaultValues: { search: '' } }) - const isInUnreadTab = tab === CHAT_TAB_VALUES.unread const isInArchivedTab = tab === CHAT_TAB_VALUES.archived const searchValue = watch('search') @@ -84,7 +83,7 @@ const ChatRoomsList: FC = ({ [data?.chatRooms?.edges], ) - useRoomListSubscription(data.id) + useRoomListSubscription({ profileId: data.id, connections: [] }) const renderItem = useCallback( (room: ChatRoomNode) => { @@ -97,13 +96,12 @@ const ChatRoomsList: FC = ({ handleClick={() => { setChatRoom({ id: room.id }) }} - isInUnreadTab={isInUnreadTab} isInArchivedTab={isInArchivedTab} {...ChatRoomItemProps} /> ) }, - [selectedRoom, setChatRoom, ChatRoomItemProps, ChatRoomItem, isInUnreadTab, isInArchivedTab], + [selectedRoom, setChatRoom, ChatRoomItemProps, ChatRoomItem, isInArchivedTab], ) const renderLoadingState = () => { diff --git a/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx b/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx index 8ee7691d..923372ee 100644 --- a/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx +++ b/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx @@ -47,10 +47,12 @@ const ChatRoomListItem: FC = ({ profile: profileRef, onCh ConnectionHandler.getConnectionID(currentProfile.id, 'roomsList_chatRooms', { unreadMessages: false, archived: false, + q: '', }), ConnectionHandler.getConnectionID(currentProfile.id, 'roomsList_chatRooms', { unreadMessages: true, archived: false, + q: '', }), ], }, diff --git a/packages/components/modules/messages/CreateGroup/index.tsx b/packages/components/modules/messages/CreateGroup/index.tsx index 8e7b69a2..c863cbd8 100644 --- a/packages/components/modules/messages/CreateGroup/index.tsx +++ b/packages/components/modules/messages/CreateGroup/index.tsx @@ -96,6 +96,8 @@ const CreateGroup: FC = ({ // TODO: add filter handling (for now we can default 'unreadMessages' to false) ConnectionHandler.getConnectionID(currentProfile?.id as string, 'roomsList_chatRooms', { unreadMessages: false, + archived: false, + q: '', }), ], }, diff --git a/packages/components/modules/messages/EditGroup/index.tsx b/packages/components/modules/messages/EditGroup/index.tsx index 6233b26e..b4e93ba9 100644 --- a/packages/components/modules/messages/EditGroup/index.tsx +++ b/packages/components/modules/messages/EditGroup/index.tsx @@ -15,16 +15,27 @@ import { GroupDetailsQuery as GroupDetailsQueryType } from '../../../__generated import { EditGroupTitleAndImage } from '../__shared__' import { useUpdateChatRoomMutation } from '../graphql/mutations/UpdateChatRoom' import { GroupDetailsQuery } from '../graphql/queries/GroupDetailsQuery' +import useRoomListSubscription from '../graphql/subscriptions/useRoomListSubscription' +import { useGroupNameAndAvatar } from '../utils' import { DEFAULT_FORM_VALIDATION, FORM_VALUE, getDefaultFormValues } from './constants' import { HeaderContainer } from './styled' import { EditGroupProps } from './types' -const EditGroup: FC = ({ queryRef, roomId, onValidSubmission, onCancellation }) => { +const EditGroup: FC = ({ + profileId, + queryRef, + roomId, + onCancellation, + onRemovalFromGroup, + onValidSubmission, +}) => { const { sendToast } = useNotification() const { chatRoom: group } = usePreloadedQuery(GroupDetailsQuery, queryRef) + const { avatar, title } = useGroupNameAndAvatar(group) + useRoomListSubscription({ profileId, connections: [], onRemoval: onRemovalFromGroup }) const formReturn = useForm({ - defaultValues: getDefaultFormValues(group?.title ? group.title : '', group?.image?.url), + defaultValues: getDefaultFormValues(title || '', avatar), resolver: zodResolver(DEFAULT_FORM_VALIDATION), mode: 'onBlur', }) @@ -40,8 +51,6 @@ const EditGroup: FC = ({ queryRef, roomId, onValidSubmission, on formState: { isValid, isDirty, dirtyFields }, } = formReturn - const { currentProfile } = useCurrentProfile() - const [commit, isMutationInFlight] = useUpdateChatRoomMutation() const onSubmit = handleSubmit((data: any) => { @@ -63,9 +72,10 @@ const EditGroup: FC = ({ queryRef, roomId, onValidSubmission, on variables: { input: { roomId, - profileId: currentProfile?.id as string, + profileId, ...dirtyValues, }, + connections: [], }, uploadables, onCompleted: (response) => { @@ -125,4 +135,12 @@ const EditGroup: FC = ({ queryRef, roomId, onValidSubmission, on ) } -export default EditGroup +const WrappedEditGroup: FC = (props) => { + const { currentProfile } = useCurrentProfile() + if (!currentProfile?.id) { + return null + } + return +} + +export default WrappedEditGroup diff --git a/packages/components/modules/messages/EditGroup/types.ts b/packages/components/modules/messages/EditGroup/types.ts index f808d04c..90067795 100644 --- a/packages/components/modules/messages/EditGroup/types.ts +++ b/packages/components/modules/messages/EditGroup/types.ts @@ -8,8 +8,9 @@ export interface EditGroupProps extends PropsWithChildren { queryRef: PreloadedQuery remotePatternsHostName?: string roomId: string | undefined - onValidSubmission: () => void onCancellation: () => void + onRemovalFromGroup: () => void + onValidSubmission: () => void } export interface EditGroupUpload { diff --git a/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/index.tsx b/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/index.tsx index e435f9e0..bc29ca6d 100644 --- a/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/index.tsx +++ b/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/index.tsx @@ -4,12 +4,17 @@ import { MenuItem, MenuList, Typography } from '@mui/material' import { AdminOptionsProps } from './types' -const AdminOptionsMenu: FC = ({ onMakeAdminClicked, onRemoveClicked }) => ( +const AdminOptionsMenu: FC = ({ + isAdmin, + isMe, + onToggleAdminClicked, + onRemoveClicked, +}) => ( - - Make Admin + + {isAdmin ? 'Make normal user' : 'Make Admin'} - + Remove diff --git a/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/types.ts b/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/types.ts index 1958e956..b86e794e 100644 --- a/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/types.ts +++ b/packages/components/modules/messages/GroupDetails/ProfileCard/AdminOptionsMenu/types.ts @@ -1,4 +1,6 @@ export interface AdminOptionsProps { - onMakeAdminClicked: () => void + isAdmin: boolean + isMe: boolean + onToggleAdminClicked: () => void onRemoveClicked: () => void } diff --git a/packages/components/modules/messages/GroupDetails/ProfileCard/index.tsx b/packages/components/modules/messages/GroupDetails/ProfileCard/index.tsx index 10d11995..389de181 100644 --- a/packages/components/modules/messages/GroupDetails/ProfileCard/index.tsx +++ b/packages/components/modules/messages/GroupDetails/ProfileCard/index.tsx @@ -2,6 +2,7 @@ import { FC } from 'react' +import { useCurrentProfile } from '@baseapp-frontend/authentication' import { AvatarWithPlaceholder, Popover, @@ -12,20 +13,33 @@ import { import { Box, IconButton, Typography } from '@mui/material' import { useFragment } from 'react-relay' +import { ProfileItemFragment$key } from '../../../../__generated__/ProfileItemFragment.graphql' import { ProfileItemFragment } from '../../../profiles/graphql/queries/ProfileItem' import AdminOptionsMenu from './AdminOptionsMenu' import { ADMIN_LABEL, CHAT_ROOM_PARTICIPANT_ROLES } from './constants' import { MainContainer } from './styled' import { ProfileCardProps } from './types' -const ProfileCard: FC = ({ hasAdminPermissions, profile: profileRef, role }) => { - const { id, image, name, urlPath } = useFragment(ProfileItemFragment, profileRef) +const ProfileCard: FC = ({ + hasAdminPermissions, + groupMember, + initiateRemoval, +}) => { + const { id, image, name, urlPath } = useFragment( + ProfileItemFragment, + groupMember.profile!, + ) const showUrlPath = !!urlPath?.path - const showAdminLabel = role === CHAT_ROOM_PARTICIPANT_ROLES.admin + const showAdminLabel = groupMember?.role === CHAT_ROOM_PARTICIPANT_ROLES.admin const showMenu = hasAdminPermissions - + const { currentProfile } = useCurrentProfile() const popover = usePopover() + const handleRemoveClicked = () => { + popover.onClose() + initiateRemoval(id, name) + } + return ( = ({ hasAdminPermissions, profile: profi diff --git a/packages/components/modules/messages/GroupDetails/ProfileCard/types.ts b/packages/components/modules/messages/GroupDetails/ProfileCard/types.ts index 63c27b9f..ceace4fd 100644 --- a/packages/components/modules/messages/GroupDetails/ProfileCard/types.ts +++ b/packages/components/modules/messages/GroupDetails/ProfileCard/types.ts @@ -1,7 +1,11 @@ -import { ProfileItemFragment$key } from '../../../../__generated__/ProfileItemFragment.graphql' +import { MembersListFragment$data } from '../../../../__generated__/MembersListFragment.graphql' + +type GroupMembers = NonNullable +export type GroupMembersEdge = NonNullable +export type GroupMembersNode = NonNullable export interface ProfileCardProps { + groupMember: GroupMembersNode hasAdminPermissions: boolean - profile: ProfileItemFragment$key - role: string | null | undefined + initiateRemoval: (id: string, name: string | null | undefined) => void } diff --git a/packages/components/modules/messages/GroupDetails/index.tsx b/packages/components/modules/messages/GroupDetails/index.tsx index dd308cc5..93e62034 100644 --- a/packages/components/modules/messages/GroupDetails/index.tsx +++ b/packages/components/modules/messages/GroupDetails/index.tsx @@ -1,45 +1,55 @@ 'use client' -import { FC, Suspense } from 'react' +import { FC, Suspense, useRef, useState } from 'react' import { useCurrentProfile } from '@baseapp-frontend/authentication' -import { CircledAvatar, LoadingState } from '@baseapp-frontend/design-system' +import { CircledAvatar, ConfirmDialog, LoadingState } from '@baseapp-frontend/design-system' +import { useNotification } from '@baseapp-frontend/utils' +import { LoadingButton } from '@mui/lab' import { Box, Typography, useTheme } from '@mui/material' -import { usePaginationFragment, usePreloadedQuery } from 'react-relay' +import { ConnectionHandler, usePaginationFragment, usePreloadedQuery } from 'react-relay' import { Virtuoso } from 'react-virtuoso' import { ChatRoomParticipantsPaginationQuery } from '../../../__generated__/ChatRoomParticipantsPaginationQuery.graphql' import { GroupDetailsQuery as GroupDetailsQueryType } from '../../../__generated__/GroupDetailsQuery.graphql' import { MembersListFragment$key } from '../../../__generated__/MembersListFragment.graphql' +import { MembersListFragment } from '../graphql/fragments/MembersList' +import { useUpdateChatRoomMutation } from '../graphql/mutations/UpdateChatRoom' import { GroupDetailsQuery } from '../graphql/queries/GroupDetailsQuery' -import { MembersListFragment } from '../graphql/queries/MembersList' +import useRoomListSubscription from '../graphql/subscriptions/useRoomListSubscription' +import { getParticipantCountString, useGroupNameAndAvatar } from '../utils' import { GroupDetailsHeader } from './GroupDetailsHeader' import DefaultProfileCard from './ProfileCard' import { CHAT_ROOM_PARTICIPANT_ROLES } from './ProfileCard/constants' +import { GroupMembersEdge } from './ProfileCard/types' import { GroupHeaderContainer, GroupTitleContainer } from './styled' -import { GroupDetailsProps, GroupMembersEdge } from './types' +import { GroupDetailsProps } from './types' -const GroupDetails: FC = ({ +const GroupDetails: FC = ({ onBackButtonClicked, onEditButtonClicked, + profileId, queryRef, ProfileCard = DefaultProfileCard, ProfileCardProps = {}, VirtuosoProps = {}, }) => { - const theme = useTheme() const { chatRoom: group } = usePreloadedQuery(GroupDetailsQuery, queryRef) - const { currentProfile } = useCurrentProfile() + const { avatar, title } = useGroupNameAndAvatar(group) + const theme = useTheme() + + const connections = group?.id + ? [ConnectionHandler.getConnectionID(group.id, 'ChatRoom_participants')] + : [] + useRoomListSubscription({ profileId, connections, onRemoval: onBackButtonClicked }) const { data, loadNext, isLoadingNext, hasNext } = usePaginationFragment< ChatRoomParticipantsPaginationQuery, MembersListFragment$key >(MembersListFragment, group) const members = data?.participants - const me = members?.edges.find( - (edge) => currentProfile?.id && edge?.node?.profile?.id === currentProfile?.id, - ) + const me = members?.edges.find((edge) => edge?.node?.profile?.id === profileId) const isAdmin = me?.node?.role === CHAT_ROOM_PARTICIPANT_ROLES.admin const renderLoadingState = () => { @@ -54,13 +64,66 @@ const GroupDetails: FC = ({ ) } + const [removingParticipantId, setRemovingParticipantId] = useState(undefined) + const removingParticipantName = useRef(undefined) + const [commit, isMutationInFlight] = useUpdateChatRoomMutation() + const { sendToast } = useNotification() + + const initiateRemoval = (id: string, name: string | null | undefined) => { + setRemovingParticipantId(id) + removingParticipantName.current = name + } + + const handleRemoveDialogClose = () => { + setRemovingParticipantId(undefined) + removingParticipantName.current = undefined + } + + const onRemoveConfirmed = () => { + if (!group?.id) return + commit({ + variables: { + input: { + roomId: group.id, + profileId, + removeParticipants: [removingParticipantId], + }, + connections: [ConnectionHandler.getConnectionID(group.id, 'ChatRoom_participants')], + }, + onCompleted: (response) => { + if (!response?.chatRoomUpdate?.errors) { + sendToast(`${removingParticipantName.current} was successfully removed`) + } + handleRemoveDialogClose() + }, + }) + } + + const renderDeleteDialog = () => ( + + Remove + + } + onClose={handleRemoveDialogClose} + open={removingParticipantId !== undefined} + /> + ) + const renderItem = (item: GroupMembersEdge) => { - const profile = item?.node?.profile - if (profile) { + if (item.node) { return ( @@ -88,6 +151,7 @@ const GroupDetails: FC = ({ return ( <> + {renderDeleteDialog()} = ({ /> - + - {group?.title} + {title} - {members?.totalCount} member{members?.totalCount !== 1 ? 's' : ''} + {getParticipantCountString(group?.participantsCount)} @@ -127,22 +191,32 @@ const GroupDetails: FC = ({ ) } -const SuspendedGroupDetails: FC = ({ onBackButtonClicked, ...props }) => ( +const WrappedGroupDetails: FC = ({ onBackButtonClicked, ...props }) => { // Displays a 'preliminary' header and a spinner below // Header has "Group Details" label and back button, but no edit button (appears if the group details are loaded and current user has admin permissions) - - - - - } - > - - -) + const { currentProfile } = useCurrentProfile() + if (!currentProfile?.id) { + return null + } + return ( + + + + + } + > + + + ) +} -export default SuspendedGroupDetails +export default WrappedGroupDetails diff --git a/packages/components/modules/messages/GroupDetails/types.ts b/packages/components/modules/messages/GroupDetails/types.ts index 7574ba7a..cd937b45 100644 --- a/packages/components/modules/messages/GroupDetails/types.ts +++ b/packages/components/modules/messages/GroupDetails/types.ts @@ -4,12 +4,8 @@ import { PreloadedQuery } from 'react-relay' import { VirtuosoProps } from 'react-virtuoso' import { GroupDetailsQuery as GroupDetailsQueryType } from '../../../__generated__/GroupDetailsQuery.graphql' -import { MembersListFragment$data } from '../../../__generated__/MembersListFragment.graphql' import { ProfileCardProps } from './ProfileCard/types' -type GroupMembers = NonNullable -export type GroupMembersEdge = GroupMembers['edges'][number] - export type GroupDetailsProps = { onBackButtonClicked: () => void onEditButtonClicked: () => void diff --git a/packages/components/modules/messages/MessagesList/MessagesGroup/MessageItem/index.tsx b/packages/components/modules/messages/MessagesList/MessagesGroup/MessageItem/index.tsx index 07fbc32e..da6c391d 100644 --- a/packages/components/modules/messages/MessagesList/MessagesGroup/MessageItem/index.tsx +++ b/packages/components/modules/messages/MessagesList/MessagesGroup/MessageItem/index.tsx @@ -5,7 +5,7 @@ import { useCurrentProfile } from '@baseapp-frontend/authentication' import { Typography } from '@mui/material' import { useFragment } from 'react-relay' -import { MessageItemFragment } from '../../../graphql/queries/MessageItem' +import { MessageItemFragment } from '../../../graphql/fragments/MessageItem' import { MessageItemContainer } from './styled' import { MessageItemProps } from './types' diff --git a/packages/components/modules/messages/MessagesList/index.tsx b/packages/components/modules/messages/MessagesList/index.tsx index 828cd682..9157a8c7 100644 --- a/packages/components/modules/messages/MessagesList/index.tsx +++ b/packages/components/modules/messages/MessagesList/index.tsx @@ -10,8 +10,8 @@ import { Virtuoso, VirtuosoHandle } from 'react-virtuoso' import { ChatRoomMessagesListPaginationQuery } from '../../../__generated__/ChatRoomMessagesListPaginationQuery.graphql' import { MessagesListFragment$key } from '../../../__generated__/MessagesListFragment.graphql' import { useChatRoom } from '../context' +import { MessagesListFragment } from '../graphql/fragments/MessagesList' import { useReadMessageMutation } from '../graphql/mutations/ReadMessages' -import { MessagesListFragment } from '../graphql/queries/MessagesList' import useMessagesListSubscription from '../graphql/subscriptions/useMessagesListSubscription' import DefaultMessagesGroup from './MessagesGroup' import { MESSAGES_TO_LOAD_NEXT } from './constants' diff --git a/packages/components/modules/messages/graphql/fragments/GroupTitle.ts b/packages/components/modules/messages/graphql/fragments/GroupTitle.ts new file mode 100644 index 00000000..c9006b9e --- /dev/null +++ b/packages/components/modules/messages/graphql/fragments/GroupTitle.ts @@ -0,0 +1,11 @@ +import { graphql } from 'react-relay' + +export const GroupTitleFragment = graphql` + fragment GroupTitleFragment on ChatRoom { + id + image(width: 144, height: 144) { + url + } + title + } +` diff --git a/packages/components/modules/messages/graphql/fragments/LastMessage.ts b/packages/components/modules/messages/graphql/fragments/LastMessage.ts new file mode 100644 index 00000000..a9e26a2f --- /dev/null +++ b/packages/components/modules/messages/graphql/fragments/LastMessage.ts @@ -0,0 +1,12 @@ +import { graphql } from 'react-relay' + +export const LastMessageFragment = graphql` + fragment LastMessageFragment on ChatRoom { + id + lastMessageTime + lastMessage { + id + content + } + } +` diff --git a/packages/components/modules/messages/graphql/queries/MembersList.ts b/packages/components/modules/messages/graphql/fragments/MembersList.ts similarity index 97% rename from packages/components/modules/messages/graphql/queries/MembersList.ts rename to packages/components/modules/messages/graphql/fragments/MembersList.ts index f4a6a0a5..d61d9ca8 100644 --- a/packages/components/modules/messages/graphql/queries/MembersList.ts +++ b/packages/components/modules/messages/graphql/fragments/MembersList.ts @@ -8,6 +8,7 @@ export const MembersListFragment = graphql` participants(first: $count, after: $cursor) @connection(key: "ChatRoom_participants") { edges { node { + id profile { id ...ProfileItemFragment @@ -19,7 +20,6 @@ export const MembersListFragment = graphql` hasNextPage endCursor } - totalCount } } ` diff --git a/packages/components/modules/messages/graphql/queries/MessageItem.ts b/packages/components/modules/messages/graphql/fragments/MessageItem.ts similarity index 100% rename from packages/components/modules/messages/graphql/queries/MessageItem.ts rename to packages/components/modules/messages/graphql/fragments/MessageItem.ts diff --git a/packages/components/modules/messages/graphql/queries/MessagesList.ts b/packages/components/modules/messages/graphql/fragments/MessagesList.ts similarity index 100% rename from packages/components/modules/messages/graphql/queries/MessagesList.ts rename to packages/components/modules/messages/graphql/fragments/MessagesList.ts diff --git a/packages/components/modules/messages/graphql/fragments/Room.ts b/packages/components/modules/messages/graphql/fragments/Room.ts new file mode 100644 index 00000000..7b107326 --- /dev/null +++ b/packages/components/modules/messages/graphql/fragments/Room.ts @@ -0,0 +1,15 @@ +import { graphql } from 'react-relay' + +// This includes most data (except MembersList) which is found on a chat room. +// It is currently not used in the code. +export const RoomFragment = graphql` + fragment RoomFragment on ChatRoom { + id + isGroup + participantsCount + ...LastMessageFragment + ...MessagesListFragment + ...TitleFragment + ...UnreadMessagesCountFragment + } +` diff --git a/packages/components/modules/messages/graphql/queries/ChatRoomHeaderFragment.ts b/packages/components/modules/messages/graphql/fragments/RoomTitle.ts similarity index 53% rename from packages/components/modules/messages/graphql/queries/ChatRoomHeaderFragment.ts rename to packages/components/modules/messages/graphql/fragments/RoomTitle.ts index 6a95a8cb..ff0db626 100644 --- a/packages/components/modules/messages/graphql/queries/ChatRoomHeaderFragment.ts +++ b/packages/components/modules/messages/graphql/fragments/RoomTitle.ts @@ -1,15 +1,10 @@ import { graphql } from 'react-relay' -export const ChatRoomHeaderFragment = graphql` - fragment ChatRoomHeaderFragment on ChatRoom { +// non-group chat rooms have the avatar and name of the other participant as title +export const RoomTitleFragment = graphql` + fragment RoomTitleFragment on ChatRoom { id - image(width: 144, height: 144) { - url - } - title - isGroup - participants(first: 5) { - totalCount + participants(first: 2) { edges { node { profile { diff --git a/packages/components/modules/messages/graphql/queries/RoomsList.ts b/packages/components/modules/messages/graphql/fragments/RoomsList.ts similarity index 88% rename from packages/components/modules/messages/graphql/queries/RoomsList.ts rename to packages/components/modules/messages/graphql/fragments/RoomsList.ts index c75e7f9c..0c99a863 100644 --- a/packages/components/modules/messages/graphql/queries/RoomsList.ts +++ b/packages/components/modules/messages/graphql/fragments/RoomsList.ts @@ -8,7 +8,7 @@ export const RoomsListFragment = graphql` @argumentDefinitions( cursor: { type: "String" } count: { type: "Int", defaultValue: 5 } - q: { type: "String", defaultValue: null } + q: { type: "String", defaultValue: "" } unreadMessages: { type: "Boolean", defaultValue: false } archived: { type: "Boolean", defaultValue: false } ) @@ -23,7 +23,9 @@ export const RoomsListFragment = graphql` edges { node { id - ...RoomFragment + ...LastMessageFragment + ...TitleFragment + ...UnreadMessagesCountFragment } } pageInfo { diff --git a/packages/components/modules/messages/graphql/fragments/Title.ts b/packages/components/modules/messages/graphql/fragments/Title.ts new file mode 100644 index 00000000..66a5c2a5 --- /dev/null +++ b/packages/components/modules/messages/graphql/fragments/Title.ts @@ -0,0 +1,15 @@ +import { graphql } from 'react-relay' + +// Ideally this would use a type refinement of the form +// ...on ChatGroup { ...GroupTitleFragment } +// ...on OneOnOneChat { ...RoomTitleFragment } +// but the backend does not provide different ChatRoom types. +// Therefore we fetch both fragments. +export const TitleFragment = graphql` + fragment TitleFragment on ChatRoom { + id + isGroup + ...RoomTitleFragment + ...GroupTitleFragment + } +` diff --git a/packages/components/modules/messages/graphql/fragments/UnreadMessagesCount.ts b/packages/components/modules/messages/graphql/fragments/UnreadMessagesCount.ts new file mode 100644 index 00000000..349d6237 --- /dev/null +++ b/packages/components/modules/messages/graphql/fragments/UnreadMessagesCount.ts @@ -0,0 +1,11 @@ +import { graphql } from 'react-relay' + +export const UnreadMessagesCountFragment = graphql` + fragment UnreadMessagesCountFragment on ChatRoom { + id + unreadMessages { + count + markedUnread + } + } +` diff --git a/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts b/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts index 46f547ec..079dddb9 100644 --- a/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts +++ b/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts @@ -5,13 +5,16 @@ import { Disposable, UseMutationConfig, graphql, useMutation } from 'react-relay import { CreateChatRoomMutation } from '../../../../__generated__/CreateChatRoomMutation.graphql' import { useChatRoom } from '../../context' +// node should be same as in RoomsList export const CreateChatRoomMutationQuery = graphql` mutation CreateChatRoomMutation($input: ChatRoomCreateInput!, $connections: [ID!]!) { chatRoomCreate(input: $input) { room @prependEdge(connections: $connections) { node { id - ...RoomFragment + ...LastMessageFragment + ...TitleFragment + ...UnreadMessagesCountFragment } } errors { diff --git a/packages/components/modules/messages/graphql/mutations/ReadMessages.ts b/packages/components/modules/messages/graphql/mutations/ReadMessages.ts index 400136b9..a6c4a363 100644 --- a/packages/components/modules/messages/graphql/mutations/ReadMessages.ts +++ b/packages/components/modules/messages/graphql/mutations/ReadMessages.ts @@ -9,11 +9,7 @@ export const ReadMessagesMutationQuery = graphql` chatRoomReadMessages(input: $input) { room { id - unreadMessages { - count - markedUnread - } - ...RoomFragment + ...UnreadMessagesCountFragment } errors { field diff --git a/packages/components/modules/messages/graphql/mutations/UnreadChat.ts b/packages/components/modules/messages/graphql/mutations/UnreadChat.ts index 1f36e8a0..0a5d7476 100644 --- a/packages/components/modules/messages/graphql/mutations/UnreadChat.ts +++ b/packages/components/modules/messages/graphql/mutations/UnreadChat.ts @@ -9,10 +9,7 @@ export const UnreadChatMutationQuery = graphql` chatRoomUnread(input: $input) { room { id - unreadMessages { - count - markedUnread - } + ...UnreadMessagesCountFragment } errors { field diff --git a/packages/components/modules/messages/graphql/mutations/UpdateChatRoom.ts b/packages/components/modules/messages/graphql/mutations/UpdateChatRoom.ts index 49f8da6b..34411f2f 100644 --- a/packages/components/modules/messages/graphql/mutations/UpdateChatRoom.ts +++ b/packages/components/modules/messages/graphql/mutations/UpdateChatRoom.ts @@ -4,15 +4,21 @@ import { Disposable, UseMutationConfig, graphql, useMutation } from 'react-relay import { UpdateChatRoomMutation } from '../../../../__generated__/UpdateChatRoomMutation.graphql' +// node should be the same as in RoomsList export const UpdateChatRoomMutationQuery = graphql` - mutation UpdateChatRoomMutation($input: ChatRoomUpdateInput!) { + mutation UpdateChatRoomMutation($input: ChatRoomUpdateInput!, $connections: [ID!]!) { chatRoomUpdate(input: $input) { room { node { id - ...RoomFragment + ...LastMessageFragment + ...TitleFragment + ...UnreadMessagesCountFragment } } + removedParticipants { + id @deleteEdge(connections: $connections) + } errors { field messages diff --git a/packages/components/modules/messages/graphql/queries/ChatRoomQuery.ts b/packages/components/modules/messages/graphql/queries/ChatRoomQuery.ts index bd03afd8..3c503eab 100644 --- a/packages/components/modules/messages/graphql/queries/ChatRoomQuery.ts +++ b/packages/components/modules/messages/graphql/queries/ChatRoomQuery.ts @@ -4,7 +4,8 @@ export const ChatRoomQuery = graphql` query ChatRoomQuery($roomId: ID!) { chatRoom(id: $roomId) { id - ...ChatRoomHeaderFragment + participantsCount + ...TitleFragment ...MessagesListFragment } } diff --git a/packages/components/modules/messages/graphql/queries/GroupDetailsQuery.ts b/packages/components/modules/messages/graphql/queries/GroupDetailsQuery.ts index 7a617708..4a976fba 100644 --- a/packages/components/modules/messages/graphql/queries/GroupDetailsQuery.ts +++ b/packages/components/modules/messages/graphql/queries/GroupDetailsQuery.ts @@ -4,10 +4,8 @@ export const GroupDetailsQuery = graphql` query GroupDetailsQuery($roomId: ID!) { chatRoom(id: $roomId) { id - image(width: 144, height: 144) { - url - } - title + participantsCount + ...GroupTitleFragment ...MembersListFragment } } diff --git a/packages/components/modules/messages/graphql/queries/Room.ts b/packages/components/modules/messages/graphql/queries/Room.ts deleted file mode 100644 index 13857d65..00000000 --- a/packages/components/modules/messages/graphql/queries/Room.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { graphql } from 'react-relay' - -export const RoomFragment = graphql` - fragment RoomFragment on ChatRoom { - id - unreadMessages { - count - markedUnread - } - lastMessageTime - lastMessage { - id - content - } - ...ChatRoomHeaderFragment - ...MessagesListFragment - } -` diff --git a/packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx b/packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx index 3270ab14..b5f13a64 100644 --- a/packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx +++ b/packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx @@ -4,6 +4,7 @@ import { useCurrentProfile } from '@baseapp-frontend/authentication' import { graphql, useSubscription } from 'react-relay' +// TODO: check if this is used and delete const MessageCountUpdateSubscription = graphql` subscription useMessageCountUpdateSubscription($profileId: ID!) { chatRoomOnMessagesCountUpdate(profileId: $profileId) { diff --git a/packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx b/packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx index 49fb44ca..383f5fc3 100644 --- a/packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx +++ b/packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react' import { ConnectionHandler, graphql, useSubscription } from 'react-relay' -const newMessageSubscription = graphql` +export const newMessageSubscription = graphql` subscription useMessagesListSubscription($roomId: ID!, $connections: [ID!]!) { chatRoomOnNewMessage(roomId: $roomId) { message @prependEdge(connections: $connections) { diff --git a/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx b/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx index 40bb3530..d6344222 100644 --- a/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx +++ b/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx @@ -1,41 +1,108 @@ +'use-client' + import { useMemo } from 'react' +import { useNotification } from '@baseapp-frontend/utils' + import { ConnectionHandler, graphql, useSubscription } from 'react-relay' +import { RecordSourceSelectorProxy } from 'relay-runtime' + +import { + useRoomListSubscription$data, + useRoomListSubscription as useRoomListSubscriptionType, +} from '../../../../__generated__/useRoomListSubscription.graphql' +import { useChatRoom } from '../../context' +import { getChatRoomConnections } from '../../utils' -const RoomListSubscriptionQuery = graphql` +// isArchived is needed to bump the chatRoom up in the correct connection +// title is used to toast room name if user was removed, without having to read in a fragment +export const RoomListSubscriptionQuery = graphql` subscription useRoomListSubscription($profileId: ID!, $connections: [ID!]!) { chatRoomOnRoomUpdate(profileId: $profileId) { - room @prependEdge(connections: $connections) { + room { node { id - ...RoomFragment + isArchived + participantsCount + title + ...LastMessageFragment + ...TitleFragment + ...UnreadMessagesCountFragment + } + } + removedParticipants { + id @deleteEdge(connections: $connections) + profile { + id } } } } ` -const useRoomListSubscription = (profileId: string) => { +const useRoomListSubscription = ({ + connections, + profileId, + onRemoval, +}: { + connections: string[] + profileId: string + onRemoval?: () => void +}) => { + const { id: selectedRoom, resetChatRoom } = useChatRoom() + const { sendToast } = useNotification() + const config = useMemo(() => { - const connectionIdActive = ConnectionHandler.getConnectionID(profileId, 'roomsList_chatRooms', { - unreadMessages: false, - archived: false, - }) - const connectionIdUnread = ConnectionHandler.getConnectionID(profileId, 'roomsList_chatRooms', { - unreadMessages: true, - archived: false, - }) + const wasRemovedFromChatRoom = (data: useRoomListSubscription$data | null | undefined) => + data?.chatRoomOnRoomUpdate?.removedParticipants?.some( + (node) => node?.profile?.id === profileId, + ) + return { subscription: RoomListSubscriptionQuery, onError: console.error, - variables: { - profileId, - connections: [connectionIdActive, connectionIdUnread], + variables: { profileId, connections }, + updater: ( + store: RecordSourceSelectorProxy, + data: useRoomListSubscription$data | null | undefined, + ) => { + const roomId = data?.chatRoomOnRoomUpdate?.room?.node?.id + if (!roomId) return + if (wasRemovedFromChatRoom(data)) { + getChatRoomConnections(store, profileId).forEach((connectionRecord) => + ConnectionHandler.deleteNode(connectionRecord, roomId), + ) + } else { + const isArchived = data?.chatRoomOnRoomUpdate?.room?.node?.isArchived + getChatRoomConnections( + store, + profileId, + ({ q, archived }) => q === '' && archived === isArchived, + ).forEach((connectionRecord) => { + ConnectionHandler.deleteNode(connectionRecord, roomId) + const serverEdge = store.getRootField('chatRoomOnRoomUpdate')?.getLinkedRecord('room') + const edge = ConnectionHandler.buildConnectionEdge(store, connectionRecord, serverEdge) + if (edge) { + ConnectionHandler.insertEdgeBefore(connectionRecord, edge) + } + }) + } + }, + onNext: (data: useRoomListSubscription$data | null | undefined) => { + if (wasRemovedFromChatRoom(data)) { + if (selectedRoom && data?.chatRoomOnRoomUpdate?.room?.node?.id === selectedRoom) { + resetChatRoom() + } + onRemoval?.() + sendToast(`You were removed from ${data?.chatRoomOnRoomUpdate?.room?.node?.title}`, { + type: 'info', + }) + } }, } - }, [profileId]) + }, [profileId, connections, onRemoval, selectedRoom, resetChatRoom]) - return useSubscription(config) + return useSubscription(config) } export default useRoomListSubscription diff --git a/packages/components/modules/messages/index.ts b/packages/components/modules/messages/index.ts index e808ad0d..3048a781 100644 --- a/packages/components/modules/messages/index.ts +++ b/packages/components/modules/messages/index.ts @@ -24,16 +24,25 @@ export type * from './GroupDetails/types' export * from './context' -export * from './graphql/mutations/SendMessage' +export * from './graphql/mutations/ArchiveChatRoom' export * from './graphql/mutations/CreateChatRoom' export * from './graphql/mutations/ReadMessages' +export * from './graphql/mutations/SendMessage' +export * from './graphql/mutations/UnreadChat' +export * from './graphql/mutations/UpdateChatRoom' export * from './graphql/queries/ChatRoomQuery' -export * from './graphql/queries/ChatRoomHeaderFragment' -export * from './graphql/queries/MessageItem' -export * from './graphql/queries/MessagesList' -export * from './graphql/queries/Room' -export * from './graphql/queries/RoomsList' +export * from './graphql/queries/ChatRoomsQuery' +export * from './graphql/queries/GroupDetailsQuery' + +export * from './graphql/fragments/LastMessage' +export * from './graphql/fragments/MembersList' +export * from './graphql/fragments/MessageItem' +export * from './graphql/fragments/MessagesList' +export * from './graphql/fragments/Room' +export * from './graphql/fragments/RoomsList' +export * from './graphql/fragments/Title' +export * from './graphql/fragments/UnreadMessagesCount' export { default as useMessagesListSubscription } from './graphql/subscriptions/useMessagesListSubscription' export { default as useMessageCountUpdateSubscription } from './graphql/subscriptions/useMessageCountUpdateSubscription' diff --git a/packages/components/modules/messages/utils.ts b/packages/components/modules/messages/utils.ts index 24fc1c11..ecaca010 100644 --- a/packages/components/modules/messages/utils.ts +++ b/packages/components/modules/messages/utils.ts @@ -1,22 +1,32 @@ import { useCurrentProfile } from '@baseapp-frontend/authentication' -import { ChatRoomHeaderFragment$data } from '../../__generated__/ChatRoomHeaderFragment.graphql' +import { useFragment } from 'react-relay' +import ConnectionHandler from 'relay-connection-handler-plus' +import { RecordProxy, RecordSourceSelectorProxy, Variables } from 'relay-runtime' -export const useNameAndAvatar = (roomHeader: ChatRoomHeaderFragment$data) => { - const { currentProfile } = useCurrentProfile() - if (roomHeader.isGroup) { - return { - title: roomHeader.title, - avatar: roomHeader.image?.url, - } +import { GroupTitleFragment$key } from '../../__generated__/GroupTitleFragment.graphql' +import { RoomTitleFragment$key } from '../../__generated__/RoomTitleFragment.graphql' +import { TitleFragment$data } from '../../__generated__/TitleFragment.graphql' +import { GroupTitleFragment } from './graphql/fragments/GroupTitle' +import { RoomTitleFragment } from './graphql/fragments/RoomTitle' + +export const useGroupNameAndAvatar = (headerRef: GroupTitleFragment$key | null | undefined) => { + const header = useFragment(GroupTitleFragment, headerRef) + return { + title: header?.title, + avatar: header?.image?.url, } - if (!roomHeader.participants) { +} + +const useRoomNameAndAvatar = (headerRef: RoomTitleFragment$key | null | undefined) => { + const { currentProfile } = useCurrentProfile() + const header = useFragment(RoomTitleFragment, headerRef) + if (!header?.participants) { return { title: 'Error: No participants', } } - - const otherParticipant = roomHeader.participants.edges.find( + const otherParticipant = header.participants.edges.find( (edge) => edge?.node?.profile?.id && edge?.node?.profile?.id !== currentProfile?.id, ) return { @@ -25,9 +35,28 @@ export const useNameAndAvatar = (roomHeader: ChatRoomHeaderFragment$data) => { } } +export const useNameAndAvatar = (roomHeader: TitleFragment$data) => { + const roomNameAndAvatar = useRoomNameAndAvatar(roomHeader) + const groupNameAndAvatar = useGroupNameAndAvatar(roomHeader) + if (roomHeader.isGroup) return groupNameAndAvatar + return roomNameAndAvatar +} + export const getParticipantCountString = (participantCount: number | null | undefined) => { if (participantCount !== undefined && participantCount !== null) { return `${participantCount} member${participantCount !== 1 ? 's' : ''}` } return undefined } + +export const getChatRoomConnections: ( + store: RecordSourceSelectorProxy, + profileId: string, + filter?: (variables: Variables) => boolean, +) => RecordProxy[] = (store, profileId, filter) => { + const storyRecord = store.get(profileId) + if (storyRecord) { + return ConnectionHandler.getConnections(storyRecord, 'roomsList_chatRooms', filter) + } + return [] +} diff --git a/packages/components/package.json b/packages/components/package.json index fc189a56..d1bbe950 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -41,6 +41,7 @@ "react-hook-form": "catalog:", "react-relay": "catalog:graphql", "react-virtuoso": "catalog:", + "relay-connection-handler-plus": "^0.1.2", "relay-runtime": "catalog:graphql", "slugify": "^1.6.6", "use-long-press": "^3.2.0", diff --git a/packages/components/schema.graphql b/packages/components/schema.graphql index e3ac3a94..884b61ea 100644 --- a/packages/components/schema.graphql +++ b/packages/components/schema.graphql @@ -103,6 +103,7 @@ type ChatRoom implements Node { image(width: Int!, height: Int!): File lastMessage: Message lastMessageTime: DateTime + participantsCount: Int! isGroup: Boolean! participants(offset: Int, before: String, after: String, first: Int, last: Int): ChatRoomParticipantConnection pk: Int! @@ -172,15 +173,16 @@ type ChatRoomOnNewMessage { type ChatRoomOnRoomUpdate { room: ChatRoomEdge + removedParticipants: [ChatRoomParticipant] } type ChatRoomParticipant implements Node { """The ID of the object""" id: ID! profile: Profile + role: ChatRoomParticipantRoles hasArchivedRoom: Boolean! pk: Int! - role: String } type ChatRoomParticipantConnection { @@ -202,6 +204,15 @@ type ChatRoomParticipantEdge { cursor: String! } +"""An enumeration.""" +enum ChatRoomParticipantRoles { + """member""" + MEMBER + + """admin""" + ADMIN +} + input ChatRoomReadMessagesInput { roomId: ID! profileId: ID! @@ -273,10 +284,10 @@ type ChatRoomUnreadPayload { input ChatRoomUpdateInput { roomId: ID! profileId: ID! - addParticipants: [ID] - deleteImage: Boolean - removeParticipants: [ID] title: String + deleteImage: Boolean = false + addParticipants: [ID] = [] + removeParticipants: [ID] = [] clientMutationId: String } @@ -285,6 +296,7 @@ type ChatRoomUpdatePayload { errors: [ErrorType] _debug: DjangoDebug room: ChatRoomEdge + removedParticipants: [ChatRoomParticipant] clientMutationId: String } @@ -664,11 +676,11 @@ type Mutation { rateCreate(input: RateCreateInput!): RateCreatePayload organizationCreate(input: OrganizationCreateInput!): OrganizationCreatePayload chatRoomCreate(input: ChatRoomCreateInput!): ChatRoomCreatePayload + chatRoomUpdate(input: ChatRoomUpdateInput!): ChatRoomUpdatePayload chatRoomSendMessage(input: ChatRoomSendMessageInput!): ChatRoomSendMessagePayload chatRoomReadMessages(input: ChatRoomReadMessagesInput!): ChatRoomReadMessagesPayload chatRoomUnread(input: ChatRoomUnreadInput!): ChatRoomUnreadPayload chatRoomArchive(input: ChatRoomArchiveInput!): ChatRoomArchivePayload - chatRoomUpdate(input: ChatRoomUpdateInput!): ChatRoomUpdatePayload reportCreate(input: ReportCreateInput!): ReportCreatePayload followToggle(input: FollowToggleInput!): FollowTogglePayload blockToggle(input: BlockToggleInput!): BlockTogglePayload diff --git a/packages/graphql/config/environment.ts b/packages/graphql/config/environment.ts index 89f0a094..1ca70f2d 100644 --- a/packages/graphql/config/environment.ts +++ b/packages/graphql/config/environment.ts @@ -4,6 +4,7 @@ import { getToken } from '@baseapp-frontend/utils/functions/token/getToken' import { createClient } from 'graphql-ws' import WebSocket from 'isomorphic-ws' +import ConnectionHandler from 'relay-connection-handler-plus' import { CacheConfig, Environment, @@ -17,6 +18,9 @@ import { UploadableMap, Variables, } from 'relay-runtime' +import RelayDefaultHandlerProvider, { + HandlerProvider, +} from 'relay-runtime/lib/handlers/RelayDefaultHandlerProvider' const CACHE_TTL = 5 * 1000 // 5 seconds, to resolve preloaded results @@ -151,12 +155,22 @@ function createQueryCache() { const responseCacheByEnvironment = new WeakMap() +function handlerProvider(handle: string) { + switch (handle) { + case 'connection': + return ConnectionHandler + default: + return (RelayDefaultHandlerProvider as unknown as HandlerProvider)(handle) + } +} + export function createEnvironment() { const cache = createQueryCache() const network = createNetwork(cache) const store = new Store(RecordSource.create()) const environment = new Environment({ + handlerProvider, network, store, isServer: typeof window === typeof undefined, diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 47287154..72dee637 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -18,6 +18,7 @@ "isomorphic-ws": "catalog:graphql", "js-cookie": "catalog:", "react-relay": "catalog:graphql", + "relay-connection-handler-plus": "^0.1.2", "relay-runtime": "catalog:graphql", "relay-test-utils": "catalog:graphql" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c6d594b3..58f57d22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -549,6 +549,9 @@ importers: react-virtuoso: specifier: 'catalog:' version: 4.7.11(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + relay-connection-handler-plus: + specifier: ^0.1.2 + version: 0.1.2(relay-runtime@16.2.0) relay-runtime: specifier: catalog:graphql version: 16.2.0 @@ -777,10 +780,10 @@ importers: version: 8.57.1 eslint-config-airbnb: specifier: catalog:lint - version: 19.0.4(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint-plugin-jsx-a11y@6.10.2(eslint@8.57.1))(eslint-plugin-react-hooks@4.6.2(eslint@8.57.1))(eslint-plugin-react@7.37.3(eslint@8.57.1))(eslint@8.57.1) + version: 19.0.4(eslint-plugin-import@2.31.0)(eslint-plugin-jsx-a11y@6.10.2(eslint@8.57.1))(eslint-plugin-react-hooks@4.6.2(eslint@8.57.1))(eslint-plugin-react@7.37.3(eslint@8.57.1))(eslint@8.57.1) eslint-config-airbnb-typescript: specifier: catalog:lint - version: 17.1.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5))(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1) + version: 17.1.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5))(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-plugin-import@2.31.0)(eslint@8.57.1) eslint-config-next: specifier: catalog:lint version: 13.5.8(eslint@8.57.1)(typescript@5.4.5) @@ -789,7 +792,7 @@ importers: version: 8.10.0(eslint@8.57.1) eslint-plugin-import: specifier: catalog:lint - version: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + version: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) eslint-plugin-jsx-a11y: specifier: catalog:lint version: 6.10.2(eslint@8.57.1) @@ -1011,6 +1014,9 @@ importers: react-relay: specifier: catalog:graphql version: 16.2.0(react@18.3.1) + relay-connection-handler-plus: + specifier: ^0.1.2 + version: 0.1.2(relay-runtime@16.2.0) relay-runtime: specifier: catalog:graphql version: 16.2.0 @@ -2175,12 +2181,6 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/preset-react@7.26.3': - resolution: {integrity: sha512-Nl03d6T9ky516DGK2YMxrTqvnpUW63TnJMOMonj+Zae0JiPC5BC9xPMSL6L8fiSpA5vP88qfygavVQvnLp+6Cw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - '@babel/preset-typescript@7.26.0': resolution: {integrity: sha512-NMk1IGZ5I/oHhoXEElcm+xUnL/szL6xflkFZmoEU9xj1qSJXpiS7rsspYo92B4DRCDvZn2erT5LdsCeXAKNCkg==} engines: {node: '>=6.9.0'} @@ -8876,6 +8876,11 @@ packages: resolution: {integrity: sha512-KuyzUBKL9PZRNtIZWNlWEOl7OliUxaGJ2d+3mkiWEiGCEuGnNTxqEg4kJyL341aIGZC4gSqEpfvRTcMqnSM4qQ==} hasBin: true + relay-connection-handler-plus@0.1.2: + resolution: {integrity: sha512-uM0wyjZbh/fwGFI7+0MFrdw2fsSNWQkduH35G3EN4zw9ALZMQ7GeZrr90+vQJ+lKvP9jqzHqLO18i7SKrgowTA==} + peerDependencies: + relay-runtime: '>=9.0.0' + relay-runtime@16.2.0: resolution: {integrity: sha512-SrIyYItH1EZUj37NI8nZALasuq7mNyFrrSNgMefhgxNZxTVnr1KCp43LaxUfZqhsWbw4Y00JSGDRQXlcv4STHQ==} @@ -10341,7 +10346,7 @@ snapshots: '@babel/generator@7.17.7': dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.26.3 jsesc: 2.5.2 source-map: 0.5.7 @@ -11177,18 +11182,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/preset-react@7.26.3(@babel/core@7.26.0)': - dependencies: - '@babel/core': 7.26.0 - '@babel/helper-plugin-utils': 7.25.9 - '@babel/helper-validator-option': 7.25.9 - '@babel/plugin-transform-react-display-name': 7.25.9(@babel/core@7.26.0) - '@babel/plugin-transform-react-jsx': 7.25.9(@babel/core@7.26.0) - '@babel/plugin-transform-react-jsx-development': 7.25.9(@babel/core@7.26.0) - '@babel/plugin-transform-react-pure-annotations': 7.25.9(@babel/core@7.26.0) - transitivePeerDependencies: - - supports-color - '@babel/preset-typescript@7.26.0(@babel/core@7.26.0)': dependencies: '@babel/core': 7.26.0 @@ -11543,7 +11536,7 @@ snapshots: dependencies: '@babel/runtime': 7.26.0 '@emotion/babel-plugin': 11.13.5 - '@emotion/cache': 11.11.0 + '@emotion/cache': 11.14.0 '@emotion/serialize': 1.3.3 '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@18.3.1) '@emotion/utils': 1.4.2 @@ -12140,7 +12133,7 @@ snapshots: '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -12153,14 +12146,14 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@22.7.2)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)) + jest-config: 29.7.0(@types/node@22.10.5)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -12188,14 +12181,14 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@22.7.2)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.7.2)(typescript@5.4.5)) + jest-config: 29.7.0(@types/node@22.10.5)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.7.2)(typescript@5.4.5)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -12224,7 +12217,7 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-mock: 29.7.0 '@jest/expect-utils@29.7.0': @@ -12242,7 +12235,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -12264,7 +12257,7 @@ snapshots: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -12334,7 +12327,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 22.7.2 + '@types/node': 22.10.5 '@types/yargs': 17.0.33 chalk: 4.1.2 @@ -14432,7 +14425,7 @@ snapshots: '@types/graceful-fs@4.1.9': dependencies: - '@types/node': 22.7.2 + '@types/node': 22.10.5 '@types/html-minifier-terser@5.1.2': {} @@ -14465,7 +14458,7 @@ snapshots: '@types/jsdom@20.0.1': dependencies: - '@types/node': 22.7.2 + '@types/node': 22.10.5 '@types/tough-cookie': 4.0.5 parse5: 7.2.1 @@ -15243,7 +15236,7 @@ snapshots: '@babel/plugin-transform-export-namespace-from': 7.25.9(@babel/core@7.26.0) '@babel/plugin-transform-object-rest-spread': 7.25.9(@babel/core@7.26.0) '@babel/plugin-transform-parameters': 7.25.9(@babel/core@7.26.0) - '@babel/preset-react': 7.26.3(@babel/core@7.26.0) + '@babel/preset-react': 7.25.9(@babel/core@7.26.0) '@babel/preset-typescript': 7.26.0(@babel/core@7.26.0) '@react-native/babel-preset': 0.76.5(@babel/core@7.26.0)(@babel/preset-env@7.26.0(@babel/core@7.26.0)) babel-plugin-react-native-web: 0.19.13 @@ -15508,7 +15501,7 @@ snapshots: chrome-launcher@0.15.2: dependencies: - '@types/node': 22.7.2 + '@types/node': 22.10.5 escape-string-regexp: 4.0.0 is-wsl: 2.2.0 lighthouse-logger: 1.4.2 @@ -15519,7 +15512,7 @@ snapshots: chromium-edge-launcher@0.2.0: dependencies: - '@types/node': 22.7.2 + '@types/node': 22.10.5 escape-string-regexp: 4.0.0 is-wsl: 2.2.0 lighthouse-logger: 1.4.2 @@ -15805,12 +15798,12 @@ snapshots: css-loader@6.11.0(webpack@5.93.0(@swc/core@1.10.4(@swc/helpers@0.5.15))): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 - postcss-modules-extract-imports: 3.1.0(postcss@8.4.38) - postcss-modules-local-by-default: 4.2.0(postcss@8.4.38) - postcss-modules-scope: 3.2.1(postcss@8.4.38) - postcss-modules-values: 4.0.0(postcss@8.4.38) + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 + postcss-modules-extract-imports: 3.1.0(postcss@8.4.49) + postcss-modules-local-by-default: 4.2.0(postcss@8.4.49) + postcss-modules-scope: 3.2.1(postcss@8.4.49) + postcss-modules-values: 4.0.0(postcss@8.4.49) postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: @@ -15818,12 +15811,12 @@ snapshots: css-loader@6.11.0(webpack@5.93.0): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 - postcss-modules-extract-imports: 3.1.0(postcss@8.4.38) - postcss-modules-local-by-default: 4.2.0(postcss@8.4.38) - postcss-modules-scope: 3.2.1(postcss@8.4.38) - postcss-modules-values: 4.0.0(postcss@8.4.38) + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 + postcss-modules-extract-imports: 3.1.0(postcss@8.4.49) + postcss-modules-local-by-default: 4.2.0(postcss@8.4.49) + postcss-modules-scope: 3.2.1(postcss@8.4.49) + postcss-modules-values: 4.0.0(postcss@8.4.49) postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: @@ -15831,12 +15824,12 @@ snapshots: css-loader@7.1.2(webpack@5.93.0(@swc/core@1.10.4(@swc/helpers@0.5.15))): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 - postcss-modules-extract-imports: 3.1.0(postcss@8.4.38) - postcss-modules-local-by-default: 4.2.0(postcss@8.4.38) - postcss-modules-scope: 3.2.1(postcss@8.4.38) - postcss-modules-values: 4.0.0(postcss@8.4.38) + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 + postcss-modules-extract-imports: 3.1.0(postcss@8.4.49) + postcss-modules-local-by-default: 4.2.0(postcss@8.4.49) + postcss-modules-scope: 3.2.1(postcss@8.4.49) + postcss-modules-values: 4.0.0(postcss@8.4.49) postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: @@ -15844,12 +15837,12 @@ snapshots: css-loader@7.1.2(webpack@5.93.0): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 - postcss-modules-extract-imports: 3.1.0(postcss@8.4.38) - postcss-modules-local-by-default: 4.2.0(postcss@8.4.38) - postcss-modules-scope: 3.2.1(postcss@8.4.38) - postcss-modules-values: 4.0.0(postcss@8.4.38) + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 + postcss-modules-extract-imports: 3.1.0(postcss@8.4.49) + postcss-modules-local-by-default: 4.2.0(postcss@8.4.49) + postcss-modules-scope: 3.2.1(postcss@8.4.49) + postcss-modules-values: 4.0.0(postcss@8.4.49) postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: @@ -16387,28 +16380,28 @@ snapshots: optionalDependencies: source-map: 0.6.1 - eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1): + eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.31.0)(eslint@8.57.1): dependencies: confusing-browser-globals: 1.0.11 eslint: 8.57.1 - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) object.assign: 4.1.7 object.entries: 1.1.8 semver: 6.3.1 - eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5))(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1): + eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5))(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-plugin-import@2.31.0)(eslint@8.57.1): dependencies: '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5) '@typescript-eslint/parser': 5.62.0(eslint@8.57.1)(typescript@5.4.5) eslint: 8.57.1 - eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) - eslint-config-airbnb@19.0.4(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint-plugin-jsx-a11y@6.10.2(eslint@8.57.1))(eslint-plugin-react-hooks@4.6.2(eslint@8.57.1))(eslint-plugin-react@7.37.3(eslint@8.57.1))(eslint@8.57.1): + eslint-config-airbnb@19.0.4(eslint-plugin-import@2.31.0)(eslint-plugin-jsx-a11y@6.10.2(eslint@8.57.1))(eslint-plugin-react-hooks@4.6.2(eslint@8.57.1))(eslint-plugin-react@7.37.3(eslint@8.57.1))(eslint@8.57.1): dependencies: eslint: 8.57.1 - eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1) eslint-plugin-react: 7.37.3(eslint@8.57.1) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.1) @@ -16422,8 +16415,8 @@ snapshots: '@typescript-eslint/parser': 5.62.0(eslint@8.57.1)(typescript@5.4.5) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1) eslint-plugin-react: 7.37.3(eslint@8.57.1) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.1) @@ -16446,7 +16439,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1): + eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.4.0(supports-color@8.1.1) @@ -16458,22 +16451,22 @@ snapshots: is-glob: 4.0.3 stable-hash: 0.0.4 optionalDependencies: - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): + eslint-module-utils@2.12.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1): dependencies: debug: 3.2.7(supports-color@8.1.1) optionalDependencies: '@typescript-eslint/parser': 5.62.0(eslint@8.57.1)(typescript@5.4.5) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1) + eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): + eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 @@ -16484,7 +16477,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 @@ -17539,9 +17532,9 @@ snapshots: dependencies: safer-buffer: 2.1.2 - icss-utils@5.1.0(postcss@8.4.38): + icss-utils@5.1.0(postcss@8.4.49): dependencies: - postcss: 8.4.38 + postcss: 8.4.49 ieee754@1.2.1: {} @@ -17881,7 +17874,7 @@ snapshots: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.3(babel-plugin-macros@3.1.0) @@ -17970,7 +17963,7 @@ snapshots: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@22.7.2)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)): + jest-config@29.7.0(@types/node@22.10.5)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.7.2)(typescript@5.4.5)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -17995,8 +17988,8 @@ snapshots: slash: 3.0.0 strip-json-comments: 3.1.1 optionalDependencies: - '@types/node': 22.7.2 - ts-node: 10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5) + '@types/node': 22.10.5 + ts-node: 10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.7.2)(typescript@5.4.5) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -18057,7 +18050,7 @@ snapshots: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 '@types/jsdom': 20.0.1 - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-mock: 29.7.0 jest-util: 29.7.0 jsdom: 20.0.3 @@ -18071,7 +18064,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -18081,7 +18074,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 22.7.2 + '@types/node': 22.10.5 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -18120,7 +18113,7 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): @@ -18155,7 +18148,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -18183,7 +18176,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 cjs-module-lexer: 1.4.1 collect-v8-coverage: 1.0.2 @@ -18229,7 +18222,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -18248,7 +18241,7 @@ snapshots: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.7.2 + '@types/node': 22.10.5 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -18263,7 +18256,7 @@ snapshots: jest-worker@29.7.0: dependencies: - '@types/node': 22.7.2 + '@types/node': 22.10.5 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -19552,24 +19545,24 @@ snapshots: possible-typed-array-names@1.0.0: {} - postcss-import@15.1.0(postcss@8.4.38): + postcss-import@15.1.0(postcss@8.4.49): dependencies: - postcss: 8.4.38 + postcss: 8.4.49 postcss-value-parser: 4.2.0 read-cache: 1.0.0 resolve: 1.22.10 - postcss-js@4.0.1(postcss@8.4.38): + postcss-js@4.0.1(postcss@8.4.49): dependencies: camelcase-css: 2.0.1 - postcss: 8.4.38 + postcss: 8.4.49 - postcss-load-config@4.0.2(postcss@8.4.38)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)): + postcss-load-config@4.0.2(postcss@8.4.49)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)): dependencies: lilconfig: 3.1.3 yaml: 2.7.0 optionalDependencies: - postcss: 8.4.38 + postcss: 8.4.49 ts-node: 10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5) postcss-loader@8.1.1(postcss@8.4.38)(typescript@5.4.5)(webpack@5.93.0(@swc/core@1.10.4(@swc/helpers@0.5.15))): @@ -19594,30 +19587,30 @@ snapshots: transitivePeerDependencies: - typescript - postcss-modules-extract-imports@3.1.0(postcss@8.4.38): + postcss-modules-extract-imports@3.1.0(postcss@8.4.49): dependencies: - postcss: 8.4.38 + postcss: 8.4.49 - postcss-modules-local-by-default@4.2.0(postcss@8.4.38): + postcss-modules-local-by-default@4.2.0(postcss@8.4.49): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 postcss-selector-parser: 7.0.0 postcss-value-parser: 4.2.0 - postcss-modules-scope@3.2.1(postcss@8.4.38): + postcss-modules-scope@3.2.1(postcss@8.4.49): dependencies: - postcss: 8.4.38 + postcss: 8.4.49 postcss-selector-parser: 7.0.0 - postcss-modules-values@4.0.0(postcss@8.4.38): + postcss-modules-values@4.0.0(postcss@8.4.49): dependencies: - icss-utils: 5.1.0(postcss@8.4.38) - postcss: 8.4.38 + icss-utils: 5.1.0(postcss@8.4.49) + postcss: 8.4.49 - postcss-nested@6.2.0(postcss@8.4.38): + postcss-nested@6.2.0(postcss@8.4.49): dependencies: - postcss: 8.4.38 + postcss: 8.4.49 postcss-selector-parser: 6.1.2 postcss-selector-parser@6.0.10: @@ -20055,6 +20048,11 @@ snapshots: relay-compiler@16.2.0: {} + relay-connection-handler-plus@0.1.2(relay-runtime@16.2.0): + dependencies: + '@types/relay-runtime': 17.0.3 + relay-runtime: 16.2.0 + relay-runtime@16.2.0: dependencies: '@babel/runtime': 7.26.0 @@ -20774,11 +20772,11 @@ snapshots: normalize-path: 3.0.0 object-hash: 3.0.0 picocolors: 1.1.1 - postcss: 8.4.38 - postcss-import: 15.1.0(postcss@8.4.38) - postcss-js: 4.0.1(postcss@8.4.38) - postcss-load-config: 4.0.2(postcss@8.4.38)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)) - postcss-nested: 6.2.0(postcss@8.4.38) + postcss: 8.4.49 + postcss-import: 15.1.0(postcss@8.4.49) + postcss-js: 4.0.1(postcss@8.4.49) + postcss-load-config: 4.0.2(postcss@8.4.49)(ts-node@10.9.2(@swc/core@1.10.4(@swc/helpers@0.5.15))(@types/node@22.10.5)(typescript@5.4.5)) + postcss-nested: 6.2.0(postcss@8.4.49) postcss-selector-parser: 6.1.2 resolve: 1.22.10 sucrase: 3.35.0 From b5fd8478f4bdba2fb5a82e18d62bec2e2d43619b Mon Sep 17 00:00:00 2001 From: Philipp Schmitt Date: Mon, 20 Jan 2025 17:04:06 +0100 Subject: [PATCH 2/4] BA-2054 Review suggestions --- .../modules/messages/GroupDetails/index.tsx | 61 +++++++++---------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/packages/components/modules/messages/GroupDetails/index.tsx b/packages/components/modules/messages/GroupDetails/index.tsx index 93e62034..8a926730 100644 --- a/packages/components/modules/messages/GroupDetails/index.tsx +++ b/packages/components/modules/messages/GroupDetails/index.tsx @@ -26,30 +26,37 @@ import { GroupMembersEdge } from './ProfileCard/types' import { GroupHeaderContainer, GroupTitleContainer } from './styled' import { GroupDetailsProps } from './types' -const GroupDetails: FC = ({ +const GroupDetails: FC = ({ onBackButtonClicked, onEditButtonClicked, - profileId, queryRef, ProfileCard = DefaultProfileCard, ProfileCardProps = {}, VirtuosoProps = {}, }) => { const { chatRoom: group } = usePreloadedQuery(GroupDetailsQuery, queryRef) + const { currentProfile } = useCurrentProfile() const { avatar, title } = useGroupNameAndAvatar(group) const theme = useTheme() const connections = group?.id ? [ConnectionHandler.getConnectionID(group.id, 'ChatRoom_participants')] : [] - useRoomListSubscription({ profileId, connections, onRemoval: onBackButtonClicked }) + // TODO: Is there a safer way to ensure the current profile id is not undefined? + useRoomListSubscription({ + profileId: currentProfile?.id!, + connections, + onRemoval: onBackButtonClicked, + }) const { data, loadNext, isLoadingNext, hasNext } = usePaginationFragment< ChatRoomParticipantsPaginationQuery, MembersListFragment$key >(MembersListFragment, group) const members = data?.participants - const me = members?.edges.find((edge) => edge?.node?.profile?.id === profileId) + const me = members?.edges.find( + (edge) => currentProfile?.id && edge?.node?.profile?.id === currentProfile?.id, + ) const isAdmin = me?.node?.role === CHAT_ROOM_PARTICIPANT_ROLES.admin const renderLoadingState = () => { @@ -80,12 +87,12 @@ const GroupDetails: FC = ({ } const onRemoveConfirmed = () => { - if (!group?.id) return + if (!group?.id || !currentProfile?.id) return commit({ variables: { input: { roomId: group.id, - profileId, + profileId: currentProfile?.id, removeParticipants: [removingParticipantId], }, connections: [ConnectionHandler.getConnectionID(group.id, 'ChatRoom_participants')], @@ -191,32 +198,22 @@ const GroupDetails: FC = ({ ) } -const WrappedGroupDetails: FC = ({ onBackButtonClicked, ...props }) => { +const SuspendedGroupDetails: FC = ({ onBackButtonClicked, ...props }) => ( // Displays a 'preliminary' header and a spinner below // Header has "Group Details" label and back button, but no edit button (appears if the group details are loaded and current user has admin permissions) - const { currentProfile } = useCurrentProfile() - if (!currentProfile?.id) { - return null - } - return ( - - - - - } - > - - - ) -} + + + + + } + > + + +) -export default WrappedGroupDetails +export default SuspendedGroupDetails From 85a6f189f4860179bd86d0262ed96e503ff6aab1 Mon Sep 17 00:00:00 2001 From: Philipp Schmitt Date: Mon, 20 Jan 2025 17:08:53 +0100 Subject: [PATCH 3/4] BA-2054 Fix rebase error --- packages/components/modules/messages/ChatRoomsList/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/modules/messages/ChatRoomsList/index.tsx b/packages/components/modules/messages/ChatRoomsList/index.tsx index 1b016d0b..4d61f87b 100644 --- a/packages/components/modules/messages/ChatRoomsList/index.tsx +++ b/packages/components/modules/messages/ChatRoomsList/index.tsx @@ -39,6 +39,7 @@ const ChatRoomsList: FC = ({ const { control, reset, watch } = useForm({ defaultValues: { search: '' } }) const isInArchivedTab = tab === CHAT_TAB_VALUES.archived + const isInUnreadTab = tab === CHAT_TAB_VALUES.unread const searchValue = watch('search') const handleSearchChange: ChangeEventHandler = (e) => { From 601b131d35fad1b40cad10335843b9f91b5d9e1d Mon Sep 17 00:00:00 2001 From: Philipp Schmitt Date: Mon, 20 Jan 2025 17:32:24 +0100 Subject: [PATCH 4/4] BA-2054 Installing relay-connection-handler-plus in catalog --- packages/components/CHANGELOG.md | 8 ++++++++ packages/components/package.json | 4 ++-- packages/graphql/CHANGELOG.md | 6 ++++++ packages/graphql/package.json | 4 ++-- packages/wagtail/CHANGELOG.md | 7 +++++++ packages/wagtail/package.json | 2 +- pnpm-lock.yaml | 7 +++++-- pnpm-workspace.yaml | 1 + 8 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index a69f3652..11c0c437 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -1,5 +1,13 @@ # @baseapp-frontend/components +## 0.0.49 + +### Patch Changes + +- Removing chat room members +- Updated dependencies + - @baseapp-frontend/graphql@1.2.2 + ## 0.0.48 ### Patch Changes diff --git a/packages/components/package.json b/packages/components/package.json index d1bbe950..e340aa01 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,7 +1,7 @@ { "name": "@baseapp-frontend/components", "description": "BaseApp components modules such as comments, notifications, messages, and more.", - "version": "0.0.48", + "version": "0.0.49", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false, @@ -41,7 +41,7 @@ "react-hook-form": "catalog:", "react-relay": "catalog:graphql", "react-virtuoso": "catalog:", - "relay-connection-handler-plus": "^0.1.2", + "relay-connection-handler-plus": "catalog:graphql", "relay-runtime": "catalog:graphql", "slugify": "^1.6.6", "use-long-press": "^3.2.0", diff --git a/packages/graphql/CHANGELOG.md b/packages/graphql/CHANGELOG.md index fb067da5..f5f5ff6e 100644 --- a/packages/graphql/CHANGELOG.md +++ b/packages/graphql/CHANGELOG.md @@ -1,5 +1,11 @@ # @baseapp-frontend/graphql +## 1.2.2 + +### Patch Changes + +- Use package relay-connection-handler-plus + ## 1.2.1 ### Patch Changes diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 72dee637..37bf1acd 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -1,7 +1,7 @@ { "name": "@baseapp-frontend/graphql", "description": "GraphQL configurations and utilities", - "version": "1.2.1", + "version": "1.2.2", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false, @@ -18,7 +18,7 @@ "isomorphic-ws": "catalog:graphql", "js-cookie": "catalog:", "react-relay": "catalog:graphql", - "relay-connection-handler-plus": "^0.1.2", + "relay-connection-handler-plus": "catalog:graphql", "relay-runtime": "catalog:graphql", "relay-test-utils": "catalog:graphql" }, diff --git a/packages/wagtail/CHANGELOG.md b/packages/wagtail/CHANGELOG.md index 793125f0..0e5b22c5 100644 --- a/packages/wagtail/CHANGELOG.md +++ b/packages/wagtail/CHANGELOG.md @@ -1,5 +1,12 @@ # @baseapp-frontend/wagtail +## 1.0.16 + +### Patch Changes + +- Updated dependencies + - @baseapp-frontend/graphql@1.2.2 + ## 1.0.15 ### Patch Changes diff --git a/packages/wagtail/package.json b/packages/wagtail/package.json index 7528db63..290727a4 100644 --- a/packages/wagtail/package.json +++ b/packages/wagtail/package.json @@ -1,7 +1,7 @@ { "name": "@baseapp-frontend/wagtail", "description": "BaseApp Wagtail", - "version": "1.0.15", + "version": "1.0.16", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58f57d22..1342a913 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,6 +88,9 @@ catalogs: relay-compiler: specifier: 16.2.0 version: 16.2.0 + relay-connection-handler-plus: + specifier: 0.1.2 + version: 0.1.2 relay-runtime: specifier: 16.2.0 version: 16.2.0 @@ -550,7 +553,7 @@ importers: specifier: 'catalog:' version: 4.7.11(react-dom@18.3.1(react@18.3.1))(react@18.3.1) relay-connection-handler-plus: - specifier: ^0.1.2 + specifier: catalog:graphql version: 0.1.2(relay-runtime@16.2.0) relay-runtime: specifier: catalog:graphql @@ -1015,7 +1018,7 @@ importers: specifier: catalog:graphql version: 16.2.0(react@18.3.1) relay-connection-handler-plus: - specifier: ^0.1.2 + specifier: catalog:graphql version: 0.1.2(relay-runtime@16.2.0) relay-runtime: specifier: catalog:graphql diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d5767433..efc5494b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -40,6 +40,7 @@ catalogs: isomorphic-ws: 5.0.0 react-relay: 16.2.0 relay-compiler: 16.2.0 + relay-connection-handler-plus: 0.1.2 relay-runtime: 16.2.0 relay-test-utils: 17.0.0