瀏覽代碼

Finished bug 2024

bugfix/2024
Djordje Mitrovic 3 年之前
父節點
當前提交
3c19b99783
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13
    3
      src/components/DirectChat/MiniChatColumn/MiniChatColumn.js

+ 13
- 3
src/components/DirectChat/MiniChatColumn/MiniChatColumn.js 查看文件

@@ -1,4 +1,4 @@
import React, { useEffect, useMemo } from "react";
import React, { useEffect, useMemo, useState } from "react";
import PropTypes from "prop-types";
import {
ChatPagingText,
@@ -12,7 +12,7 @@ import {
selectLatestChats,
selectSelectedChat,
} from "../../../store/selectors/chatSelectors";
import { fetchChats } from "../../../store/actions/chat/chatActions";
import { fetchChats, setOneChat } from "../../../store/actions/chat/chatActions";
import MiniChatColumnHeader from "./MiniChatColumnHeader/MiniChatColumnHeaderTitle";
import { useLocation } from "react-router-dom";
import { selectOffer } from "../../../store/selectors/offersSelectors";
@@ -29,6 +29,7 @@ const MiniChatColumn = () => {
const offer = useSelector(selectOffer);
const location = useLocation();
const dispatch = useDispatch();
const [changedPage, setChangedPage] = useState(false);
const paging = usePaging();
const isLoadingMiniChat = useSelector(
selectIsLoadingByActionType(CHAT_SCOPE)
@@ -52,6 +53,12 @@ const MiniChatColumn = () => {
return {};
}, [offer, location.state]);

useEffect(() => {
if (changedPage && !isLoadingMiniChat) {
dispatch(setOneChat(chats[0]))
}
}, [changedPage, isLoadingMiniChat])

useEffect(() => {
dispatch(
fetchChats({
@@ -59,7 +66,10 @@ const MiniChatColumn = () => {
})
);
}, [paging.currentPage]);
const handleChangePage = (newPage) => paging.changePage(newPage);
const handleChangePage = (newPage) => {
setChangedPage(true);
paging.changePage(newPage);
};
return (
<>
{isLoadingMiniChat || isLoadingMiniChat === undefined ? (

Loading…
取消
儲存