fix(notifications): sync mute state in chat store immediately
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
@@ -34,6 +34,7 @@ interface Props {
|
||||
export function ChatInfoPanel({ chatId, open, onClose }: Props) {
|
||||
const me = useAuthStore((s) => s.me);
|
||||
const loadChats = useChatStore((s) => s.loadChats);
|
||||
const updateChatMuted = useChatStore((s) => s.updateChatMuted);
|
||||
const setActiveChatId = useChatStore((s) => s.setActiveChatId);
|
||||
const setFocusedMessage = useChatStore((s) => s.setFocusedMessage);
|
||||
const showToast = useUiStore((s) => s.showToast);
|
||||
@@ -306,6 +307,7 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) {
|
||||
try {
|
||||
const updated = await updateChatNotificationSettings(chatId, !muted);
|
||||
setMuted(updated.muted);
|
||||
updateChatMuted(chatId, updated.muted);
|
||||
} catch {
|
||||
setError("Failed to update notifications");
|
||||
} finally {
|
||||
|
||||
@@ -99,6 +99,7 @@ interface ChatState {
|
||||
setReplyToMessage: (chatId: number, message: Message | null) => void;
|
||||
setEditingMessage: (chatId: number, message: Message | null) => void;
|
||||
updateChatPinnedMessage: (chatId: number, pinnedMessageId: number | null) => void;
|
||||
updateChatMuted: (chatId: number, muted: boolean) => void;
|
||||
applyPresenceEvent: (chatId: number, userId: number, isOnline: boolean, lastSeenAt?: string) => void;
|
||||
removeChat: (chatId: number) => void;
|
||||
setDraft: (chatId: number, text: string) => void;
|
||||
@@ -416,6 +417,10 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
set((state) => ({
|
||||
chats: state.chats.map((chat) => (chat.id === chatId ? { ...chat, pinned_message_id: pinnedMessageId } : chat))
|
||||
})),
|
||||
updateChatMuted: (chatId, muted) =>
|
||||
set((state) => ({
|
||||
chats: state.chats.map((chat) => (chat.id === chatId ? { ...chat, muted } : chat))
|
||||
})),
|
||||
applyPresenceEvent: (chatId, userId, isOnline, lastSeenAt) =>
|
||||
set((state) => ({
|
||||
chats: state.chats.map((chat) => {
|
||||
|
||||
Reference in New Issue
Block a user