diff --git a/packages/react-chat/src/components/Channels/Channels.tsx b/packages/react-chat/src/components/Channels/Channels.tsx
index 3b4f6c1..fc08ca3 100644
--- a/packages/react-chat/src/components/Channels/Channels.tsx
+++ b/packages/react-chat/src/components/Channels/Channels.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from "react";
+import React from "react";
import styled from "styled-components";
import { ChatState, useChatState } from "../../contexts/chatStateProvider";
@@ -45,43 +45,36 @@ function GenerateChannels({ type, onCommunityClick }: GenerateChannelsProps) {
);
}
-export function Channels({ onCommunityClick }: ChannelsProps) {
- const { clearNotifications, clearMentions, notifications, activeChannel } =
- useMessengerContext();
- useEffect(() => {
- if (activeChannel) {
- if (notifications[activeChannel.id] > 0) {
- clearNotifications(activeChannel.id);
- clearMentions(activeChannel.id);
- }
- }
- }, [notifications, activeChannel]);
- const setChatState = useChatState()[1];
- const identity = useIdentity();
+type ChatsListProps = {
+ onCommunityClick?: () => void;
+};
+function ChatsSideBar({ onCommunityClick }: ChatsListProps) {
+ const setChatState = useChatState()[1];
+ return (
+ <>
+
+ Chat
+ setChatState(ChatState.ChatCreation)}>
+
+
+
+
+
+
+
+ >
+ );
+}
+
+export function Channels({ onCommunityClick }: ChannelsProps) {
+ const identity = useIdentity();
return (
{identity ? (
- <>
-
- Chat
- setChatState(ChatState.ChatCreation)}>
-
-
-
-
-
-
-
- >
+
) : (
)}
diff --git a/packages/react-chat/src/components/Channels/EmptyChannel.tsx b/packages/react-chat/src/components/Channels/EmptyChannel.tsx
index f4bbac4..a33d5f2 100644
--- a/packages/react-chat/src/components/Channels/EmptyChannel.tsx
+++ b/packages/react-chat/src/components/Channels/EmptyChannel.tsx
@@ -9,11 +9,11 @@ import { textMediumStyles } from "../Text";
import { ChannelInfo, ChannelLogo, ChannelName } from "./Channel";
-type EmptyChannelProps = {
+type ChannelBeggingTextProps = {
channel: ChannelData;
};
-export function EmptyChannel({ channel }: EmptyChannelProps) {
+function ChannelBeggingText({ channel }: ChannelBeggingTextProps) {
const identity = useIdentity();
const { contacts } = useMessengerContext();
const members = useMemo(() => {
@@ -25,23 +25,18 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
}
return [];
}, [channel, contacts]);
- return (
-
-
-
- {" "}
- {!channel.icon && channel.name.slice(0, 1).toUpperCase()}
-
-
-
- {channel.type === "dm" ? (
+ switch (channel.type) {
+ case "dm":
+ return (
Any messages you send here are encrypted and can only be read by you
and
{channel.name.slice(0, 10)}.
- ) : channel.type === "group" ? (
+ );
+ case "group":
+ return (
{identity && {utils.bufToHex(identity.publicKey)}}{" "}
created a group with{" "}
@@ -52,11 +47,32 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
))}
- ) : (
+ );
+ case "channel":
+ return (
Welcome to the beginning of the #{channel.name} channel!
- )}
+ );
+ }
+ return null;
+}
+
+type EmptyChannelProps = {
+ channel: ChannelData;
+};
+
+export function EmptyChannel({ channel }: EmptyChannelProps) {
+ return (
+
+
+
+ {" "}
+ {!channel.icon && channel.name.slice(0, 1).toUpperCase()}
+
+
+
+
);
}
diff --git a/packages/react-chat/src/hooks/messenger/useMessenger.ts b/packages/react-chat/src/hooks/messenger/useMessenger.ts
index d17ffd6..b980082 100644
--- a/packages/react-chat/src/hooks/messenger/useMessenger.ts
+++ b/packages/react-chat/src/hooks/messenger/useMessenger.ts
@@ -228,6 +228,15 @@ export function useMessenger(
[messenger, groupChat, activeChannel]
);
+ useEffect(() => {
+ if (activeChannel) {
+ if (notifications[activeChannel.id] > 0) {
+ clearNotifications(activeChannel.id);
+ clearMentions(activeChannel.id);
+ }
+ }
+ }, [notifications, activeChannel]);
+
return {
messenger,
messages,