chore: remove unused console

This commit is contained in:
Tristan Yang
2022-08-31 22:13:35 +08:00
parent be7d547719
commit 65f8917657
31 changed files with 44 additions and 65 deletions
+2 -3
View File
@@ -7,7 +7,6 @@ import { useAppSelector } from "../../app/store";
interface Props {
children: ReactElement;
}
const GuestOnly: FC<Props> = ({ children }) => {
const { data: loginConfig, isLoading: fetchingConfig } = useGetLoginConfigQuery();
const { isLoading: initChecking } = useGetInitializedQuery();
@@ -19,14 +18,14 @@ const GuestOnly: FC<Props> = ({ children }) => {
if (!token) {
guestLogin();
}
}, [token, user]);
}, [token]);
// 已登录的非guest用户
if (token && user?.create_by !== "guest") {
return <Navigate to={`/`} replace />;
}
if (initChecking || guestSigning || fetchingConfig) return null;
// console.log("wtfff", token, user);
console.log("guest check", token, user, loginConfig?.guest, initialized);
// 检查有没有开启guest mode
if (!loginConfig?.guest) return <Navigate to={`/v/off`} replace />;
// 未初始化 则先走setup 流程
@@ -46,7 +46,7 @@ const MarkdownEditor: FC<Props> = ({
if (updateDraft) {
updateDraft(md);
}
console.log("mmmm", md);
// console.log("mmmm", md);
editorInstance.destroy();
}
};
@@ -47,7 +47,7 @@ const ForwardedMessage: FC<Props> = ({ context, to, from_uid, id }) => {
useEffect(() => {
if (messages) {
const forward_mids = messages.map(({ from_mid }) => from_mid) || [];
console.log("fff", messages);
// console.log("fff", messages);
setForwards(
<StyledForward data-forwarded-mids={forward_mids.join(",")}>
<h4 className="tip">
+1 -4
View File
@@ -86,11 +86,9 @@ const Plugins: FC<Props> = ({
useKey(
"Enter",
(evt) => {
// console.log("tttt", plateEditor);
if (!plateEditor) return;
// 是否在at操作
const mentionInputs = findMentionInput(plateEditor);
// console.log("tttt", mentionInputs, evt);
if (mentionInputs || evt.shiftKey || evt.ctrlKey || evt.altKey || evt.isComposing) {
return true;
}
@@ -142,7 +140,7 @@ const Plugins: FC<Props> = ({
const handleChange = useCallback(
async (val: any) => {
console.log("tmps changed", val);
// console.log("tmps changed", val);
const tmps = [];
const getMixedText = (children: any) => {
const mentions: any = [];
@@ -186,7 +184,6 @@ const Plugins: FC<Props> = ({
});
const msgs = arr.filter(({ content }) => !!content);
setMsgs(msgs);
// console.log("tmps", tmps, arr, msgs);
},
[msgs]
);
-1
View File
@@ -45,7 +45,6 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
const enableCall = type == "card" && canCall;
const canRemoveFromServer = type == "embed" && canRemove;
const hasMore = enableCall || email || canRemoveFromChannel || canRemoveFromServer;
console.log("ccc", canRemove, cid, uid);
return (
<StyledWrapper className={type}>
-2
View File
@@ -69,7 +69,6 @@ const Send: FC<IProps> = ({
// markdown insert emoji
markdownEditor.insertText(emoji);
} else {
console.log("emojii", emoji);
editor.insertText(emoji);
}
};
@@ -78,7 +77,6 @@ const Send: FC<IProps> = ({
if (msgs && msgs.length) {
// send text msgs
for await (const msg of msgs) {
console.log("send msg", msg);
const { type: content_type, content, properties = {} } = msg;
properties.local_id = properties.local_id ?? +new Date();
await sendMessage({
+1 -1
View File
@@ -61,7 +61,7 @@ export default function Server({ readonly = false }: Props) {
server: store.server
};
});
console.log("server info", server);
// console.log("server info", server);
const { name, description, logo } = server;
if (readonly)
return (
+8 -8
View File
@@ -29,14 +29,14 @@ const getFeedWithPagination = (config: Config): PageInfo => {
shadowMids.sort((a, b) => {
return Number(a) - Number(b);
});
console.log("message pagination", shadowMids);
// console.log("message pagination", shadowMids);
const pageCount = Math.ceil(shadowMids.length / pageSize);
const computedPageNumber = isLast ? pageCount : pageNumber;
const _start = -(pageCount - computedPageNumber + 1) * pageSize;
const _tmp = _start + pageSize;
const _end = _tmp == 0 ? undefined : _tmp;
const ids = shadowMids.slice(_start, _end);
console.log("start,end", _start, _end, ids);
// console.log("start,end", _start, _end, ids);
return {
isFirst: computedPageNumber == 1,
isLast: computedPageNumber == pageCount,
@@ -97,11 +97,11 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
mids: serverMids,
isLast: true
});
console.log("pull up 2", pageInfo);
// console.log("pull up 2", pageInfo);
pageRef.current = pageInfo;
listRef.current = pageInfo.ids;
setItems(listRef.current);
console.log("message pageInfo", serverMids, pageInfo);
// console.log("message pageInfo", serverMids, pageInfo);
} else {
// 追加
const [lastMid] = listRef.current.slice(-1);
@@ -109,7 +109,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
return Number(a) - Number(b);
});
const appends = sorteds.filter((s: number) => s > lastMid);
console.log("appends", appends, sorteds, lastMid, mids);
// console.log("appends", appends, sorteds, lastMid, mids);
if (appends.length) {
setAppends(appends);
const [newestMsgId] = appends.slice(-1);
@@ -119,7 +119,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
const msgFromSelf = loginUid == messageData[newestMsgId]?.from_uid;
const scrollDistance =
container.scrollHeight - (container.offsetHeight + container.scrollTop);
console.log("scrollDistance", msgFromSelf, scrollDistance);
// console.log("scrollDistance", msgFromSelf, scrollDistance);
if (msgFromSelf) {
container.scrollTop = container.scrollHeight;
} else if (scrollDistance <= 100) {
@@ -133,7 +133,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
}, [mids, messageData, loginUid]);
const pullUp = async () => {
const currPageInfo = pageRef.current;
console.log("pull up", currPageInfo);
// console.log("pull up", currPageInfo);
// 第一页
if (currPageInfo && currPageInfo.isFirst) {
const [firstMid] = currPageInfo.ids;
@@ -165,7 +165,7 @@ export default function useMessageFeed({ context = "channel", id }: Props) {
setTimeout(
() => {
setItems(listRef.current);
console.log("pull up", currPageInfo, listRef.current);
// console.log("pull up", currPageInfo, listRef.current);
setHasMore(pageInfo.pageNumber !== 1);
const container = containerRef.current;
if (container) {
+1 -1
View File
@@ -74,7 +74,7 @@ export default function usePreload() {
}, [rehydrated]);
const tokenAlmostExpire = dayjs().isAfter(new Date(expireTime - 20 * 1000));
const canStreaming = !!loginUid && rehydrated && !!token && !tokenAlmostExpire;
console.log("ttt", loginUid, rehydrated, token);
// console.log("ttt", loginUid, rehydrated, token);
useEffect(() => {
setStreamingReady(canStreaming);
+1 -1
View File
@@ -63,7 +63,7 @@ const handler = (data: ChatEvent, dispatch: AppDispatch, currState: CurrentState
// 如果是自己发的消息,就是已读
dispatch(addMessage({ mid, read, ...common }));
// 未推送完 or 不是自己发的消息
console.log("curr state", ready, loginUid, common.from_uid);
// console.log("curr state", ready, loginUid, common.from_uid);
// if (!ready || loginUid != common.from_uid) {
dispatch(
appendMessage({
+9 -6
View File
@@ -62,12 +62,15 @@ export default function useStreaming() {
initializing = true;
const params: {
"api-key": string;
after_mid: string;
after_mid?: string;
users_version?: string;
} = {
"api-key": token,
after_mid: `${afterMid}`
"api-key": token
};
// 如果afterMid是0,则不传该参数
if (afterMid !== 0) {
params.after_mid = `${afterMid}`;
}
// 如果usersVersion是0,则不传该参数
if (usersVersion !== 0) {
params.users_version = `${usersVersion}`;
@@ -320,9 +323,9 @@ export default function useStreaming() {
stopStreaming();
}
}
return () => {
stopStreaming();
};
// return () => {
// stopStreaming();
// };
}, [online, readyPullData]);
return {