Fix channel messages (#32)
This commit is contained in:
parent
aa034e963f
commit
0d6239aab8
|
@ -47,7 +47,7 @@ export function Channels({
|
||||||
isActive={channel.id === activeChannelId}
|
isActive={channel.id === activeChannelId}
|
||||||
isMuted={channel.isMuted || false}
|
isMuted={channel.isMuted || false}
|
||||||
notification={
|
notification={
|
||||||
notifications[channel.name] > 0
|
notifications[channel.name] > 0 && !channel.isMuted
|
||||||
? notifications[channel.name]
|
? notifications[channel.name]
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ export function ChatMessages({ messages, theme }: ChatMessagesProps) {
|
||||||
<MessagesWrapper ref={ref}>
|
<MessagesWrapper ref={ref}>
|
||||||
{messages.map((message, idx) => {
|
{messages.map((message, idx) => {
|
||||||
return (
|
return (
|
||||||
<MessageOuterWrapper key={idx}>
|
<MessageOuterWrapper key={message.date.getTime()}>
|
||||||
{(idx === 0 ||
|
{(idx === 0 ||
|
||||||
messages[idx - 1].date.getDay() !=
|
messages[idx - 1].date.getDay() !=
|
||||||
messages[idx].date.getDay()) && (
|
messages[idx].date.getDay()) && (
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { ChatMessage } from "../models/ChatMessage";
|
||||||
|
|
||||||
export function useMessenger(chatId: string, chatIdList: string[]) {
|
export function useMessenger(chatId: string, chatIdList: string[]) {
|
||||||
const [messenger, setMessenger] = useState<Messenger | undefined>(undefined);
|
const [messenger, setMessenger] = useState<Messenger | undefined>(undefined);
|
||||||
|
const [activeMessages, setActiveMessages] = useState<ChatMessage[]>([]);
|
||||||
const [messages, setMessages] = useState<{ [chatId: string]: ChatMessage[] }>(
|
const [messages, setMessages] = useState<{ [chatId: string]: ChatMessage[] }>(
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
@ -153,9 +154,13 @@ export function useMessenger(chatId: string, chatIdList: string[]) {
|
||||||
[chatId, messenger]
|
[chatId, messenger]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActiveMessages(messages?.[chatId] ?? []);
|
||||||
|
}, [messages, chatId]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
messenger,
|
messenger,
|
||||||
messages: messages?.[chatId] ?? [],
|
messages: activeMessages,
|
||||||
sendMessage,
|
sendMessage,
|
||||||
notifications,
|
notifications,
|
||||||
clearNotifications,
|
clearNotifications,
|
||||||
|
|
Loading…
Reference in New Issue