Fix: Prevent context menu on images in settings.

Revert mobile change.
Messages: Add channel id matching.
This commit is contained in:
Paul
2021-07-10 17:35:18 +01:00
parent cc112300de
commit 0afd123ef5
5 changed files with 41 additions and 33 deletions

View File

@@ -82,6 +82,9 @@ md.renderer.rules.emoji = function (token, idx) {
const RE_TWEMOJI = /:(\w+):/g;
// ! FIXME: Move to library
const RE_CHANNELS = /<#([A-z0-9]{26})>/g;
export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
const client = useContext(AppContext);
if (typeof content === "undefined") return null;
@@ -99,6 +102,18 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
return `[@${user.username}](/@${id})`;
}
return sub;
},
).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})`;
}
return sub;
},
);

View File

@@ -233,30 +233,21 @@ export function ServerListSidebar({ unreads, lastOpened }: Props) {
to={lastOpened.home ? `/channel/${lastOpened.home}` : "/"}>
<ServerEntry home active={homeActive}>
<Swoosh />
{isTouchscreenDevice ? (
<Icon size={42} unread={homeUnread}>
<img
style={{ width: 32, height: 32 }}
src={logoSVG}
/>
</Icon>
) : (
<div
onContextMenu={attachContextMenu("Status")}
onClick={() =>
homeActive && openContextMenu("Status")
}>
<UserHover user={self}>
<Icon size={42} unread={homeUnread}>
<UserIcon
target={self}
size={32}
status
/>
</Icon>
</UserHover>
</div>
)}
<div
onContextMenu={attachContextMenu("Status")}
onClick={() =>
homeActive && openContextMenu("Status")
}>
<UserHover user={self}>
<Icon size={42} unread={homeUnread}>
<UserIcon
target={self}
size={32}
status
/>
</Icon>
</UserHover>
</div>
</ServerEntry>
</ConditionalLink>
<LineDivider />