diff --git a/apps/backend/src/user/user.service.ts b/apps/backend/src/user/user.service.ts
index 3419927d..af6499b1 100644
--- a/apps/backend/src/user/user.service.ts
+++ b/apps/backend/src/user/user.service.ts
@@ -419,7 +419,8 @@ export class UserService {
async userPatch(userId: number, data: ReqUserPatchDto) {
// Wrap everything in a transaction (if one call fails, then they all roll back - making every
// call to the DB dependent on each other)
- return await this.prisma.$transaction(async (tx) => {
+
+ const res = await this.prisma.$transaction(async (tx) => {
const newData: Prisma.UserUpdateInput = {};
if (data.name !== undefined) {
@@ -551,9 +552,6 @@ export class UserService {
},
});
- // After updating the user we need to resync the chat rooms he is in
- await this.chatGateway.resyncUserRooms(userId);
-
return {
...user_raw,
createdAt: user_raw.createdAt.toISOString(),
@@ -568,6 +566,10 @@ export class UserService {
})),
};
});
+
+ // After updating the user we need to resync the chat rooms he is in
+ await this.chatGateway.resyncUserRooms(userId);
+ return res;
}
/**
diff --git a/apps/frontend/src/features/chat/ChatBox.tsx b/apps/frontend/src/features/chat/ChatBox.tsx
index 2ad50ee8..8506a2ce 100644
--- a/apps/frontend/src/features/chat/ChatBox.tsx
+++ b/apps/frontend/src/features/chat/ChatBox.tsx
@@ -160,11 +160,10 @@ export const ChatBox = ({ conversationId }: { conversationId: string }) => {
if (
viewport.scrollTop < 100 &&
hasMore &&
- messages.length > 0 &&
+ messages.length >= 10 && // initial load value
!isLoadingMoreHistory.current
) {
isLoadingMoreHistory.current = true;
- isLoadingMoreHistory.current = true;
const currentMessages = messagesRef.current;
if (!currentMessages.length) return;
@@ -192,7 +191,7 @@ export const ChatBox = ({ conversationId }: { conversationId: string }) => {
hasMore &&
!isInitialLoad.current &&
!isLoadingMoreHistory.current &&
- messages.length > 0
+ messages.length >= 10 // initial load value
) {
isLoadingMoreHistory.current = true;
const oldest = messages[0];
@@ -230,11 +229,7 @@ export const ChatBox = ({ conversationId }: { conversationId: string }) => {
Error
{errorMessage}
- void navigate('/chat')}
- />
+ void navigate('/chat')} />
>
);
}