chore: updates
This commit is contained in:
@@ -109,7 +109,7 @@ const Input: FC<Props> = ({ type = "text", prefix = "", className, ...rest }) =>
|
|||||||
|
|
||||||
return type == "password" ? (
|
return type == "password" ? (
|
||||||
<StyledWrapper className={className}>
|
<StyledWrapper className={className}>
|
||||||
<StyledInput type={inputType} className={`inner ${className}`} {...rest} />
|
<StyledInput type={inputType} autoComplete={inputType == "password" ? "current-password" : "on"} className={`inner ${className}`} {...rest} />
|
||||||
<div className="view" onClick={togglePasswordVisible}>
|
<div className="view" onClick={togglePasswordVisible}>
|
||||||
{inputType == "password" ? <HiEyeOff color="#78787c" /> : <HiEye color="#78787c" />}
|
{inputType == "password" ? <HiEyeOff color="#78787c" /> : <HiEye color="#78787c" />}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
const pageRef = useRef<PageInfo | null>(null);
|
const pageRef = useRef<PageInfo | null>(null);
|
||||||
const containerRef = useRef<HTMLElement | null>(null);
|
const containerRef = useRef<HTMLElement | null>(null);
|
||||||
const [hasMore, setHasMore] = useState(true);
|
const [hasMore, setHasMore] = useState(true);
|
||||||
const [appends, setAppends] = useState([]);
|
const [appends, setAppends] = useState<number[]>([]);
|
||||||
const [items, setItems] = useState<number[]>([]);
|
const [items, setItems] = useState<number[]>([]);
|
||||||
const loadMoreMsgsFromServer = context == "channel" ? loadMoreChannelMsgs : loadMoreDmMsgs;
|
const loadMoreMsgsFromServer = context == "channel" ? loadMoreChannelMsgs : loadMoreDmMsgs;
|
||||||
const { mids, messageData, loginUid } = useAppSelector((store) => {
|
const { mids, messageData, loginUid } = useAppSelector((store) => {
|
||||||
@@ -71,6 +71,8 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// curScrollPos = 0;
|
||||||
|
// oldScroll = 0;
|
||||||
listRef.current = [];
|
listRef.current = [];
|
||||||
pageRef.current = null;
|
pageRef.current = null;
|
||||||
setItems([]);
|
setItems([]);
|
||||||
@@ -87,17 +89,18 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
}
|
}
|
||||||
}, [items, context, id]);
|
}, [items, context, id]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
//过滤掉本地消息
|
||||||
const serverMids = mids.filter((id: number) => {
|
const serverMids = mids.filter((id: number) => {
|
||||||
const ts = +new Date();
|
const ts = +new Date();
|
||||||
return Math.abs(ts - id) > 10 * 1000;
|
return Math.abs(ts - id) > 10 * 1000;
|
||||||
});
|
});
|
||||||
if (listRef.current.length == 0 && serverMids.length) {
|
if (listRef.current.length == 0 && serverMids.length > 0) {
|
||||||
// 初次
|
// 初次
|
||||||
const pageInfo = getFeedWithPagination({
|
const pageInfo = getFeedWithPagination({
|
||||||
mids: serverMids,
|
mids: serverMids,
|
||||||
isLast: true
|
isLast: true
|
||||||
});
|
});
|
||||||
// console.log("pull up 2", pageInfo);
|
console.log("pull up first", pageInfo, serverMids);
|
||||||
pageRef.current = pageInfo;
|
pageRef.current = pageInfo;
|
||||||
listRef.current = pageInfo.ids;
|
listRef.current = pageInfo.ids;
|
||||||
setItems(listRef.current);
|
setItems(listRef.current);
|
||||||
@@ -109,7 +112,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
return Number(a) - Number(b);
|
return Number(a) - Number(b);
|
||||||
});
|
});
|
||||||
const appends = sorteds.filter((s: number) => s > lastMid);
|
const appends = sorteds.filter((s: number) => s > lastMid);
|
||||||
// console.log("appends", appends, sorteds, lastMid, mids);
|
console.log("pull up appends", appends, sorteds, lastMid, mids);
|
||||||
if (appends.length) {
|
if (appends.length) {
|
||||||
setAppends(appends);
|
setAppends(appends);
|
||||||
const [newestMsgId] = appends.slice(-1);
|
const [newestMsgId] = appends.slice(-1);
|
||||||
@@ -133,7 +136,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
}, [mids, messageData, loginUid]);
|
}, [mids, messageData, loginUid]);
|
||||||
const pullUp = async () => {
|
const pullUp = async () => {
|
||||||
const currPageInfo = pageRef.current;
|
const currPageInfo = pageRef.current;
|
||||||
// console.log("pull up", currPageInfo);
|
console.log("pull up", currPageInfo);
|
||||||
// 第一页
|
// 第一页
|
||||||
if (currPageInfo && currPageInfo.isFirst) {
|
if (currPageInfo && currPageInfo.isFirst) {
|
||||||
const [firstMid] = currPageInfo.ids;
|
const [firstMid] = currPageInfo.ids;
|
||||||
@@ -165,7 +168,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
setItems(listRef.current);
|
setItems(listRef.current);
|
||||||
// console.log("pull up", currPageInfo, listRef.current);
|
console.log("pull up timeout", currPageInfo, listRef.current);
|
||||||
setHasMore(pageInfo.pageNumber !== 1);
|
setHasMore(pageInfo.pageNumber !== 1);
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
if (container) {
|
if (container) {
|
||||||
@@ -173,7 +176,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
|
|||||||
oldScroll = container.scrollHeight - container.clientHeight;
|
oldScroll = container.scrollHeight - container.clientHeight;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currPageInfo?.isLast ? 10 : 800
|
currPageInfo?.isLast ? 10 : 500
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const pullDown = () => {
|
const pullDown = () => {
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ import { useTranslation } from "react-i18next";
|
|||||||
let from: string = "";
|
let from: string = "";
|
||||||
|
|
||||||
export default function DMSetting() {
|
export default function DMSetting() {
|
||||||
const { t } = useTranslation("setting");
|
// const { t } = useTranslation("setting");
|
||||||
|
const { t: ct } = useTranslation();
|
||||||
const { uid = 0 } = useParams();
|
const { uid = 0 } = useParams();
|
||||||
const { loginUser, user } = useAppSelector((store) => {
|
const { loginUser } = useAppSelector((store) => {
|
||||||
return {
|
return {
|
||||||
loginUser: store.authData.user,
|
loginUser: store.authData.user,
|
||||||
user: uid ? store.users.byId[+uid] : undefined
|
user: uid ? store.users.byId[+uid] : undefined
|
||||||
@@ -48,7 +49,7 @@ export default function DMSetting() {
|
|||||||
navs={navs}
|
navs={navs}
|
||||||
dangers={[
|
dangers={[
|
||||||
canDelete && {
|
canDelete && {
|
||||||
title: t("action.remove"),
|
title: ct("action.remove_user"),
|
||||||
handler: toggleDeleteConfirm
|
handler: toggleDeleteConfirm
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
|
|||||||
Reference in New Issue
Block a user