瀏覽代碼

Merge branch 'bugfix/2024' of http://git.dilig.net/selenaaasi/trampa-frontend

bugfix/2025
Djordje Mitrovic 3 年之前
父節點
當前提交
0b7bee7998
共有 1 個檔案被更改,包括 13 行新增3 行删除
  1. 13
    3
      src/components/DirectChat/MiniChatColumn/MiniChatColumn.js

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

import React, { useEffect, useMemo } from "react";
import React, { useEffect, useMemo, useState } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import {
ChatPagingText, ChatPagingText,
selectLatestChats, selectLatestChats,
selectSelectedChat, selectSelectedChat,
} from "../../../store/selectors/chatSelectors"; } 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 MiniChatColumnHeader from "./MiniChatColumnHeader/MiniChatColumnHeaderTitle";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { selectOffer } from "../../../store/selectors/offersSelectors"; import { selectOffer } from "../../../store/selectors/offersSelectors";
const offer = useSelector(selectOffer); const offer = useSelector(selectOffer);
const location = useLocation(); const location = useLocation();
const dispatch = useDispatch(); const dispatch = useDispatch();
const [changedPage, setChangedPage] = useState(false);
const paging = usePaging(); const paging = usePaging();
const isLoadingMiniChat = useSelector( const isLoadingMiniChat = useSelector(
selectIsLoadingByActionType(CHAT_SCOPE) selectIsLoadingByActionType(CHAT_SCOPE)
return {}; return {};
}, [offer, location.state]); }, [offer, location.state]);


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

useEffect(() => { useEffect(() => {
dispatch( dispatch(
fetchChats({ fetchChats({
}) })
); );
}, [paging.currentPage]); }, [paging.currentPage]);
const handleChangePage = (newPage) => paging.changePage(newPage);
const handleChangePage = (newPage) => {
setChangedPage(true);
paging.changePage(newPage);
};
return ( return (
<> <>
{isLoadingMiniChat || isLoadingMiniChat === undefined ? ( {isLoadingMiniChat || isLoadingMiniChat === undefined ? (

Loading…
取消
儲存