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
+3 -3
View File
@@ -39,7 +39,7 @@ const useRehydrate = () => {
server: {}
};
const tables = Object.keys(window.CACHE);
const results = await Promise.all(
await Promise.all(
tables.map((_key) => {
return window.CACHE[_key]?.iterate((data: any, key) => {
// console.log("iterated", key);
@@ -87,7 +87,7 @@ const useRehydrate = () => {
);
dispatch(fillUsers(rehydrateData.users));
dispatch(fillServer(rehydrateData.server));
console.log("fill channels from indexedDB");
// console.log("fill channels from indexedDB");
dispatch(fillChannels(rehydrateData.channels));
// file message
dispatch(fillFileMessage(rehydrateData.fileMessage.list));
@@ -99,7 +99,7 @@ const useRehydrate = () => {
dispatch(fillReactionMessage(rehydrateData.reactionMessage));
setIterated(true);
console.log("iterate results", rehydrateData, results);
// console.log("iterate results", rehydrateData, results);
};
return { rehydrate, rehydrated: iterated };
};
@@ -13,7 +13,7 @@ export default async function handler({ operation, data = {} }: Params) {
case "addFileMessage":
case "removeFileMessage":
{
console.log("file message opt", data, operation);
// console.log("file message opt", data, operation);
await table?.setItem("list", data);
}
break;
+1 -1
View File
@@ -13,7 +13,7 @@ export default async function handler({ operation, data = {} }: Params) {
switch (operation) {
case "toggleMenuExpand":
{
console.log("cache the toggleMenuExpand");
// console.log("cache the toggleMenuExpand");
await table?.setItem("menuExpand", data.menuExpand);
}
break;
+1 -1
View File
@@ -46,7 +46,7 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
// 先检查token是否过期,过期则renew
const { token, refreshToken, expireTime = +new Date() } = api.getState().authData;
let result = null;
console.log("base check", whiteList.includes(api.endpoint), api.endpoint);
// console.log("base check", whiteList.includes(api.endpoint), api.endpoint);
if (!whiteList.includes(api.endpoint) && dayjs().isAfter(new Date(expireTime - 20 * 1000))) {
// 快过期了,renew
waitingForRenew = baseQuery(
+2 -2
View File
@@ -22,7 +22,7 @@ export const onMessageSendStarted = async (
// 忽略archive类型的消息
if (type == "archive") return;
// id: who send to ,from_uid: who sent
console.log("handlers data", content, type, properties, ignoreLocal, id);
// console.log("handlers data", content, type, properties, ignoreLocal, id);
const isImage = properties.content_type?.startsWith("image");
const ts = properties.local_id || +new Date();
const tmpMsg = {
@@ -45,7 +45,7 @@ export const onMessageSendStarted = async (
try {
const { data: server_mid } = await queryFulfilled;
console.log("message server mid", server_mid);
// console.log("message server mid", server_mid);
batch(() => {
dispatch(removeContextMessage({ id, mid: ts }));
dispatch(addMessage({ mid: server_mid, ...tmpMsg }));
+2 -2
View File
@@ -34,10 +34,10 @@ export const userApi = createApi({
try {
const { data: users } = await queryFulfilled;
const matchedUser = users.find((c) => c.uid == local_uid);
console.log("wtf", users, matchedUser);
// console.log("wtf", users, matchedUser);
if (!matchedUser) {
// 用户已注销或被禁用
console.log("no matched user, redirect to login");
// console.log("no matched user, redirect to login");
dispatch(resetAuthData());
} else {
const markedUsers = users.map((u) => {
+1 -1
View File
@@ -83,7 +83,7 @@ const messageSlice = createSlice({
},
addReplyingMessage(state, action: PayloadAction<{ key: string | number; mid: number }>) {
const { key, mid } = action.payload;
console.log("to ", key, mid);
// console.log("to ", key, mid);
state.replying[key] = mid;
},
removeReplyingMessage(state, action: PayloadAction<string | number>) {
-7
View File
@@ -39,13 +39,6 @@ const serverSlice = createSlice({
},
updateInfo(state, action: PayloadAction<Partial<StoredServer>>) {
const values = action.payload || {};
const tmp = { ...state, ...values };
console.log("ssss", tmp);
// todo: check and remove old logic
// Object.keys(values).forEach((_key) => {
// state[_key] = values[_key];
// });
return { ...state, ...values };
}
}
+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 {
+1 -1
View File
@@ -87,7 +87,7 @@ const FavList: FC<Props> = ({ cid = null, uid = null }) => {
const { favorites, removeFavorite } = useFavMessage({ cid, uid });
const handleRemove = (evt: MouseEvent<HTMLButtonElement>) => {
const { id = "" } = evt.currentTarget.dataset;
console.log("remove fav", id);
// console.log("remove fav", id);
removeFavorite(id);
};
const noFavs = favorites.length == 0;
-1
View File
@@ -29,7 +29,6 @@ export default function GuestChannelChat({ cid = 0 }: Props) {
});
if (!data) return null;
const { name, description, is_public } = data;
console.log("channel message list", msgIds);
const feeds = [...msgIds, ...appends];
return (
<>
-1
View File
@@ -61,7 +61,6 @@ export default function MetamaskLoginButton({
}
}, [accounts]);
const getSignature = async (address: string, nonce: string) => {
console.log("get sn");
const signature = await window.ethereum.request({
method: "personal_sign",
params: [nonce, address, "hello from "]
-1
View File
@@ -91,7 +91,6 @@ export default function LoginPage() {
const handleLogin = (evt: FormEvent<HTMLFormElement>) => {
evt.preventDefault();
console.log("wtf", input);
login({
...input,
type: "password"
-1
View File
@@ -36,7 +36,6 @@ export default function OAuthPage() {
if (isSuccess && data) {
setLoading(false);
// 更新本地认证信息
console.log("login data", data);
toast.success("Login Successfully");
dispatch(setAuthData(data));
navigateTo("/");
+1 -1
View File
@@ -67,7 +67,7 @@ function ResourceManagement({ fileMessages }) {
const count = Math.floor(cWidth / 368);
const leftWidth = cWidth % 368;
const gutter = Math.max(Math.floor(leftWidth / (count - 1)), 8);
console.log("gutter", gutter, cWidth, count, leftWidth);
// console.log("gutter", gutter, cWidth, count, leftWidth);
msnry = new Masonry(container, {
// options
fitWidth: true,
+6 -6
View File
@@ -100,8 +100,6 @@ export default function License() {
}, [licenseInfo]);
const disableBtn = checking || upserting || !license || license === licenseInfo?.base58;
console.log("ddd", licenseInfo);
return (
<Styled>
<div className="input">
@@ -116,10 +114,12 @@ export default function License() {
</div>
<div className="item">
<span className="label">Domains</span>
<ul className="info"> {licenseInfo?.domains.map(d => {
return <li key={d}>{d}</li>;
})}</ul>
<ul className="info">
{" "}
{licenseInfo?.domains.map((d) => {
return <li key={d}>{d}</li>;
})}
</ul>
</div>
<div className="item">
<span className="label">User Limit</span>
-1
View File
@@ -117,7 +117,6 @@ export default function Overview() {
});
};
const handleReset = () => {
console.log("reset", server, loginConfig);
setServerValues(server);
setLoginConfigValues(loginConfig);
};
@@ -49,7 +49,6 @@ const ProfileBasicEditModal: FC<Props> = ({ closeModal }) => {
});
};
const handleUpdate = () => {
console.log("pwd", input);
const { current, newPassword } = input;
updatePassword({ old_password: current, new_password: newPassword });
};
-2
View File
@@ -40,7 +40,6 @@ export default function ConfigSMTP() {
setTestEmail(newValue);
};
const handleTestClick = () => {
console.log("test");
sendTestEmail({
to: testEmail,
subject: "test title",
@@ -58,7 +57,6 @@ export default function ConfigSMTP() {
if (!values) return null;
const { host, port, from, username, password, enabled = false } = values as SMTPConfig;
console.log("values", values);
return (
<StyledContainer>
<div className="inputs">
-1
View File
@@ -76,7 +76,6 @@ export default function Overview({ id = 0 }) {
};
const handleReset = () => {
console.log("reset", data);
setValues(data);
};
-1
View File
@@ -23,7 +23,6 @@ export default function UsersPage() {
};
}, [pathname]);
console.log({ userIds, user_id });
if (!userIds) return null;
return (
<StyledWrapper>