mirror of
https://github.com/owncast/owncast.git
synced 2024-11-22 21:03:19 +03:00
fix(chat): fix chat not using the correct messages selector. (#3180)
* fix(chat): fix chat not using the correct messages selector. Closes #3166 * fix(chat): initial state was incorrect when hiding/showing messages
This commit is contained in:
parent
b0c50fb8e5
commit
777da508ed
2 changed files with 5 additions and 7 deletions
|
@ -174,7 +174,7 @@ export const ClientConfigStore: FC = () => {
|
||||||
const setAppState = useSetRecoilState<AppStateOptions>(appStateAtom);
|
const setAppState = useSetRecoilState<AppStateOptions>(appStateAtom);
|
||||||
const setGlobalFatalErrorMessage = useSetRecoilState<DisplayableError>(fatalErrorStateAtom);
|
const setGlobalFatalErrorMessage = useSetRecoilState<DisplayableError>(fatalErrorStateAtom);
|
||||||
const setWebsocketService = useSetRecoilState<WebsocketService>(websocketServiceAtom);
|
const setWebsocketService = useSetRecoilState<WebsocketService>(websocketServiceAtom);
|
||||||
const [hiddenMessageIds, setHiddenMessageIds] = useRecoilState<string[]>(removedMessageIdsAtom);
|
const setHiddenMessageIds = useSetRecoilState<string[]>(removedMessageIdsAtom);
|
||||||
const [hasLoadedConfig, setHasLoadedConfig] = useState(false);
|
const [hasLoadedConfig, setHasLoadedConfig] = useState(false);
|
||||||
|
|
||||||
let ws: WebsocketService;
|
let ws: WebsocketService;
|
||||||
|
@ -279,11 +279,9 @@ export const ClientConfigStore: FC = () => {
|
||||||
const handleMessageVisibilityChange = (message: MessageVisibilityEvent) => {
|
const handleMessageVisibilityChange = (message: MessageVisibilityEvent) => {
|
||||||
const { ids, visible } = message;
|
const { ids, visible } = message;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
const updatedIds = hiddenMessageIds.filter(id => !ids.includes(id));
|
setHiddenMessageIds(currentState => currentState.filter(id => !ids.includes(id)));
|
||||||
setHiddenMessageIds(updatedIds);
|
|
||||||
} else {
|
} else {
|
||||||
const updatedIds = [...hiddenMessageIds, ...ids];
|
setHiddenMessageIds(currentState => [...currentState, ...ids]);
|
||||||
setHiddenMessageIds(updatedIds);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import { canPushNotificationsBeSupported } from '../../../utils/browserPushNotif
|
||||||
|
|
||||||
import {
|
import {
|
||||||
clientConfigStateAtom,
|
clientConfigStateAtom,
|
||||||
chatMessagesAtom,
|
|
||||||
currentUserAtom,
|
currentUserAtom,
|
||||||
ChatState,
|
ChatState,
|
||||||
chatStateAtom,
|
chatStateAtom,
|
||||||
|
@ -19,6 +18,7 @@ import {
|
||||||
isMobileAtom,
|
isMobileAtom,
|
||||||
serverStatusState,
|
serverStatusState,
|
||||||
isChatAvailableSelector,
|
isChatAvailableSelector,
|
||||||
|
visibleChatMessagesSelector,
|
||||||
} from '../../stores/ClientConfigStore';
|
} from '../../stores/ClientConfigStore';
|
||||||
import { ClientConfig } from '../../../interfaces/client-config.model';
|
import { ClientConfig } from '../../../interfaces/client-config.model';
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ export const Content: FC = () => {
|
||||||
const currentUser = useRecoilValue(currentUserAtom);
|
const currentUser = useRecoilValue(currentUserAtom);
|
||||||
const serverStatus = useRecoilValue<ServerStatus>(serverStatusState);
|
const serverStatus = useRecoilValue<ServerStatus>(serverStatusState);
|
||||||
const [isMobile, setIsMobile] = useRecoilState<boolean | undefined>(isMobileAtom);
|
const [isMobile, setIsMobile] = useRecoilState<boolean | undefined>(isMobileAtom);
|
||||||
const messages = useRecoilValue<ChatMessage[]>(chatMessagesAtom);
|
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
|
||||||
const online = useRecoilValue<boolean>(isOnlineSelector);
|
const online = useRecoilValue<boolean>(isOnlineSelector);
|
||||||
const isChatAvailable = useRecoilValue<boolean>(isChatAvailableSelector);
|
const isChatAvailable = useRecoilValue<boolean>(isChatAvailableSelector);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue