From 4abf98adcb102d67e0a0d774b5dde64d12c88837 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 15 Aug 2021 09:58:22 +0100 Subject: [PATCH] Bump revolt.js to fix objects not being properly updated. Also don't re-fetch members on each message. Add cursor: pointer to attachment images upon request. Use client message cache for replies. --- package.json | 2 +- .../common/messaging/attachments/Attachment.module.scss | 4 ++++ .../common/messaging/attachments/MessageReply.tsx | 8 +++----- src/components/navigation/right/MemberSidebar.tsx | 3 ++- yarn.lock | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 27dc0a6b..864e460f 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "react-virtuoso": "^1.10.4", "redux": "^4.1.0", "revolt-api": "0.5.2-alpha.1", - "revolt.js": "5.0.1-alpha.3", + "revolt.js": "5.0.1-alpha.5", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/components/common/messaging/attachments/Attachment.module.scss b/src/components/common/messaging/attachments/Attachment.module.scss index ce818ee1..929a2c41 100644 --- a/src/components/common/messaging/attachments/Attachment.module.scss +++ b/src/components/common/messaging/attachments/Attachment.module.scss @@ -89,3 +89,7 @@ .image { border-radius: var(--border-radius); } + +.image { + cursor: pointer; +} diff --git a/src/components/common/messaging/attachments/MessageReply.tsx b/src/components/common/messaging/attachments/MessageReply.tsx index 9512d828..bf9aee33 100644 --- a/src/components/common/messaging/attachments/MessageReply.tsx +++ b/src/components/common/messaging/attachments/MessageReply.tsx @@ -144,11 +144,9 @@ export const MessageReply = observer(({ index, channel, id }: Props) => { const [message, setMessage] = useState(undefined); useLayoutEffect(() => { - // ! FIXME: We should do this through the message renderer, so it can fetch it from cache if applicable. - const m = view.messages.find((x) => x._id === id); - - if (m) { - setMessage(m); + const message = channel.client.messages.get(id); + if (message) { + setMessage(message); } else { channel.fetchMessage(id).then(setMessage); } diff --git a/src/components/navigation/right/MemberSidebar.tsx b/src/components/navigation/right/MemberSidebar.tsx index 4e8bb83e..635efba4 100644 --- a/src/components/navigation/right/MemberSidebar.tsx +++ b/src/components/navigation/right/MemberSidebar.tsx @@ -150,7 +150,8 @@ export const ServerMemberSidebar = observer( if (status === ClientStatus.ONLINE) { channel.server!.fetchMembers(); } - }, [status, channel.server]); + // eslint-disable-next-line + }, [status, channel.server_id]); const keys = [...client.members.keys()]; const entries = useEntries(channel, keys, true); diff --git a/yarn.lock b/yarn.lock index 53ec96e9..4f307aeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3605,10 +3605,10 @@ revolt-api@0.5.2-alpha.1: resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.2-alpha.1.tgz#2164d04cd5581267ce59142557666bd386bc85c4" integrity sha512-3OrjYCDNPkJ+yO9d87NJvuUDAbungEbUfrfHlvFwV8hJze/RMkuYUTFWe1HyBMwBC7F/yWQK+2V7IoifC5STmw== -revolt.js@5.0.1-alpha.3: - version "5.0.1-alpha.3" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.3.tgz#986d2ec21d751067d95c4f444f81b922df566cde" - integrity sha512-h1xlaBvKyTS+wF9Oe4rtjuTe5plrOpYMp9qskqxMeNIoVu9VuJjHU+n9YUWANbgn7Ji9sxPHZrco5+0+bLOCcg== +revolt.js@5.0.1-alpha.5: + version "5.0.1-alpha.5" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.5.tgz#531f456cd80ca786868081825507b868e9eb8e27" + integrity sha512-D17O+MuCSL8KPehu2BoVb17/XgbtwGILMJPvBXyGUvbBuhOzieDAN2gzDCRNP17JvWR9kLkVOzXxWhCaBO36Vw== dependencies: axios "^0.19.2" eventemitter3 "^4.0.7"