Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(),
Expand All @@ -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;
}

/**
Expand Down
11 changes: 3 additions & 8 deletions apps/frontend/src/features/chat/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -230,11 +229,7 @@ export const ChatBox = ({ conversationId }: { conversationId: string }) => {
<AlertTitle>Error</AlertTitle>
<AlertDescription>{errorMessage}</AlertDescription>
</Alert>
<BackButton
className="w-"
label="Back to all Chats"
onClick={() => void navigate('/chat')}
/>
<BackButton label="Back to all Chats" onClick={() => void navigate('/chat')} />
</>
);
}
Expand Down
Loading