Skip to content

Commit

Permalink
merge blocked messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Wadie-ess committed Nov 15, 2023
1 parent 64fb6d6 commit 6d37c06
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 35 deletions.
2 changes: 1 addition & 1 deletion backend/code/src/rooms/rooms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export class RoomsService {
},
},
});

const dmsData: DMsData[] = await Promise.all(
rooms.map(async (room) => {
const secondMember = room.members.find(
Expand Down
5 changes: 4 additions & 1 deletion backend/code/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export class UsersController {
@Get('search')
@HttpCode(HttpStatus.OK)
@UseGuards(AtGuard)
async getUsers(@Query() query: usersSearchDto, @GetCurrentUser('userId') userId: string) {
async getUsers(
@Query() query: usersSearchDto,
@GetCurrentUser('userId') userId: string,
) {
return this.usersService.getUsers(query.q, userId);
}

Expand Down
4 changes: 2 additions & 2 deletions backend/code/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export class UsersService {
blocked_by_id: currentUserId,
},
},
}
]
},
],
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChatType, useChatStore } from "../Controllers/RoomChatControllers";

import { ChatPlaceHolder, ConfirmationModal } from "./RoomChatHelpers";
import { KeyboardEvent } from "react";
import { createNewRoomCall, leaveRoomCall } from "../Services/ChatServices";
import { leaveRoomCall } from "../Services/ChatServices";
import toast from "react-hot-toast";
import { useModalStore } from "../Controllers/LayoutControllers";
import {
Expand All @@ -24,7 +24,6 @@ import { useUserStore } from "../../../Stores/stores";
import { formatTime } from "./tools/utils";
import { useSocketStore } from "../Services/SocketsServices";
import { useNavigate } from "react-router-dom";
import { useInView } from "react-intersection-observer";
import { blockUserCall } from "../Services/FriendsServices";
import { InvitationWaiting } from "../../Layout/Assets/Invitationacceptance";

Expand Down Expand Up @@ -359,9 +358,6 @@ export const ConversationHeader: React.FC<ConversationProps> = ({
export const Conversation: React.FC<ConversationProps> = ({
onRemoveUserPreview,
}) => {
const [ref, inView] = useInView();
const [EndOfFetching, setEndOfFetching] = useState(false);

const chatState = useChatStore();
const messageContainerRef = useRef<HTMLDivElement>(null);
const socketStore = useSocketStore();
Expand Down
2 changes: 2 additions & 0 deletions frontend/code/src/Components/Chat/Components/RecentChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ export const RecentConversations = () => {
}
}
});
// eslint-disable-next-line
}, [ChatRoomsState.recentDms]);

useEffect(() => {
fetchRecentDms();
return () => {
setEndOfFetching(false);
};
// eslint-disable-next-line
}, []);

useEffect(() => {
Expand Down
17 changes: 4 additions & 13 deletions frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const RoomChatPlaceHolder = () => {
}
}
});
// eslint-disable-next-line
}, [
ChatRoomsState.recentRooms,
setIsLoading,
Expand All @@ -105,6 +106,7 @@ export const RoomChatPlaceHolder = () => {
setEndOfFetching(false);
ChatRoomsState.fillRecentRooms([]);
};
// eslint-disable-next-line
}, [ChatRoomsState.selectedChatType, ChatRoomsState.recentRoomsOnchange]);

useEffect(() => {
Expand Down Expand Up @@ -199,7 +201,6 @@ export const CreateNewRoomModal = () => {
setName(event.target.value);
};

const createNewRoom = useChatStore((state) => state.createNewRoom);
const [selectedOption, setSelectedOption] = useState(RoomType.public);
const setIsLoading = useChatStore((state) => state.setIsLoading);
const chatState = useChatStore((state) => state);
Expand Down Expand Up @@ -540,9 +541,6 @@ export const BlockedUsersModal = () => {
};

export const FriendStatusTile = (props: { user: RoomMember }) => {
const [IsAdding, setIsAdding] = useState(false);
const selectedChatID = useChatStore((state) => state.selectedChatID);
const LayoutState = useModalStore((state) => state);
const user = props.user;
const [onlineStatus, setOnlineStatus] = useState<string>("offline");
const socketStore = useSocketStore((state) => state);
Expand Down Expand Up @@ -601,7 +599,6 @@ export const FriendStatusTile = (props: { user: RoomMember }) => {

export const FriendsListModal = () => {
const [currentFriends, setUsers] = useState<RoomMember[]>([]);
const [onlineStatus, setOnlineStatus] = useState<string>("offline");

const LayoutState = useModalStore((state) => state);
const [IsLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -701,15 +698,10 @@ export const AddUsersModal = () => {
const [skipCount, setSkipCount] = useState(true);
const ChatState = useChatStore((state) => state);

const [ref, inView] = useInView();
const [EndOfFetching, setEndOfFetching] = useState(false);

useEffect(() => {
if (skipCount) setSkipCount(false);
if (!skipCount) {
const fetchData = async () => {
const offset = currentFriends.length;

try {
setIsLoading(true);

Expand Down Expand Up @@ -760,9 +752,8 @@ export const AddUsersModal = () => {
console.error("Error fetching data: ", error);
}
};
if (!EndOfFetching) {
fetchData();
}

fetchData();
}
// eslint-disable-next-line
}, [LayoutState.showAddUsersModal]);
Expand Down
7 changes: 2 additions & 5 deletions frontend/code/src/Components/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getRoomMembersCall } from "./Services/ChatServices";

import { classNames } from "../../Utils/helpers";
import { useModalStore } from "./Controllers/LayoutControllers";
import { useInView } from "react-intersection-observer";

import { useNavigate } from "react-router-dom";

export interface ConversationProps {
Expand All @@ -41,7 +41,6 @@ export const Chat = () => {
const showChatRooms = useChatStore((state) => state.showChatRooms);
const toggleChatRooms = useChatStore((state) => state.toggleChatRooms);

const chatRooms = useChatStore((state) => state.recentRooms);
const handleRemoveUserPreview = () => {
setShowUserPreview(!showUserPreview);
};
Expand Down Expand Up @@ -210,9 +209,7 @@ export const UserPreviewCard: React.FC<ConversationProps> = ({
<div className="mask mask-squircle w-11 h-11">
<button
onClick={async () => {
{
navigate(`/profile/${user.id}`);
}
navigate(`/profile/${user.id}`);
}}
>
<img
Expand Down
4 changes: 1 addition & 3 deletions frontend/code/src/Components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import {
ShowLogoModal,
} from "../Chat/Components/RoomChatHelpers";
import { Modal } from "./Assets/Modal";
import toast from "react-hot-toast";
import { closeWhite } from "../Chat/Components/tools/Assets";
import { useChatStore } from "../Chat/Controllers/RoomChatControllers";

import { InvitationGame } from "./Assets/Invitationmodale";

const routes = [
Expand Down
7 changes: 2 additions & 5 deletions frontend/code/src/Components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import {
} from "../Chat/Controllers/RoomChatControllers";
import { More } from "../Chat/Components/tools/Assets";
import { useModalStore } from "../Chat/Controllers/LayoutControllers";
import {
BlockedUsersModal,
FriendsListModal,
} from "../Chat/Components/RoomChatHelpers";

import { blockUserCall } from "../Chat/Services/FriendsServices";
import { AxiosError } from "axios";
import { InvitationWaiting } from "../Layout/Assets/Invitationacceptance";
Expand Down Expand Up @@ -417,7 +414,7 @@ export const Profile = () => {
}
user.setGameWaitingId(data.gameId);
inviteWaitingModalRef.current?.showModal();
},
}
);
}}
>
Expand Down

0 comments on commit 6d37c06

Please sign in to comment.