chore: updates

This commit is contained in:
Tristan Yang
2023-01-29 09:28:11 +08:00
parent 46113159d2
commit 0abf149188
8 changed files with 43 additions and 67 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ const DMList: FC<Props> = ({ 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,
+1 -1
View File
@@ -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;
+5 -29
View File
@@ -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 (
<Styled>
<h2 className="title">{t("welcome", { name: serverName })}</h2>
<div className="details">
<span className="desc">{t("guest_login_tip")}</span>
<section className="flex flex-col items-center">
<h2 className="text-3xl text-gray-600 font-bold ">{t("welcome", { name: serverName })}</h2>
<div className="flex flex-col">
<span className="text-gray-400 my-3 text-sm">{t("guest_login_tip")}</span>
<Button onClick={handleSignIn} className="small">{t("sign_in")}</Button>
</div>
</Styled>
</section>
);
};
+1 -1
View File
@@ -29,7 +29,7 @@ const SessionList: FC<Props> = () => {
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) => {
+2 -2
View File
@@ -38,7 +38,7 @@ const SessionList: FC<Props> = ({ 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<Props> = ({ 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) => {
+7 -7
View File
@@ -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 ? <GuestBlankPlaceholder /> : <BlankPlaceholder />)}
{channel_id !== 0 &&
(isGuest ? (
<GuestChannelChatInfo cid={+channel_id} />
<GuestChannelChat cid={+channel_id} />
) : (
<ChannelChat cid={+channel_id} />
))}