refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-11 16:28:02 +08:00
parent c7eae47fb2
commit 45a147ae67
18 changed files with 132 additions and 113 deletions
+6 -2
View File
@@ -48,7 +48,11 @@ const getFeedWithPagination = (config: Config): PageInfo => {
};
let curScrollPos = 0;
let oldScroll = 0;
export default function useMessageFeed({ context = "channel", id = null }) {
type Props = {
context?: "channel" | "user";
id: number;
};
export default function useMessageFeed({ context = "channel", id }: Props) {
const [loadMoreChannelMsgs] = useLazyGetHistoryMessagesQuery();
const [loadMoreDmMsgs] = useLazyGetDMHistoryMsg();
const listRef = useRef<number[]>([]);
@@ -83,7 +87,7 @@ export default function useMessageFeed({ context = "channel", id = null }) {
}
}, [items, context, id]);
useEffect(() => {
const serverMids = mids.filter((id) => {
const serverMids = mids.filter((id: number) => {
const ts = +new Date();
return Math.abs(ts - id) > 10 * 1000;
});