diff --git a/web/components/stores/ClientConfigStore.tsx b/web/components/stores/ClientConfigStore.tsx index 4bb53f6ea..50c5926c3 100644 --- a/web/components/stores/ClientConfigStore.tsx +++ b/web/components/stores/ClientConfigStore.tsx @@ -174,7 +174,7 @@ export const ClientConfigStore: FC = () => { const setAppState = useSetRecoilState(appStateAtom); const setGlobalFatalErrorMessage = useSetRecoilState(fatalErrorStateAtom); const setWebsocketService = useSetRecoilState(websocketServiceAtom); - const [hiddenMessageIds, setHiddenMessageIds] = useRecoilState(removedMessageIdsAtom); + const setHiddenMessageIds = useSetRecoilState(removedMessageIdsAtom); const [hasLoadedConfig, setHasLoadedConfig] = useState(false); let ws: WebsocketService; @@ -279,11 +279,9 @@ export const ClientConfigStore: FC = () => { const handleMessageVisibilityChange = (message: MessageVisibilityEvent) => { const { ids, visible } = message; if (visible) { - const updatedIds = hiddenMessageIds.filter(id => !ids.includes(id)); - setHiddenMessageIds(updatedIds); + setHiddenMessageIds(currentState => currentState.filter(id => !ids.includes(id))); } else { - const updatedIds = [...hiddenMessageIds, ...ids]; - setHiddenMessageIds(updatedIds); + setHiddenMessageIds(currentState => [...currentState, ...ids]); } }; diff --git a/web/components/ui/Content/Content.tsx b/web/components/ui/Content/Content.tsx index 496e4464b..ffdef5e76 100644 --- a/web/components/ui/Content/Content.tsx +++ b/web/components/ui/Content/Content.tsx @@ -10,7 +10,6 @@ import { canPushNotificationsBeSupported } from '../../../utils/browserPushNotif import { clientConfigStateAtom, - chatMessagesAtom, currentUserAtom, ChatState, chatStateAtom, @@ -19,6 +18,7 @@ import { isMobileAtom, serverStatusState, isChatAvailableSelector, + visibleChatMessagesSelector, } from '../../stores/ClientConfigStore'; import { ClientConfig } from '../../../interfaces/client-config.model'; @@ -103,7 +103,7 @@ export const Content: FC = () => { const currentUser = useRecoilValue(currentUserAtom); const serverStatus = useRecoilValue(serverStatusState); const [isMobile, setIsMobile] = useRecoilState(isMobileAtom); - const messages = useRecoilValue(chatMessagesAtom); + const messages = useRecoilValue(visibleChatMessagesSelector); const online = useRecoilValue(isOnlineSelector); const isChatAvailable = useRecoilValue(isChatAvailableSelector);