From 0abf14918806ca27e8578beca9b22a084aac1987 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Sun, 29 Jan 2023 09:28:11 +0800 Subject: [PATCH] chore: updates --- package.json | 6 +-- src/routes/chat/DMList/index.tsx | 2 +- src/routes/chat/FavList.tsx | 2 +- src/routes/chat/GuestBlankPlaceholder.tsx | 34 +++------------- src/routes/chat/GuestSessionList/index.tsx | 2 +- src/routes/chat/SessionList/index.tsx | 4 +- src/routes/chat/index.tsx | 14 +++---- yarn.lock | 46 +++++++++++----------- 8 files changed, 43 insertions(+), 67 deletions(-) diff --git a/package.json b/package.json index 9daf83ca..c1980b39 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@metamask/onboarding": "^1.0.1", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", "@react-oauth/google": "^0.6.1", - "@reduxjs/toolkit": "^1.9.1", + "@reduxjs/toolkit": "^1.9.2", "@svgr/webpack": "^6.5.1", "@tippyjs/react": "^4.2.6", "@toast-ui/editor": "^3.2.1", @@ -30,7 +30,7 @@ "dotenv": "^16.0.3", "dotenv-expand": "^10.0.0", "emoji-mart": "5.5.2", - "eslint": "^8.32.0", + "eslint": "^8.33.0", "file-loader": "^6.2.0", "firebase": "^9.16.0", "fs-extra": "^11.1.0", @@ -57,7 +57,7 @@ "react-icons": "^4.7.1", "react-redux": "^8.0.5", "react-refresh": "0.14.0", - "react-router-dom": "^6.7.0", + "react-router-dom": "^6.8.0", "react-scripts": "^5.0.1", "react-syntax-highlighter": "^15.5.0", "react-textarea-autosize": "^8.4.0", diff --git a/src/routes/chat/DMList/index.tsx b/src/routes/chat/DMList/index.tsx index 132f8a3a..8691c568 100644 --- a/src/routes/chat/DMList/index.tsx +++ b/src/routes/chat/DMList/index.tsx @@ -28,7 +28,7 @@ const DMList: FC = ({ uids, setDropFiles }) => { if (mids.length == 0) { return { lastMid: null, unreads: 0, uid }; } - const lastMid = [...mids].pop(); + const lastMid = [...mids].sort().pop(); const readIndex = readUsers[uid]; const { unreads = 0 } = getUnreadCount({ mids, diff --git a/src/routes/chat/FavList.tsx b/src/routes/chat/FavList.tsx index 81cceeb4..b36c2a91 100644 --- a/src/routes/chat/FavList.tsx +++ b/src/routes/chat/FavList.tsx @@ -5,7 +5,7 @@ import IconSurprise from "../../assets/icons/emoji.surprise.svg"; import IconRemove from "../../assets/icons/close.svg"; import useFavMessage from "../../common/hook/useFavMessage"; import { useTranslation } from "react-i18next"; - +// 覆盖样式 const Styled = styled.div` .favorite { background: none; diff --git a/src/routes/chat/GuestBlankPlaceholder.tsx b/src/routes/chat/GuestBlankPlaceholder.tsx index c91ef95a..1040e16b 100644 --- a/src/routes/chat/GuestBlankPlaceholder.tsx +++ b/src/routes/chat/GuestBlankPlaceholder.tsx @@ -2,34 +2,10 @@ import { useTranslation } from "react-i18next"; import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; -import styled from "styled-components"; import { resetAuthData } from "../../app/slices/auth.data"; import { useAppSelector } from "../../app/store"; import Button from "../../common/component/styled/Button"; import useLogout from "../../common/hook/useLogout"; -const Styled = styled.div` - display: flex; - align-items: center; - flex-direction: column; - .title { - font-style: normal; - font-weight: 700; - font-size: 30px; - line-height: 38px; - color: #344054; - } - .details { - display: flex; - flex-direction: column; - .desc { - margin: 12px 0; - font-weight: 400; - font-size: 14px; - line-height: 20px; - color: #98a2b3; - } - } -`; // type Props = {}; const GuestBlankPlaceholder = () => { @@ -44,13 +20,13 @@ const GuestBlankPlaceholder = () => { navigateTo("/login"); }; return ( - -

{t("welcome", { name: serverName })}

-
- {t("guest_login_tip")} +
+

{t("welcome", { name: serverName })}

+
+ {t("guest_login_tip")}
- +
); }; diff --git a/src/routes/chat/GuestSessionList/index.tsx b/src/routes/chat/GuestSessionList/index.tsx index f2d6c481..c585d58f 100644 --- a/src/routes/chat/GuestSessionList/index.tsx +++ b/src/routes/chat/GuestSessionList/index.tsx @@ -29,7 +29,7 @@ const SessionList: FC = () => { if (!mids || mids.length == 0) { return { key: `channel_${id}`, unreads: 0, id, type: "channel" }; } - const mid = [...mids].pop(); + const mid = [...mids].sort().pop(); return { key: `channel_${id}`, id, mid, type: "channel" }; }); const tmps = [...(cSessions as ChatSession[])].sort((a, b) => { diff --git a/src/routes/chat/SessionList/index.tsx b/src/routes/chat/SessionList/index.tsx index e131a799..783b2ab8 100644 --- a/src/routes/chat/SessionList/index.tsx +++ b/src/routes/chat/SessionList/index.tsx @@ -38,7 +38,7 @@ const SessionList: FC = ({ tempSession }) => { if (!mids || mids.length == 0) { return { key: `channel_${id}`, unreads: 0, id, type: "channel" }; } - const mid = [...mids].pop(); + const mid = [...mids].sort().pop(); return { key: `channel_${id}`, id, mid, type: "channel" }; }); const uSessions = DMs.map((id) => { @@ -46,7 +46,7 @@ const SessionList: FC = ({ tempSession }) => { if (!mids || mids.length == 0) { return { key: `user_${id}`, unreads: 0, id, type: "user" }; } - const mid = [...mids].pop(); + const mid = [...mids].sort().pop(); return { key: `user_${id}`, type: "user", id, mid }; }); const tmps = [...(cSessions as ChatSession[]), ...(uSessions as ChatSession[])].sort((a, b) => { diff --git a/src/routes/chat/index.tsx b/src/routes/chat/index.tsx index 6e3851ff..ea1bbfa3 100644 --- a/src/routes/chat/index.tsx +++ b/src/routes/chat/index.tsx @@ -10,7 +10,7 @@ import ChannelModal from "../../common/component/ChannelModal"; import SessionList from "./SessionList"; import { useAppSelector } from "../../app/store"; import GuestBlankPlaceholder from "./GuestBlankPlaceholder"; -import GuestChannelChatInfo from "./GuestChannelChatInfo"; +import GuestChannelChat from "./GuestChannelChat"; import GuestSessionList from "./GuestSessionList"; function ChatPage() { const [channelModalVisible, setChannelModalVisible] = useState(false); @@ -32,11 +32,11 @@ function ChatPage() { sessionUids.findIndex((i) => i == user_id) > -1 ? undefined : { - key: `user_${user_id}`, - unreads: 0, - id: +user_id, - type: "user" as "user" | "channel" - }; + key: `user_${user_id}`, + unreads: 0, + id: +user_id, + type: "user" as "user" | "channel" + }; // console.log("temp uid", tmpUid); const placeholderVisible = channel_id == 0 && user_id == 0; return ( @@ -54,7 +54,7 @@ function ChatPage() { {placeholderVisible && (isGuest ? : )} {channel_id !== 0 && (isGuest ? ( - + ) : ( ))} diff --git a/yarn.lock b/yarn.lock index 3844e0cd..59eb2e64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2445,20 +2445,20 @@ resolved "https://mirrors.cloud.tencent.com/npm/@react-oauth%2fgoogle/-/google-0.6.1.tgz#2a4c0f2a2f55988e94e2b6efa4f82c8f3ae154f8" integrity sha512-Nq4OK/NTgnvl2dTgQW5H8O1bhLg4JRQhwkEzpfZNKA1ijByQk6X4XG1FGS49FIHjjKInb263Me/yVQ2F3LJeuw== -"@reduxjs/toolkit@^1.9.1": - version "1.9.1" - resolved "https://mirrors.cloud.tencent.com/npm/@reduxjs%2ftoolkit/-/toolkit-1.9.1.tgz#4c34dc4ddcec161535288c60da5c19c3ef15180e" - integrity sha512-HikrdY+IDgRfRYlCTGUQaiCxxDDgM1mQrRbZ6S1HFZX5ZYuJ4o8EstNmhTwHdPl2rTmLxzwSu0b3AyeyTlR+RA== +"@reduxjs/toolkit@^1.9.2": + version "1.9.2" + resolved "https://mirrors.cloud.tencent.com/npm/@reduxjs%2ftoolkit/-/toolkit-1.9.2.tgz#4cd153491118038e2eebcb63b2264e42a8a2d74c" + integrity sha512-5ZAZ7hwAKWSii5T6NTPmgIBUqyVdlDs+6JjThz6J6dmHLDm6zCzv2OjHIFAi3Vvs1qjmXU0bm6eBojukYXjVMQ== dependencies: immer "^9.0.16" redux "^4.2.0" redux-thunk "^2.4.2" reselect "^4.1.7" -"@remix-run/router@1.3.0": - version "1.3.0" - resolved "https://mirrors.cloud.tencent.com/npm/@remix-run%2frouter/-/router-1.3.0.tgz#b6ee542c7f087b73b3d8215b9bf799f648be71cb" - integrity sha512-nwQoYb3m4DDpHTeOwpJEuDt8lWVcujhYYSFGLluC+9es2PyLjm+jjq3IeRBQbwBtPLJE/lkuHuGHr8uQLgmJRA== +"@remix-run/router@1.3.1": + version "1.3.1" + resolved "https://mirrors.cloud.tencent.com/npm/@remix-run%2frouter/-/router-1.3.1.tgz#3bb0b6ddc0a276e8dc1138d08f63035e4e23e8bf" + integrity sha512-+eun1Wtf72RNRSqgU7qM2AMX/oHp+dnx7BHk1qhK5ZHzdHTUU4LA1mGG1vT+jMc8sbhG3orvsfOmryjzx2PzQw== "@rollup/plugin-babel@^5.2.0": version "5.3.1" @@ -6362,10 +6362,10 @@ eslint@^8.3.0: strip-json-comments "^3.1.0" text-table "^0.2.0" -eslint@^8.32.0: - version "8.32.0" - resolved "https://mirrors.cloud.tencent.com/npm/eslint/-/eslint-8.32.0.tgz#d9690056bb6f1a302bd991e7090f5b68fbaea861" - integrity sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ== +eslint@^8.33.0: + version "8.33.0" + resolved "https://mirrors.cloud.tencent.com/npm/eslint/-/eslint-8.33.0.tgz#02f110f32998cb598c6461f24f4d306e41ca33d7" + integrity sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA== dependencies: "@eslint/eslintrc" "^1.4.1" "@humanwhocodes/config-array" "^0.11.8" @@ -10638,20 +10638,20 @@ react-refresh@^0.11.0: resolved "https://mirrors.cloud.tencent.com/npm/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046" integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A== -react-router-dom@^6.7.0: - version "6.7.0" - resolved "https://mirrors.cloud.tencent.com/npm/react-router-dom/-/react-router-dom-6.7.0.tgz#0249f4ca4eb704562b8b0ff29caeb928c3a6ed38" - integrity sha512-jQtXUJyhso3kFw430+0SPCbmCmY1/kJv8iRffGHwHy3CkoomGxeYzMkmeSPYo6Egzh3FKJZRAL22yg5p2tXtfg== +react-router-dom@^6.8.0: + version "6.8.0" + resolved "https://mirrors.cloud.tencent.com/npm/react-router-dom/-/react-router-dom-6.8.0.tgz#5e5f4c4b15fdec3965d2ad9d7460d0c61971e744" + integrity sha512-hQouduSTywGJndE86CXJ2h7YEy4HYC6C/uh19etM+79FfQ6cFFFHnHyDlzO4Pq0eBUI96E4qVE5yUjA00yJZGQ== dependencies: - "@remix-run/router" "1.3.0" - react-router "6.7.0" + "@remix-run/router" "1.3.1" + react-router "6.8.0" -react-router@6.7.0: - version "6.7.0" - resolved "https://mirrors.cloud.tencent.com/npm/react-router/-/react-router-6.7.0.tgz#db262684c13b5c2970694084ae9e8531718a0681" - integrity sha512-KNWlG622ddq29MAM159uUsNMdbX8USruoKnwMMQcs/QWZgFUayICSn2oB7reHce1zPj6CG18kfkZIunSSRyGHg== +react-router@6.8.0: + version "6.8.0" + resolved "https://mirrors.cloud.tencent.com/npm/react-router/-/react-router-6.8.0.tgz#dd61fd1ec44daa2cceaef8e6baa00f99a01a650f" + integrity sha512-760bk7y3QwabduExtudhWbd88IBbuD1YfwzpuDUAlJUJ7laIIcqhMvdhSVh1Fur1PE8cGl84L0dxhR3/gvHF7A== dependencies: - "@remix-run/router" "1.3.0" + "@remix-run/router" "1.3.1" react-scripts@^5.0.1: version "5.0.1"