Merge remote-tracking branch 'upstream/main' into refactor/typescript
# Conflicts: # src/common/component/ForwardModal/index.tsx # src/common/component/GoogleLoginButton.tsx # src/common/component/ManageMembers.tsx # src/routes/settingChannel/Overview.tsx # src/routes/settingChannel/index.tsx
This commit is contained in:
@@ -17,18 +17,17 @@ export default function useContactOperation({ uid, cid }: { uid: number; cid: nu
|
||||
const [removeInChannel, { isSuccess: removeSuccess }] = useRemoveMembersMutation();
|
||||
const navigateTo = useNavigate();
|
||||
const { copy } = useCopy();
|
||||
const { user, channel, loginUid, isAdmin } = useAppSelector((store) => {
|
||||
const { user, channel, loginUser, isAdmin } = useAppSelector((store) => {
|
||||
return {
|
||||
user: store.contacts.byId[uid],
|
||||
channel: store.channels.byId[cid],
|
||||
loginUid: store.authData.uid,
|
||||
isAdmin: store.contacts.byId[store.authData.uid]?.is_admin
|
||||
loginUser: store.authData.user
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setPassedUid(uid ?? loginUid);
|
||||
}, [uid, loginUid]);
|
||||
setPassedUid(uid ?? loginUser.uid);
|
||||
}, [uid, loginUser]);
|
||||
|
||||
useEffect(() => {
|
||||
if (removeSuccess || removeUserSuccess) {
|
||||
@@ -68,7 +67,7 @@ export default function useContactOperation({ uid, cid }: { uid: number; cid: nu
|
||||
toast.success("Cooming Soon...");
|
||||
hideAll();
|
||||
};
|
||||
|
||||
const loginUid = loginUser?.uid;
|
||||
const canRemoveFromChannel =
|
||||
cid && !channel?.is_public && (isAdmin || channel?.owner == loginUid);
|
||||
const canCall = agoraConfig.enabled && loginUid != uid;
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function useDeleteMessage() {
|
||||
const { loginUser, messageData } = useAppSelector((store) => {
|
||||
return {
|
||||
messageData: store.message,
|
||||
loginUser: store.contacts.byId[store.authData.uid]
|
||||
loginUser: store.authData.user
|
||||
};
|
||||
});
|
||||
const [
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useAppSelector } from "../../app/store";
|
||||
|
||||
export default function useLeaveChannel(cid: number) {
|
||||
const { channel, loginUid } = useAppSelector((store) => {
|
||||
return { channel: store.channels.byId[cid], loginUid: store.authData.uid };
|
||||
return { channel: store.channels.byId[cid], loginUid: store.authData.user?.uid };
|
||||
});
|
||||
const [update, { isLoading: transfering, isSuccess: transferSuccess }] =
|
||||
useUpdateChannelMutation();
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useLazyGetHistoryMessagesQuery } from "../../app/services/channel";
|
||||
import { useLazyGetHistoryMessagesQuery as useLazyGetDMHistoryMsg } from "../../app/services/contact";
|
||||
|
||||
const getFeedWithPagination = (config) => {
|
||||
import { useAppSelector } from "../../app/store";
|
||||
export interface PageInfo {
|
||||
isFirst: boolean;
|
||||
isLast: boolean;
|
||||
pageCount: number;
|
||||
pageSize: number;
|
||||
pageNumber: number;
|
||||
ids: number[];
|
||||
}
|
||||
interface Config extends Partial<PageInfo> {
|
||||
mids: number[];
|
||||
}
|
||||
const getFeedWithPagination = (config: Config): PageInfo => {
|
||||
const { pageNumber = 1, pageSize = 40, mids = [], isLast = false } = config || {};
|
||||
const shadowMids = mids.slice(0);
|
||||
|
||||
@@ -41,16 +51,16 @@ let oldScroll = 0;
|
||||
export default function useMessageFeed({ context = "channel", id = null }) {
|
||||
const [loadMoreChannelMsgs] = useLazyGetHistoryMessagesQuery();
|
||||
const [loadMoreDmMsgs] = useLazyGetDMHistoryMsg();
|
||||
const listRef = useRef([]);
|
||||
const pageRef = useRef(null);
|
||||
const containerRef = useRef(null);
|
||||
const listRef = useRef<number[]>([]);
|
||||
const pageRef = useRef<object | null>(null);
|
||||
const containerRef = useRef<HTMLElement | null>(null);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
const [appends, setAppends] = useState([]);
|
||||
const [items, setItems] = useState([]);
|
||||
const [items, setItems] = useState<number[]>([]);
|
||||
const loadMoreMsgsFromServer = context == "channel" ? loadMoreChannelMsgs : loadMoreDmMsgs;
|
||||
const { mids, messageData, loginUid } = useSelector((store) => {
|
||||
const { mids, messageData, loginUid } = useAppSelector((store) => {
|
||||
return {
|
||||
loginUid: store.authData.uid,
|
||||
loginUid: store.authData.user?.uid,
|
||||
mids:
|
||||
context == "channel" ? store.channelMessage[id] || [] : store.userMessage.byId[id] || [],
|
||||
messageData: store.message
|
||||
@@ -58,7 +68,7 @@ export default function useMessageFeed({ context = "channel", id = null }) {
|
||||
});
|
||||
useEffect(() => {
|
||||
listRef.current = [];
|
||||
pageRef.current = [];
|
||||
pageRef.current = null;
|
||||
setItems([]);
|
||||
setHasMore(true);
|
||||
setAppends([]);
|
||||
@@ -91,10 +101,10 @@ export default function useMessageFeed({ context = "channel", id = null }) {
|
||||
} else {
|
||||
// 追加
|
||||
const [lastMid] = listRef.current.slice(-1);
|
||||
const sorteds = mids.slice(0).sort((a, b) => {
|
||||
const sorteds = mids.slice(0).sort((a: number, b: number) => {
|
||||
return Number(a) - Number(b);
|
||||
});
|
||||
const appends = sorteds.filter((s) => s > lastMid);
|
||||
const appends = sorteds.filter((s: number) => s > lastMid);
|
||||
console.log("appends", appends, sorteds, lastMid, mids);
|
||||
if (appends.length) {
|
||||
setAppends(appends);
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function usePinMessage(cid: number) {
|
||||
const { channel, loginUser } = useAppSelector((store) => {
|
||||
return {
|
||||
channel: store.channels.byId[cid],
|
||||
loginUser: store.contacts.byId[store.authData.uid]
|
||||
loginUser: store.authData.user
|
||||
};
|
||||
});
|
||||
const [pin, { isError, isLoading, isSuccess }] = usePinMessageMutation();
|
||||
|
||||
Reference in New Issue
Block a user