1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-22 10:22:30 +01:00

channel mention click navigation

This commit is contained in:
Puyodead1 2023-11-30 15:06:51 -05:00
parent d98ce87c9e
commit e95cac3c12
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC

View File

@ -1,4 +1,5 @@
import React, { memo } from "react";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { useAppStore } from "../../stores/AppStore";
import Channel from "../../stores/objects/Channel";
@ -46,6 +47,12 @@ function UserMention({ id }: MentionProps) {
function ChannelMention({ id }: MentionProps) {
const app = useAppStore();
const [channel, setChannel] = React.useState<Channel | null>(null);
const navigate = useNavigate();
const click = () => {
if (!channel) return;
navigate(`/channels/${channel.guildId}/${channel.id}`);
};
React.useEffect(() => {
const channel = app.channels.get(id);
@ -60,7 +67,7 @@ function ChannelMention({ id }: MentionProps) {
);
return (
<Container>
<Container onClick={click}>
<span>#{channel.name}</span>
</Container>
);