From a23667418c667bd798f90f03064cc3c934f5acd6 Mon Sep 17 00:00:00 2001 From: tsl-ps2 Date: Fri, 6 Dec 2024 14:27:12 -0500 Subject: [PATCH 1/3] BA-1809 [FE] Simplify CurrentProfileProvider (#142) * BA-1809 squash all previous commits * BA-1809 Replacing catalogs temporarily, revert later * BA-1809 Fix rebase mistakes * Revert "BA-1809 Replacing catalogs temporarily, revert later" This reverts commit 1071e6e2098c27d40eb28bce840c285805db1b80. * BA-1809 Do not pass currentProfile as props * BA-1809 Fix component tests * BA-1809 Remove duplicated try ... catch * BA-1809 Move useCurrentProfile into authentication package * BA-1809 Remove profileId from Comment props and use useCurrentProfile instead * BA-1809 set current profile in useLogin hook * BA-1809 Fix tests * BA-1809 changesets * BA-1809 pnpm-lock.yaml * BA-1809 Replace catalogs, revert later! * BA-1809 Remove profile id from comment props * BA-1809 Make image paths absolute * BA-1809 Implement remaining gitlab suggestions * BA-1809 Test whether env variable is undefined before using it * tweaks --------- Co-authored-by: Alexandre Anicio --- .../InitialProfileProvider/index.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx diff --git a/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx b/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx new file mode 100644 index 00000000..559c553c --- /dev/null +++ b/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx @@ -0,0 +1,25 @@ +import { FC, PropsWithChildren } from 'react' + +import { useHydrateAtoms } from 'jotai/utils' + +import { MinimalProfile } from '../../../../../../types/profile' +import { profileAtom } from '../../../index' + +export type InitialProfileProp = { + initialProfile: MinimalProfile | null +} + +// Use as: +// +// +// // You're component goes here, it is passed the initialProfile +// +// + +export const InitialProfileProvider: FC = ({ + initialProfile, + children, +}) => { + useHydrateAtoms([[profileAtom, initialProfile]]) + return children +} From 7e72502ba343f9cef9e3c31077517afcede1415c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Tib=C3=BArcio?= Date: Thu, 5 Dec 2024 21:20:43 -0500 Subject: [PATCH 2/3] feat: render newly created chats in chatrooms list --- .../__generated__/ChatRoomsQuery.graphql.ts | 40 +- .../CreateChatRoomMutation.graphql.ts | 581 +++++++++++++---- .../NotificationItemFragment.graphql.ts | 6 +- .../NotificationItemWithQuery.graphql.ts | 4 +- .../RoomsListFragment.graphql.ts | 17 +- .../chatRoomsPaginationQuery.graphql.ts | 78 ++- .../useRoomListSubscription.graphql.ts | 589 ++++++++++++------ .../modules/messages/ChatRoom/index.tsx | 10 +- .../ChatRoomsList/ChatRoomItem/index.tsx | 60 +- .../modules/messages/ChatRoomsList/index.tsx | 3 - .../ChatRoomListItem/index.tsx | 13 +- .../messages/CreateChatRoomList/index.tsx | 10 +- .../messages/CreateChatRoomList/types.ts | 1 + .../graphql/mutations/CreateChatRoom.ts | 7 +- .../messages/graphql/queries/RoomsList.ts | 3 - .../subscriptions/useRoomListSubscription.tsx | 72 +-- packages/components/modules/messages/index.ts | 1 + packages/components/schema.graphql | 20 + 18 files changed, 1051 insertions(+), 464 deletions(-) diff --git a/packages/components/__generated__/ChatRoomsQuery.graphql.ts b/packages/components/__generated__/ChatRoomsQuery.graphql.ts index e06663a2..674901a5 100644 --- a/packages/components/__generated__/ChatRoomsQuery.graphql.ts +++ b/packages/components/__generated__/ChatRoomsQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<12bb950ec6da82dadc271dbb61bc3534>> + * @generated SignedSource<<695af55d052edd1aad2d6691f70c56ea>> * @lightSyntaxTransform * @nogrep */ @@ -137,14 +137,7 @@ const node: ConcreteRequest = (function () { name: 'cursor', storageKey: null, }, - v10 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'unreadMessagesCount', - storageKey: null, - }, - v11 = [ + v10 = [ v1 /*: any*/, { kind: 'Literal', @@ -152,14 +145,14 @@ const node: ConcreteRequest = (function () { value: false, }, ], - v12 = { + v11 = { alias: null, args: null, kind: 'ScalarField', name: 'content', storageKey: null, }, - v13 = [ + v12 = [ { kind: 'Literal', name: 'first', @@ -306,10 +299,9 @@ const node: ConcreteRequest = (function () { { kind: 'InlineFragment', selections: [ - v10 /*: any*/, { alias: null, - args: v11 /*: any*/, + args: v10 /*: any*/, concreteType: 'ChatRoomConnection', kind: 'LinkedField', name: 'chatRooms', @@ -332,7 +324,13 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v0 /*: any*/, - v10 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'unreadMessagesCount', + storageKey: null, + }, v7 /*: any*/, { alias: null, @@ -348,7 +346,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v0 /*: any*/, v12 /*: any*/], + selections: [v0 /*: any*/, v11 /*: any*/], storageKey: null, }, { @@ -410,7 +408,7 @@ const node: ConcreteRequest = (function () { }, { alias: null, - args: v13 /*: any*/, + args: v12 /*: any*/, concreteType: 'MessageConnection', kind: 'LinkedField', name: 'allMessages', @@ -482,7 +480,7 @@ const node: ConcreteRequest = (function () { name: 'isRead', storageKey: null, }, - v12 /*: any*/, + v11 /*: any*/, { alias: null, args: null, @@ -528,7 +526,7 @@ const node: ConcreteRequest = (function () { }, { alias: null, - args: v13 /*: any*/, + args: v12 /*: any*/, filters: null, handle: 'connection', key: 'chatRoom_allMessages', @@ -549,7 +547,7 @@ const node: ConcreteRequest = (function () { }, { alias: null, - args: v11 /*: any*/, + args: v10 /*: any*/, filters: ['q', 'unreadMessages'], handle: 'connection', key: 'roomsList_chatRooms', @@ -569,12 +567,12 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '4a48d3b542ae8a6f07fae291e58e9f8d', + cacheID: 'ef4b0c7849fadb741c400b8acb9ddf75', 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 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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n id\n unreadMessagesCount\n chatRooms(first: 5, unreadMessages: false) {\n edges {\n node {\n id\n unreadMessagesCount\n ...RoomFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\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 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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: 5, unreadMessages: 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', }, } })() diff --git a/packages/components/__generated__/CreateChatRoomMutation.graphql.ts b/packages/components/__generated__/CreateChatRoomMutation.graphql.ts index 24866373..f4ea74b5 100644 --- a/packages/components/__generated__/CreateChatRoomMutation.graphql.ts +++ b/packages/components/__generated__/CreateChatRoomMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<80b9f00795a6e46b6a523659be326c47>> + * @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 ChatRoomCreateInput = { clientMutationId?: string | null | undefined @@ -16,6 +17,7 @@ export type ChatRoomCreateInput = { profileId: string } export type CreateChatRoomMutation$variables = { + connections: ReadonlyArray input: ChatRoomCreateInput } export type CreateChatRoomMutation$data = { @@ -54,6 +56,7 @@ export type CreateChatRoomMutation$data = { } | null | undefined + readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> } | null | undefined @@ -70,147 +73,513 @@ export type CreateChatRoomMutation = { } const node: ConcreteRequest = (function () { - var v0 = [ + var v0 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'connections', + }, + v1 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'input', + }, + v2 = [ { - defaultValue: null, - kind: 'LocalArgument', + kind: 'Variable', name: 'input', + variableName: 'input', }, ], - v1 = { + v3 = { alias: null, args: null, kind: 'ScalarField', name: 'id', storageKey: null, }, - v2 = [ + v4 = [v3 /*: any*/], + v5 = { + alias: null, + args: null, + concreteType: 'ErrorType', + kind: 'LinkedField', + name: 'errors', + plural: true, + selections: [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'field', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'messages', + storageKey: null, + }, + ], + storageKey: null, + }, + v6 = { + alias: null, + args: null, + kind: 'ScalarField', + name: '__typename', + storageKey: null, + }, + v7 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'name', + storageKey: null, + }, + v8 = [ { alias: null, - args: [ - { - kind: 'Variable', - name: 'input', - variableName: 'input', - }, - ], - concreteType: 'ChatRoomCreatePayload', - kind: 'LinkedField', - name: 'chatRoomCreate', - plural: false, - selections: [ - { - alias: null, - args: null, - concreteType: 'ChatRoomEdge', - kind: 'LinkedField', - name: 'room', - plural: false, - selections: [ - { - alias: null, - args: null, - concreteType: 'ChatRoom', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v1 /*: any*/, - { - alias: null, - args: null, - concreteType: 'ChatRoomParticipantConnection', - kind: 'LinkedField', - name: 'participants', - plural: false, - selections: [ - { - 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: [v1 /*: any*/], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'ErrorType', - kind: 'LinkedField', - name: 'errors', - plural: true, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'field', - storageKey: null, - }, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'messages', - storageKey: null, - }, - ], - storageKey: null, - }, - ], + args: null, + kind: 'ScalarField', + name: 'url', storageKey: null, }, + ], + v9 = { + alias: null, + args: [ + { + kind: 'Literal', + name: 'height', + value: 100, + }, + { + kind: 'Literal', + name: 'width', + value: 100, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v8 /*: any*/, + storageKey: 'image(height:100,width:100)', + }, + v10 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'totalCount', + storageKey: null, + }, + v11 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, + }, + v12 = [ + { + kind: 'Literal', + name: 'first', + value: 20, + }, ] return { fragment: { - argumentDefinitions: v0 /*: any*/, + argumentDefinitions: [v0 /*: any*/, v1 /*: any*/], kind: 'Fragment', metadata: null, name: 'CreateChatRoomMutation', - selections: v2 /*: any*/, + selections: [ + { + alias: null, + args: v2 /*: any*/, + concreteType: 'ChatRoomCreatePayload', + kind: 'LinkedField', + name: 'chatRoomCreate', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoomEdge', + kind: 'LinkedField', + name: 'room', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoom', + kind: 'LinkedField', + name: 'node', + plural: false, + selections: [ + v3 /*: any*/, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipantConnection', + kind: 'LinkedField', + name: 'participants', + plural: false, + selections: [ + { + 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: v4 /*: any*/, + storageKey: null, + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + { + args: null, + kind: 'FragmentSpread', + name: 'RoomFragment', + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + v5 /*: any*/, + ], + storageKey: null, + }, + ], type: 'Mutation', abstractKey: null, }, kind: 'Request', operation: { - argumentDefinitions: v0 /*: any*/, + argumentDefinitions: [v1 /*: any*/, v0 /*: any*/], kind: 'Operation', name: 'CreateChatRoomMutation', - selections: v2 /*: any*/, + selections: [ + { + alias: null, + args: v2 /*: any*/, + concreteType: 'ChatRoomCreatePayload', + kind: 'LinkedField', + name: 'chatRoomCreate', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoomEdge', + kind: 'LinkedField', + name: 'room', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoom', + kind: 'LinkedField', + name: 'node', + plural: false, + selections: [ + v3 /*: any*/, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipantConnection', + kind: 'LinkedField', + name: 'participants', + plural: false, + selections: [ + { + 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: [ + v3 /*: any*/, + { + alias: null, + args: null, + concreteType: 'Profile', + kind: 'LinkedField', + name: 'profile', + plural: false, + selections: [ + v3 /*: any*/, + v6 /*: any*/, + v7 /*: any*/, + v9 /*: any*/, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + v10 /*: any*/, + ], + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'unreadMessagesCount', + storageKey: null, + }, + v9 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'lastMessageTime', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'Message', + kind: 'LinkedField', + name: 'lastMessage', + plural: false, + selections: [v3 /*: any*/, v11 /*: any*/], + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: v12 /*: any*/, + concreteType: 'MessageConnection', + kind: 'LinkedField', + name: 'allMessages', + plural: false, + selections: [ + v10 /*: 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: v8 /*: 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: v4 /*: any*/, + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'pk', + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'verb', + storageKey: null, + }, + v6 /*: any*/, + ], + storageKey: null, + }, + { + 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, + }, + ], + storageKey: 'allMessages(first:20)', + }, + { + alias: null, + args: v12 /*: any*/, + filters: null, + handle: 'connection', + key: 'chatRoom_allMessages', + kind: 'LinkedHandle', + name: 'allMessages', + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + { + alias: null, + args: null, + filters: null, + handle: 'prependEdge', + key: '', + kind: 'LinkedHandle', + name: 'room', + handleArgs: [ + { + kind: 'Variable', + name: 'connections', + variableName: 'connections', + }, + ], + }, + v5 /*: any*/, + ], + storageKey: null, + }, + ], }, params: { - cacheID: 'db74448ff08cffbba38c4f8939cb863f', + cacheID: '11bf60080bc3647d363cbfaa9aa6204b', 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 participants {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n errors {\n field\n messages\n }\n }\n}\n', + text: 'mutation CreateChatRoomMutation(\n $input: ChatRoomCreateInput!\n) {\n chatRoomCreate(input: $input) {\n room {\n node {\n id\n participants {\n edges {\n node {\n id\n }\n }\n }\n ...RoomFragment\n }\n }\n errors {\n field\n messages\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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n', }, } })() -;(node as any).hash = '7e43714ac9912309528928e478db1bd2' +;(node as any).hash = '0c8de3803eb96cb2bd64dd751320a8a0' export default node diff --git a/packages/components/__generated__/NotificationItemFragment.graphql.ts b/packages/components/__generated__/NotificationItemFragment.graphql.ts index e8caec9c..8632cf9f 100644 --- a/packages/components/__generated__/NotificationItemFragment.graphql.ts +++ b/packages/components/__generated__/NotificationItemFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<54c65b4705b09eb66456e99dd5901529>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -11,7 +11,7 @@ import { Fragment, ReaderFragment } from 'relay-runtime' import { FragmentRefs } from 'relay-runtime' -export type BaseappNotificationsNotificationLevelChoices = +export type NotificationsNotificationLevelChoices = | 'ERROR' | 'INFO' | 'SUCCESS' @@ -43,7 +43,7 @@ export type NotificationItemFragment$data = { readonly data: any | null | undefined readonly description: string | null | undefined readonly id: string - readonly level: BaseappNotificationsNotificationLevelChoices + readonly level: NotificationsNotificationLevelChoices readonly pk: number readonly target: | { diff --git a/packages/components/__generated__/NotificationItemWithQuery.graphql.ts b/packages/components/__generated__/NotificationItemWithQuery.graphql.ts index 631d1874..302799f5 100644 --- a/packages/components/__generated__/NotificationItemWithQuery.graphql.ts +++ b/packages/components/__generated__/NotificationItemWithQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<2be8361b76383cb89c29eb2821435085>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -302,7 +302,7 @@ const node: ConcreteRequest = (function () { enumValues: ['SUCCESS', 'INFO', 'WARNING', 'ERROR'], nullable: false, plural: false, - type: 'BaseappNotificationsNotificationLevelChoices', + type: 'NotificationsNotificationLevelChoices', }, 'target.pk': { enumValues: null, diff --git a/packages/components/__generated__/RoomsListFragment.graphql.ts b/packages/components/__generated__/RoomsListFragment.graphql.ts index 6290dfa2..a7876f78 100644 --- a/packages/components/__generated__/RoomsListFragment.graphql.ts +++ b/packages/components/__generated__/RoomsListFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<38e0add85315f14cc90ee08389420fe7>> * @lightSyntaxTransform * @nogrep */ @@ -19,7 +19,6 @@ export type RoomsListFragment$data = { readonly node: | { readonly id: string - readonly unreadMessagesCount: number | null | undefined readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> } | null @@ -36,7 +35,6 @@ export type RoomsListFragment$data = { | null | undefined readonly id: string - readonly unreadMessagesCount: number | null | undefined readonly ' $fragmentType': 'RoomsListFragment' } export type RoomsListFragment$key = { @@ -52,13 +50,6 @@ const node: ReaderFragment = (function () { kind: 'ScalarField', name: 'id', storageKey: null, - }, - v2 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'unreadMessagesCount', - storageKey: null, } return { argumentDefinitions: [ @@ -112,8 +103,6 @@ const node: ReaderFragment = (function () { }, name: 'RoomsListFragment', selections: [ - v1 /*: any*/, - v2 /*: any*/, { alias: 'chatRooms', args: [ @@ -150,7 +139,6 @@ const node: ReaderFragment = (function () { plural: false, selections: [ v1 /*: any*/, - v2 /*: any*/, { args: null, kind: 'FragmentSpread', @@ -204,12 +192,13 @@ const node: ReaderFragment = (function () { ], storageKey: null, }, + v1 /*: any*/, ], type: 'ChatRoomsInterface', abstractKey: '__isChatRoomsInterface', } })() -;(node as any).hash = 'cf8dd10e5de039944535e8c431f1adfb' +;(node as any).hash = 'f7a5e744317c2621d3e82752cdd1459b' export default node diff --git a/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts b/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts index 78d2c159..7fea7cbb 100644 --- a/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts +++ b/packages/components/__generated__/chatRoomsPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<0da3b8f334193df5e7fb534994876c50>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -88,14 +88,7 @@ const node: ConcreteRequest = (function () { name: 'id', storageKey: null, }, - v10 = { - alias: null, - args: null, - kind: 'ScalarField', - name: 'unreadMessagesCount', - storageKey: null, - }, - v11 = [ + v10 = [ { kind: 'Variable', name: 'after', @@ -109,7 +102,7 @@ const node: ConcreteRequest = (function () { v6 /*: any*/, v7 /*: any*/, ], - v12 = [ + v11 = [ { alias: null, args: null, @@ -118,7 +111,7 @@ const node: ConcreteRequest = (function () { storageKey: null, }, ], - v13 = { + v12 = { alias: null, args: [ { @@ -136,45 +129,45 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v12 /*: any*/, + selections: v11 /*: any*/, storageKey: 'image(height:100,width:100)', }, - v14 = { + v13 = { alias: null, args: null, kind: 'ScalarField', name: 'content', storageKey: null, }, - v15 = { + v14 = { alias: null, args: null, kind: 'ScalarField', name: 'totalCount', storageKey: null, }, - v16 = { + v15 = { alias: null, args: null, kind: 'ScalarField', name: 'name', storageKey: null, }, - v17 = [ + v16 = [ { kind: 'Literal', name: 'first', value: 20, }, ], - v18 = { + v17 = { alias: null, args: null, kind: 'ScalarField', name: 'cursor', storageKey: null, }, - v19 = { + v18 = { alias: null, args: null, concreteType: 'PageInfo', @@ -258,10 +251,9 @@ const node: ConcreteRequest = (function () { { kind: 'InlineFragment', selections: [ - v10 /*: any*/, { alias: null, - args: v11 /*: any*/, + args: v10 /*: any*/, concreteType: 'ChatRoomConnection', kind: 'LinkedField', name: 'chatRooms', @@ -284,8 +276,14 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v9 /*: any*/, - v10 /*: any*/, - v13 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'unreadMessagesCount', + storageKey: null, + }, + v12 /*: any*/, { alias: null, args: null, @@ -300,7 +298,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'lastMessage', plural: false, - selections: [v9 /*: any*/, v14 /*: any*/], + selections: [v9 /*: any*/, v13 /*: any*/], storageKey: null, }, { @@ -318,7 +316,7 @@ const node: ConcreteRequest = (function () { name: 'participants', plural: false, selections: [ - v15 /*: any*/, + v14 /*: any*/, { alias: null, args: null, @@ -346,8 +344,8 @@ const node: ConcreteRequest = (function () { selections: [ v9 /*: any*/, v8 /*: any*/, - v16 /*: any*/, - v13 /*: any*/, + v15 /*: any*/, + v12 /*: any*/, ], storageKey: null, }, @@ -362,13 +360,13 @@ const node: ConcreteRequest = (function () { }, { alias: null, - args: v17 /*: any*/, + args: v16 /*: any*/, concreteType: 'MessageConnection', kind: 'LinkedField', name: 'allMessages', plural: false, selections: [ - v15 /*: any*/, + v14 /*: any*/, { alias: null, args: null, @@ -402,7 +400,7 @@ const node: ConcreteRequest = (function () { plural: false, selections: [ v9 /*: any*/, - v16 /*: any*/, + v15 /*: any*/, { alias: null, args: [ @@ -421,7 +419,7 @@ const node: ConcreteRequest = (function () { kind: 'LinkedField', name: 'image', plural: false, - selections: v12 /*: any*/, + selections: v11 /*: any*/, storageKey: 'image(height:32,width:32)', }, ], @@ -434,7 +432,7 @@ const node: ConcreteRequest = (function () { name: 'isRead', storageKey: null, }, - v14 /*: any*/, + v13 /*: any*/, { alias: null, args: null, @@ -470,17 +468,17 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v18 /*: any*/, + v17 /*: any*/, ], storageKey: null, }, - v19 /*: any*/, + v18 /*: any*/, ], storageKey: 'allMessages(first:20)', }, { alias: null, - args: v17 /*: any*/, + args: v16 /*: any*/, filters: null, handle: 'connection', key: 'chatRoom_allMessages', @@ -491,17 +489,17 @@ const node: ConcreteRequest = (function () { ], storageKey: null, }, - v18 /*: any*/, + v17 /*: any*/, ], storageKey: null, }, - v19 /*: any*/, + v18 /*: any*/, ], storageKey: null, }, { alias: null, - args: v11 /*: any*/, + args: v10 /*: any*/, filters: ['q', 'unreadMessages'], handle: 'connection', key: 'roomsList_chatRooms', @@ -518,16 +516,16 @@ const node: ConcreteRequest = (function () { ], }, params: { - cacheID: '2498718df6928cbf601ebbe7166e32f4', + cacheID: 'c85e5fe29ec282b3e60ce3840257a16e', id: null, metadata: {}, name: 'chatRoomsPaginationQuery', operationKind: 'query', - text: 'query chatRoomsPaginationQuery(\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_4kOb3U\n id\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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment_4kOb3U on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n id\n unreadMessagesCount\n chatRooms(first: $count, after: $cursor, q: $q, unreadMessages: $unreadMessages) {\n edges {\n node {\n id\n unreadMessagesCount\n ...RoomFragment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n', + text: 'query chatRoomsPaginationQuery(\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_4kOb3U\n id\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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n\nfragment RoomsListFragment_4kOb3U on ChatRoomsInterface {\n __isChatRoomsInterface: __typename\n chatRooms(first: $count, after: $cursor, q: $q, unreadMessages: $unreadMessages) {\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', }, } })() -;(node as any).hash = 'cf8dd10e5de039944535e8c431f1adfb' +;(node as any).hash = 'f7a5e744317c2621d3e82752cdd1459b' export default node diff --git a/packages/components/__generated__/useRoomListSubscription.graphql.ts b/packages/components/__generated__/useRoomListSubscription.graphql.ts index 5c0e2ed9..50389199 100644 --- a/packages/components/__generated__/useRoomListSubscription.graphql.ts +++ b/packages/components/__generated__/useRoomListSubscription.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<9e50394181061b00b8ed07f0387f8602>> * @lightSyntaxTransform * @nogrep */ @@ -9,8 +9,10 @@ /* eslint-disable */ // @ts-nocheck import { ConcreteRequest, GraphQLSubscription } from 'relay-runtime' +import { FragmentRefs } from 'relay-runtime' export type useRoomListSubscription$variables = { + connections: ReadonlyArray profileId: string } export type useRoomListSubscription$data = { @@ -21,38 +23,7 @@ export type useRoomListSubscription$data = { readonly node: | { readonly id: string - readonly participants: - | { - readonly edges: ReadonlyArray< - | { - readonly node: - | { - readonly id: string - readonly profile: - | { - readonly id: string - readonly image: - | { - readonly url: string - } - | null - | undefined - readonly name: string | null | undefined - } - | null - | undefined - } - | null - | undefined - } - | null - | undefined - > - readonly totalCount: number | null | undefined - } - | null - | undefined - readonly unreadMessagesCount: number | null | undefined + readonly ' $fragmentSpreads': FragmentRefs<'RoomFragment'> } | null | undefined @@ -69,187 +40,453 @@ export type useRoomListSubscription = { } const node: ConcreteRequest = (function () { - var v0 = [ - { - defaultValue: null, - kind: 'LocalArgument', - name: 'profileId', - }, - ], - v1 = [ + var v0 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'connections', + }, + v1 = { + defaultValue: null, + kind: 'LocalArgument', + name: 'profileId', + }, + v2 = [ { kind: 'Variable', name: 'profileId', variableName: 'profileId', }, ], - v2 = { + v3 = { alias: null, args: null, kind: 'ScalarField', name: 'id', storageKey: null, }, - v3 = [ + v4 = [ { alias: null, - args: v1 /*: any*/, - concreteType: 'ChatRoomOnRoomUpdate', - kind: 'LinkedField', - name: 'chatRoomOnRoomUpdate', - plural: false, - selections: [ - { - alias: null, - args: null, - concreteType: 'ChatRoomEdge', - kind: 'LinkedField', - name: 'room', - plural: false, - selections: [ - { - alias: null, - args: null, - concreteType: 'ChatRoom', - kind: 'LinkedField', - name: 'node', - plural: false, - selections: [ - v2 /*: any*/, - { - alias: null, - args: v1 /*: any*/, - kind: 'ScalarField', - name: 'unreadMessagesCount', - storageKey: null, - }, - { - alias: null, - args: null, - concreteType: 'ChatRoomParticipantConnection', - kind: 'LinkedField', - name: 'participants', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'totalCount', - storageKey: null, - }, - { - 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: [ - v2 /*: any*/, - { - alias: null, - args: null, - concreteType: 'Profile', - kind: 'LinkedField', - name: 'profile', - plural: false, - selections: [ - v2 /*: any*/, - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'name', - storageKey: null, - }, - { - alias: null, - args: [ - { - kind: 'Literal', - name: 'height', - value: 100, - }, - { - kind: 'Literal', - name: 'width', - value: 100, - }, - ], - concreteType: 'File', - kind: 'LinkedField', - name: 'image', - plural: false, - selections: [ - { - alias: null, - args: null, - kind: 'ScalarField', - name: 'url', - storageKey: null, - }, - ], - storageKey: 'image(height:100,width:100)', - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], - storageKey: null, - }, - ], + args: null, + kind: 'ScalarField', + name: 'url', storageKey: null, }, + ], + v5 = { + alias: null, + args: [ + { + kind: 'Literal', + name: 'height', + value: 100, + }, + { + kind: 'Literal', + name: 'width', + value: 100, + }, + ], + concreteType: 'File', + kind: 'LinkedField', + name: 'image', + plural: false, + selections: v4 /*: any*/, + storageKey: 'image(height:100,width:100)', + }, + v6 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'content', + storageKey: null, + }, + v7 = { + alias: null, + args: null, + kind: 'ScalarField', + name: 'totalCount', + storageKey: null, + }, + v8 = { + alias: null, + args: null, + kind: 'ScalarField', + name: '__typename', + 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*/, + argumentDefinitions: [v0 /*: any*/, v1 /*: any*/], kind: 'Fragment', metadata: null, name: 'useRoomListSubscription', - selections: v3 /*: any*/, + selections: [ + { + alias: null, + args: v2 /*: any*/, + concreteType: 'ChatRoomOnRoomUpdate', + kind: 'LinkedField', + name: 'chatRoomOnRoomUpdate', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoomEdge', + kind: 'LinkedField', + name: 'room', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoom', + kind: 'LinkedField', + name: 'node', + plural: false, + selections: [ + v3 /*: any*/, + { + args: null, + kind: 'FragmentSpread', + name: 'RoomFragment', + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + ], type: 'Subscription', abstractKey: null, }, kind: 'Request', operation: { - argumentDefinitions: v0 /*: any*/, + argumentDefinitions: [v1 /*: any*/, v0 /*: any*/], kind: 'Operation', name: 'useRoomListSubscription', - selections: v3 /*: any*/, + selections: [ + { + alias: null, + args: v2 /*: any*/, + concreteType: 'ChatRoomOnRoomUpdate', + kind: 'LinkedField', + name: 'chatRoomOnRoomUpdate', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoomEdge', + kind: 'LinkedField', + name: 'room', + plural: false, + selections: [ + { + alias: null, + args: null, + concreteType: 'ChatRoom', + kind: 'LinkedField', + name: 'node', + plural: false, + selections: [ + v3 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'unreadMessagesCount', + storageKey: null, + }, + v5 /*: any*/, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'lastMessageTime', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'Message', + kind: 'LinkedField', + name: 'lastMessage', + plural: false, + selections: [v3 /*: any*/, v6 /*: any*/], + storageKey: null, + }, + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'title', + storageKey: null, + }, + { + alias: null, + args: null, + concreteType: 'ChatRoomParticipantConnection', + kind: 'LinkedField', + name: 'participants', + plural: false, + selections: [ + v7 /*: 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: [ + v3 /*: any*/, + { + alias: null, + args: null, + concreteType: 'Profile', + kind: 'LinkedField', + name: 'profile', + plural: false, + selections: [ + v3 /*: any*/, + v8 /*: any*/, + v9 /*: any*/, + v5 /*: any*/, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + { + alias: null, + args: v10 /*: any*/, + concreteType: 'MessageConnection', + kind: 'LinkedField', + name: 'allMessages', + 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*/, + 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: v4 /*: 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: [v3 /*: 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, + }, + { + 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, + }, + ], + storageKey: 'allMessages(first:20)', + }, + { + alias: null, + args: v10 /*: any*/, + filters: null, + handle: 'connection', + key: 'chatRoom_allMessages', + kind: 'LinkedHandle', + name: 'allMessages', + }, + ], + storageKey: null, + }, + ], + storageKey: null, + }, + { + alias: null, + args: null, + filters: null, + handle: 'prependEdge', + key: '', + kind: 'LinkedHandle', + name: 'room', + handleArgs: [ + { + kind: 'Variable', + name: 'connections', + variableName: 'connections', + }, + ], + }, + ], + storageKey: null, + }, + ], }, params: { - cacheID: 'dac3049317997dc691ed9dab91bf01d7', + cacheID: '36f90bda90181b649a4bd7a49f852624', 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 unreadMessagesCount(profileId: $profileId)\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n }\n }\n }\n}\n', + 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 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 participants {\n totalCount\n }\n unreadMessagesCount\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 unreadMessagesCount\n image(width: 100, height: 100) {\n url\n }\n lastMessageTime\n lastMessage {\n id\n content\n }\n title\n participants {\n totalCount\n edges {\n node {\n id\n profile {\n id\n __typename\n name\n image(width: 100, height: 100) {\n url\n }\n }\n }\n }\n }\n ...MessagesListFragment\n}\n', }, } })() -;(node as any).hash = 'd8272abb91ea52f3b85b72d4efb2a6a8' +;(node as any).hash = '0464ef194cb3243175a497ff51e98cf5' export default node diff --git a/packages/components/modules/messages/ChatRoom/index.tsx b/packages/components/modules/messages/ChatRoom/index.tsx index 2791a478..3969bbba 100644 --- a/packages/components/modules/messages/ChatRoom/index.tsx +++ b/packages/components/modules/messages/ChatRoom/index.tsx @@ -35,10 +35,10 @@ const ChatRoom: FC = ({ fetchKey: roomId, }, ) - const { currentProfile: profile } = useCurrentProfile() + const { currentProfile } = useCurrentProfile() const [commitMutation] = useReadMessageMutation() - const prevProfileIdRef = useRef(profile?.id) + const prevProfileIdRef = useRef(currentProfile?.id) const prevRoomIdRef = useRef(chatRoom?.id) useEffect(() => { @@ -57,12 +57,12 @@ const ChatRoom: FC = ({ } hasRunRef.current = true return () => {} - }, [profile?.id, chatRoom?.id]) + }, [currentProfile?.id, chatRoom?.id]) useEffect(() => { - prevProfileIdRef.current = profile?.id + prevProfileIdRef.current = currentProfile?.id prevRoomIdRef.current = chatRoom?.id - }, [profile?.id, chatRoom?.id]) + }, [currentProfile?.id, chatRoom?.id]) // TODO: handle error for chatRoom if (!chatRoom) { diff --git a/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx b/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx index 6e247f01..7cf80223 100644 --- a/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx +++ b/packages/components/modules/messages/ChatRoomsList/ChatRoomItem/index.tsx @@ -90,35 +90,39 @@ const ChatRoomItem: FC = ({ height={48} src={roomData.avatarUrl} /> - + {roomData.title} - - {lastMessage && lastMessageTime && ( - <> - - {formatDate(lastMessageTime)} - - - - {lastMessage} - - - )} - + {lastMessage && lastMessageTime ? ( + + + {formatDate(lastMessageTime)} + + + + {lastMessage} + + + ) : ( +
+ )} = ({ } const { id: selectedRoom, setChatRoom } = useChatRoom() - const chatRooms = useMemo( () => data?.chatRooms?.edges?.filter((edge) => edge?.node).map((edge) => edge?.node) || [], [data?.chatRooms?.edges], ) useRoomListSubscription(data.id) - useMessageCountUpdate() // TODO: keep this until we fix the chatRoomOnRoomUpdate subscription const renderItem = useCallback( (room: ChatRoomNode) => { diff --git a/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx b/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx index 619a6e72..5254243a 100644 --- a/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx +++ b/packages/components/modules/messages/CreateChatRoomList/ChatRoomListItem/index.tsx @@ -7,10 +7,9 @@ import { AvatarWithPlaceholder } from '@baseapp-frontend/design-system' import { LoadingButton } from '@mui/lab' import { Box, Typography } from '@mui/material' -import { useFragment } from 'react-relay' +import { ConnectionHandler, useFragment } from 'react-relay' import { ProfileItemFragment } from '../../../profiles/graphql/queries/ProfileItem' -import { useChatRoom } from '../../context' import { useCreateChatRoomMutation } from '../../graphql/mutations/CreateChatRoom' import { MainContainer } from './styled' import { ChatRoomListItemProps } from './types' @@ -23,7 +22,6 @@ const ChatRoomListItem: FC = ({ const [commit, isMutationInFlight] = useCreateChatRoomMutation() const { currentProfile } = useCurrentProfile() - const { setChatRoom } = useChatRoom() return ( @@ -48,9 +46,14 @@ const ChatRoomListItem: FC = ({ commit({ variables: { input: { profileId: currentProfile.id, participants: [id] }, + connections: [ + // TODO: add filter handling (for now we can default 'unreadMessages' to false) + ConnectionHandler.getConnectionID(currentProfile.id, 'roomsList_chatRooms', { + unreadMessages: false, + }), + ], }, - onCompleted: (data) => { - setChatRoom({ id: data?.chatRoomCreate?.room?.node?.id }) + onCompleted: () => { setIsInExistingChatRoomsView(true) }, }) diff --git a/packages/components/modules/messages/CreateChatRoomList/index.tsx b/packages/components/modules/messages/CreateChatRoomList/index.tsx index f8cf7f1b..6f6658b3 100644 --- a/packages/components/modules/messages/CreateChatRoomList/index.tsx +++ b/packages/components/modules/messages/CreateChatRoomList/index.tsx @@ -2,6 +2,7 @@ import { ChangeEventHandler, FC, useMemo, useTransition } from 'react' +import { useCurrentProfile } from '@baseapp-frontend/authentication' import { AvatarWithPlaceholder, Searchbar as DefaultSearchbar, @@ -18,7 +19,7 @@ import SearchNotFoundState from '../SearchNotFoundState' import DefaultChatRoomListItem from './ChatRoomListItem' import EmptyProfilesListState from './EmptyProfilesListState' import { GroupChatContainer, MainContainer, SearchbarContainer } from './styled' -import { CreateChatRoomListProps, ProfileNode } from './types' +import { CreateChatRoomListProps, ProfileEdge, ProfileNode } from './types' const CreateChatRoomList: FC = ({ allProfilesRef, @@ -39,6 +40,8 @@ const CreateChatRoomList: FC = ({ const [isPending, startTransition] = useTransition() const { control, reset, watch } = useForm({ defaultValues: { search: '' } }) + const { currentProfile } = useCurrentProfile() + const handleSearchChange: ChangeEventHandler = (e) => { const value = e.target.value || '' startTransition(() => { @@ -54,7 +57,10 @@ const CreateChatRoomList: FC = ({ } const profiles = useMemo( - () => allProfiles?.edges.filter((edge: any) => edge?.node).map((edge: any) => edge?.node) || [], + () => + allProfiles?.edges + .filter((edge: ProfileEdge) => edge?.node && edge.node.id !== currentProfile?.id) + .map((edge: ProfileEdge) => edge?.node) || [], [allProfiles], ) diff --git a/packages/components/modules/messages/CreateChatRoomList/types.ts b/packages/components/modules/messages/CreateChatRoomList/types.ts index 3ee2c930..41eda573 100644 --- a/packages/components/modules/messages/CreateChatRoomList/types.ts +++ b/packages/components/modules/messages/CreateChatRoomList/types.ts @@ -10,6 +10,7 @@ import { ChatRoomListItemProps } from './ChatRoomListItem/types' type AllProfiles = NonNullable type AllProfilesEdges = AllProfiles['edges'] +export type ProfileEdge = AllProfilesEdges[number] export type ProfileNode = NonNullable['node'] export interface CreateChatRoomListProps extends PropsWithChildren { diff --git a/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts b/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts index 644a233b..1809b800 100644 --- a/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts +++ b/packages/components/modules/messages/graphql/mutations/CreateChatRoom.ts @@ -6,9 +6,9 @@ import { CreateChatRoomMutation } from '../../../../__generated__/CreateChatRoom import { useChatRoom } from '../../context' export const CreateChatRoomMutationQuery = graphql` - mutation CreateChatRoomMutation($input: ChatRoomCreateInput!) { + mutation CreateChatRoomMutation($input: ChatRoomCreateInput!, $connections: [ID!]!) { chatRoomCreate(input: $input) { - room { + room @prependEdge(connections: $connections) { node { id participants { @@ -18,6 +18,7 @@ export const CreateChatRoomMutationQuery = graphql` } } } + ...RoomFragment } } errors { @@ -48,7 +49,7 @@ export const useCreateChatRoomMutation = (): [ setChatRoom({ id: response?.chatRoomCreate?.room?.node?.id, participants: response?.chatRoomCreate?.room?.node?.participants?.edges?.map( - (edge) => edge?.node && edge.node.id, + (edge: any) => edge?.node?.id, ), }) diff --git a/packages/components/modules/messages/graphql/queries/RoomsList.ts b/packages/components/modules/messages/graphql/queries/RoomsList.ts index 797276f7..41dd34d5 100644 --- a/packages/components/modules/messages/graphql/queries/RoomsList.ts +++ b/packages/components/modules/messages/graphql/queries/RoomsList.ts @@ -12,14 +12,11 @@ export const RoomsListFragment = graphql` unreadMessages: { type: "Boolean", defaultValue: false } ) @refetchable(queryName: "chatRoomsPaginationQuery") { - id - unreadMessagesCount chatRooms(first: $count, after: $cursor, q: $q, unreadMessages: $unreadMessages) @connection(key: "roomsList_chatRooms") { edges { node { id - unreadMessagesCount ...RoomFragment } } diff --git a/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx b/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx index ffb5807b..fe80a400 100644 --- a/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx +++ b/packages/components/modules/messages/graphql/subscriptions/useRoomListSubscription.tsx @@ -1,72 +1,38 @@ import { useMemo } from 'react' -import { useCurrentProfile } from '@baseapp-frontend/authentication' - import { ConnectionHandler, graphql, useSubscription } from 'react-relay' -import { RecordSourceSelectorProxy } from 'relay-runtime' -const RoomListSubscription = graphql` - subscription useRoomListSubscription($profileId: ID!) { +const RoomListSubscriptionQuery = graphql` + subscription useRoomListSubscription($profileId: ID!, $connections: [ID!]!) { chatRoomOnRoomUpdate(profileId: $profileId) { - room { + room @prependEdge(connections: $connections) { node { id - unreadMessagesCount(profileId: $profileId) - participants { - totalCount - edges { - node { - id - profile { - id - name - image(width: 100, height: 100) { - url - } - } - } - } - } + ...RoomFragment } } } } ` -// TODO: check if BE subscription is working properly -const useRoomListSubscription = (nodeId: string) => { - const { currentProfile: profile } = useCurrentProfile() - const config = useMemo( - () => ({ - subscription: RoomListSubscription, +const useRoomListSubscription = (profileId: string) => { + const config = useMemo(() => { + // TODO: add filter handling (for now we can default 'unreadMessages' to false) + const connectionIdActive = ConnectionHandler.getConnectionID(profileId, 'roomsList_chatRooms', { + unreadMessages: false, + }) + const connectionIdUnread = ConnectionHandler.getConnectionID(profileId, 'roomsList_chatRooms', { + unreadMessages: true, + }) + return { + subscription: RoomListSubscriptionQuery, onError: console.error, variables: { - profileId: profile?.id, - }, - updater: (store: RecordSourceSelectorProxy, data: any) => { - const node = store.get(nodeId) - if (!node || !data) return null - const connectionRecord = ConnectionHandler.getConnection(node, 'roomsList_chatRooms') - const roomId = data?.chatRoomOnRoomUpdate?.room?.node?.id - if (!connectionRecord || !roomId) return null - - ConnectionHandler.deleteNode(connectionRecord, roomId) - - const payload = store.getRootField('chatRoomOnRoomUpdate') - - const room = payload?.getLinkedRecord('room') - - const newEdge = ConnectionHandler.buildConnectionEdge(store, connectionRecord, room) - - if (!newEdge) return null - - ConnectionHandler.insertEdgeBefore(connectionRecord, newEdge) - - return null + profileId, + connections: [connectionIdActive, connectionIdUnread], }, - }), - [nodeId, profile?.id], - ) + } + }, [profileId]) return useSubscription(config) } diff --git a/packages/components/modules/messages/index.ts b/packages/components/modules/messages/index.ts index 50a8d1df..e81e7811 100644 --- a/packages/components/modules/messages/index.ts +++ b/packages/components/modules/messages/index.ts @@ -27,3 +27,4 @@ export * from './graphql/queries/RoomsList' export { default as useMessagesListSubscription } from './graphql/subscriptions/useMessagesListSubscription' export { default as useMessageCountUpdateSubscription } from './graphql/subscriptions/useMessageCountUpdateSubscription' +export { default as useRoomListSubscription } from './graphql/subscriptions/useRoomListSubscription' diff --git a/packages/components/schema.graphql b/packages/components/schema.graphql index 2de5c148..b20acf89 100644 --- a/packages/components/schema.graphql +++ b/packages/components/schema.graphql @@ -107,6 +107,22 @@ type ChatRoom implements Node { verb: Verbs ): MessageConnection unreadMessagesCount(profileId: ID): Int + isArchivedByCurrentProfile: Boolean +} + +input ChatRoomArchiveInput { + roomId: ID! + profileId: ID! + archive: Boolean! + clientMutationId: String +} + +type ChatRoomArchivePayload { + """May contain more than one error for same field.""" + errors: [ErrorType] + _debug: DjangoDebug + room: ChatRoom + clientMutationId: String } type ChatRoomConnection { @@ -173,6 +189,7 @@ type ChatRoomParticipant implements Node { """ id: ID! profile: Profile + hasArchivedRoom: Boolean! pk: Int! } @@ -261,6 +278,7 @@ interface ChatRoomsInterface { orderBy: String profileId: String unreadMessages: Boolean + archived: Boolean ): ChatRoomConnection unreadMessagesCount: Int } @@ -756,6 +774,7 @@ type Mutation { chatRoomCreate(input: ChatRoomCreateInput!): ChatRoomCreatePayload chatRoomSendMessage(input: ChatRoomSendMessageInput!): ChatRoomSendMessagePayload chatRoomReadMessages(input: ChatRoomReadMessagesInput!): ChatRoomReadMessagesPayload + chatRoomArchive(input: ChatRoomArchiveInput!): ChatRoomArchivePayload reportCreate(input: ReportCreateInput!): ReportCreatePayload followToggle(input: FollowToggleInput!): FollowTogglePayload blockToggle(input: BlockToggleInput!): BlockTogglePayload @@ -1350,6 +1369,7 @@ type Profile implements Node & PermissionsInterface & PageInterface & FollowsInt orderBy: String profileId: String unreadMessages: Boolean + archived: Boolean ): ChatRoomConnection unreadMessagesCount: Int pk: Int! From 32c764fcc564641e9f490c173a19933fd99b1169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Tib=C3=BArcio?= Date: Tue, 10 Dec 2024 16:01:21 -0500 Subject: [PATCH 3/3] chore: versioning --- .../InitialProfileProvider/index.tsx | 25 ------------------- packages/components/CHANGELOG.md | 8 ++++++ packages/components/package.json | 2 +- 3 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx diff --git a/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx b/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx deleted file mode 100644 index 559c553c..00000000 --- a/packages/authentication/modules/profile/useCurrentProfile/__tests__/__utils__/InitialProfileProvider/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { FC, PropsWithChildren } from 'react' - -import { useHydrateAtoms } from 'jotai/utils' - -import { MinimalProfile } from '../../../../../../types/profile' -import { profileAtom } from '../../../index' - -export type InitialProfileProp = { - initialProfile: MinimalProfile | null -} - -// Use as: -// -// -// // You're component goes here, it is passed the initialProfile -// -// - -export const InitialProfileProvider: FC = ({ - initialProfile, - children, -}) => { - useHydrateAtoms([[profileAtom, initialProfile]]) - return children -} diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 1f75c909..20140d78 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -1,5 +1,13 @@ # @baseapp-frontend/components +## 0.0.29 + +### Patch Changes + +- Fixed RoomListSubscription connection and added connection to CreateChatRoom mutation +- Moved useRoomListSubscription hook to ChatRoom on baseapp-frontend-template +- Removed unused fields on RoomsListFragment and RoomListSubscription + ## 0.0.28 ### Patch Changes diff --git a/packages/components/package.json b/packages/components/package.json index b2f6724e..8e8d19f3 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.28", + "version": "0.0.29", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false,