From f9da7622538d0d73a974ad91b999eba26da8d357 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 14 Jul 2023 10:42:20 +0200 Subject: [PATCH 1/4] implemented chat seed --- backend/src/db/seed.ts | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/backend/src/db/seed.ts b/backend/src/db/seed.ts index a717ff7a6..425c9e28c 100644 --- a/backend/src/db/seed.ts +++ b/backend/src/db/seed.ts @@ -11,6 +11,8 @@ import { changeGroupMemberRoleMutation, } from '../graphql/groups' import { createPostMutation } from '../graphql/posts' +import { createRoomMutation } from '../graphql/rooms' +import { createMessageMutation } from '../graphql/messages' import { createCommentMutation } from '../graphql/comments' import { categories } from '../constants/categories' @@ -1553,6 +1555,90 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] ) await Factory.build('donations') + + // Chat + authenticatedUser = await huey.toJson() + const { data: roomHueyPeter } = await mutate({ + mutation: createRoomMutation(), + variables: { + userId: (await peterLustig.toJson()).id, + }, + }) + + for (let i = 0; i < 30; i++) { + authenticatedUser = await huey.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: roomHueyPeter?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + authenticatedUser = await peterLustig.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: roomHueyPeter?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + } + + authenticatedUser = await huey.toJson() + const { data: roomHueyJenny } = await mutate({ + mutation: createRoomMutation(), + variables: { + userId: (await jennyRostock.toJson()).id, + }, + }) + for (let i = 0; i < 10000; i++) { + authenticatedUser = await huey.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: roomHueyJenny?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + authenticatedUser = await jennyRostock.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: roomHueyJenny?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + } + + for (const user of additionalUsers) { + authenticatedUser = await jennyRostock.toJson() + const { data: room } = await mutate({ + mutation: createRoomMutation(), + variables: { + userId: (await user.toJson()).id, + }, + }) + + for (let i = 0; i < 30; i++) { + authenticatedUser = await jennyRostock.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: room?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + authenticatedUser = await user.toJson() + await mutate({ + mutation: createMessageMutation(), + variables: { + roomId: room?.CreateRoom.id, + content: faker.lorem.sentence(), + }, + }) + } + } + /* eslint-disable-next-line no-console */ console.log('Seeded Data...') await driver.close() From eae7b53adf79de8e87ee1fa1acf050de9e36b540 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 14 Jul 2023 10:56:02 +0200 Subject: [PATCH 2/4] reduce message count to 1000 instead of 10000 to reduce seed time --- backend/src/db/seed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/db/seed.ts b/backend/src/db/seed.ts index 425c9e28c..cf3f43ee9 100644 --- a/backend/src/db/seed.ts +++ b/backend/src/db/seed.ts @@ -1591,7 +1591,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] userId: (await jennyRostock.toJson()).id, }, }) - for (let i = 0; i < 10000; i++) { + for (let i = 0; i < 1000; i++) { authenticatedUser = await huey.toJson() await mutate({ mutation: createMessageMutation(), From 55b3bc999a57588e90ba90fba71052b83d919e3e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 14 Jul 2023 10:59:38 +0200 Subject: [PATCH 3/4] use a prime for seeding to allow testing of the pagination --- backend/src/db/seed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/db/seed.ts b/backend/src/db/seed.ts index cf3f43ee9..7286683dd 100644 --- a/backend/src/db/seed.ts +++ b/backend/src/db/seed.ts @@ -1619,7 +1619,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] }, }) - for (let i = 0; i < 30; i++) { + for (let i = 0; i < 29; i++) { authenticatedUser = await jennyRostock.toJson() await mutate({ mutation: createMessageMutation(), From 5dfdcc9bc2e77cde65d9c2f0ef4970ed5b07c952 Mon Sep 17 00:00:00 2001 From: elweyn Date: Sat, 15 Jul 2023 19:00:46 +0200 Subject: [PATCH 4/4] fix(webapp): show room header images. --- webapp/components/Chat/Chat.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/components/Chat/Chat.vue b/webapp/components/Chat/Chat.vue index 95bf5da95..6cacd7090 100644 --- a/webapp/components/Chat/Chat.vue +++ b/webapp/components/Chat/Chat.vue @@ -188,10 +188,10 @@ export default { }, methods: { async fetchMessages({ room, options = {} }) { - if (this.selectedRoom !== room.id) { + if (this.selectedRoom?.id !== room.id) { this.messages = [] this.messagePage = 0 - this.selectedRoom = room.id + this.selectedRoom = room } this.messagesLoaded = options.refetch ? this.messagesLoaded : false const offset = (options.refetch ? 0 : this.messagePage) * this.messagePageSize