fix: temp session duplicate
This commit is contained in:
+1
-1
@@ -134,6 +134,6 @@
|
||||
"md5-file": "^5.0.0",
|
||||
"patch-package": "^6.4.7",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"prettier": "^2.6.2"
|
||||
"prettier": "^2.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import InviteModal from "../../../common/component/InviteModal";
|
||||
export default function SessionList({ tempSession = null }) {
|
||||
const [deleteId, setDeleteId] = useState(null);
|
||||
const [inviteChannelId, setInviteChannelId] = useState(null);
|
||||
const [sessions, setSessions] = useState(tempSession ? [tempSession] : []);
|
||||
const [sessions, setSessions] = useState([]);
|
||||
const { channelIDs, DMs, readChannels, readUsers, channelMessage, userMessage, loginUid } =
|
||||
useSelector((store) => {
|
||||
return {
|
||||
@@ -37,16 +37,20 @@ export default function SessionList({ tempSession = null }) {
|
||||
const mid = [...mids].pop();
|
||||
return { key: `user_${id}`, type: "user", id, mid };
|
||||
});
|
||||
|
||||
setSessions((prevs) => {
|
||||
return [
|
||||
...prevs,
|
||||
...[...cSessions, ...uSessions].sort((a, b) => {
|
||||
return b.mid - a.mid;
|
||||
})
|
||||
];
|
||||
const tmps = [...cSessions, ...uSessions].sort((a, b) => {
|
||||
return b.mid - a.mid;
|
||||
});
|
||||
}, [channelIDs, DMs, channelMessage, readChannels, readUsers, loginUid, userMessage]);
|
||||
setSessions(tempSession ? [tempSession, ...tmps] : tmps);
|
||||
}, [
|
||||
channelIDs,
|
||||
DMs,
|
||||
channelMessage,
|
||||
readChannels,
|
||||
readUsers,
|
||||
loginUid,
|
||||
userMessage,
|
||||
tempSession
|
||||
]);
|
||||
return (
|
||||
<>
|
||||
<Styled>
|
||||
|
||||
@@ -7457,10 +7457,10 @@ prettier-linter-helpers@^1.0.0:
|
||||
dependencies:
|
||||
fast-diff "^1.1.2"
|
||||
|
||||
prettier@^2.6.2:
|
||||
version "2.6.2"
|
||||
resolved "https://mirrors.tencent.com/npm/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
|
||||
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==
|
||||
prettier@^2.7.0:
|
||||
version "2.7.0"
|
||||
resolved "https://mirrors.cloud.tencent.com/npm/prettier/-/prettier-2.7.0.tgz#a4fdae07e5596c51c9857ea676cd41a0163879d6"
|
||||
integrity sha512-nwoX4GMFgxoPC6diHvSwmK/4yU8FFH3V8XWtLQrbj4IBsK2pkYhG4kf/ljF/haaZ/aii+wNJqISrCDPgxGWDVQ==
|
||||
|
||||
pretty-bytes@^5.3.0, pretty-bytes@^5.4.1:
|
||||
version "5.6.0"
|
||||
|
||||
Reference in New Issue
Block a user