Fix server id not being replaced properly.

Fix links in spoilers opening when revealing.
Fix unread icon appearing for home.
Fix unreads not being acknowledged.
This commit is contained in:
Paul 2021-07-31 10:05:59 +01:00
parent 58d9744fad
commit 305243ab43
7 changed files with 23 additions and 24 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit f3c991242044c0125111e533a94350633a681d62
Subproject commit eb880a90254df406b25caf6b969ed3aee3142f6c

View file

@ -97,7 +97,7 @@
"react-router-dom": "^5.2.0",
"react-scroll": "^1.8.2",
"redux": "^4.1.0",
"revolt.js": "5.0.0-alpha.10",
"revolt.js": "5.0.0-alpha.11",
"rimraf": "^3.0.2",
"sass": "^1.35.1",
"shade-blend-color": "^1.0.0",

View file

@ -118,6 +118,7 @@
> * {
opacity: 0;
pointer-events: none;
}
&:global(.shown) {
@ -128,6 +129,7 @@
> * {
opacity: 1;
pointer-events: unset;
}
}
}

View file

@ -92,9 +92,8 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
// We replace the message with the mention at the time of render.
// We don't care if the mention changes.
const newContent = content.replace(
RE_MENTIONS,
(sub: string, ...args: any[]) => {
const newContent = content
.replace(RE_MENTIONS, (sub: string, ...args: any[]) => {
const id = args[0],
user = client.users.get(id);
@ -103,20 +102,17 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
}
return sub;
},
).replace(
RE_CHANNELS,
(sub: string, ...args: any[]) => {
})
.replace(RE_CHANNELS, (sub: string, ...args: any[]) => {
const id = args[0],
channel = client.channels.get(id);
if (channel?.channel_type === 'TextChannel') {
return `[#${channel.name}](/server/${channel.server}/channel/${id})`;
if (channel?.channel_type === "TextChannel") {
return `[#${channel.name}](/server/${channel.server_id}/channel/${id})`;
}
return sub;
},
);
});
const useLargeEmojis = disallowBigEmoji
? false

View file

@ -218,7 +218,7 @@ export const ServerListSidebar = observer(({ unreads, lastOpened }: Props) => {
if (
(x.channel?.channel_type === "DirectMessage"
? x.channel?.active
: true) &&
: x.channel?.channel_type === "Group") &&
x.unread
) {
homeUnread = "unread";

View file

@ -1,4 +1,4 @@
import { autorun } from "mobx";
import { autorun, isObservableProp, reaction } from "mobx";
import { Channel } from "revolt.js/dist/maps/Channels";
import { useLayoutEffect } from "preact/hooks";
@ -17,10 +17,7 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
const client = useClient();
useLayoutEffect(() => {
function checkUnread(
target: Channel,
last_message: Channel["last_message"],
) {
function checkUnread(target: Channel) {
if (!target) return;
if (target._id !== channel._id) return;
if (
@ -50,7 +47,11 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
}
}
return autorun(() => checkUnread(channel!, channel!.last_message));
checkUnread(channel);
return reaction(
() => channel.last_message,
() => checkUnread(channel),
);
}, [channel, unreads]);
}

View file

@ -3570,10 +3570,10 @@ revolt-api@0.5.1-alpha.10-patch.0:
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.1-alpha.10-patch.0.tgz#97d31bec7dfa4573567097443acb059c4feaac20"
integrity sha512-UyM890HkGlYNQOxpHuEpUsJHLt8Ujnjg9/zPEDGpbvS4iy0jmHX23Hh8tOCfb/ewxbNrtT3G1HpSWKOneW/vYg==
revolt.js@5.0.0-alpha.10:
version "5.0.0-alpha.10"
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.10.tgz#3fa1a8944a338134da09626278ee47b91f20ce2a"
integrity sha512-b5nCQDtLUei4mfXhZNkIfQiyG8WDHBnpOVRaRaJz2ZjcQtdBjxIPXxOWkBYL7N/dBJ7sn5xgLMqra9UzkwkewA==
revolt.js@5.0.0-alpha.11:
version "5.0.0-alpha.11"
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.11.tgz#af131150ce37a39b979501c730ec2bee5a4e38a1"
integrity sha512-aOD8IV2DM9Ebq15FVQ2GJDGBaICppk+jP06dW0KlrDeVoE3Hra5CRLHSIRtp2mJN/vh1cH+9eA78jssAlAgwAw==
dependencies:
axios "^0.19.2"
eventemitter3 "^4.0.7"