Fix init muted room list atom

This commit is contained in:
ajbura 2023-02-05 18:04:02 +05:30
parent ddc9bdef70
commit c7e668eed2

View file

@ -25,6 +25,14 @@ export const mutedRoomsAtom = atom<Set<string>, MutedRoomsUpdate>(
(get) => get(baseMutedRoomsAtom), (get) => get(baseMutedRoomsAtom),
(get, set, action) => { (get, set, action) => {
const mutedRooms = new Set([...get(mutedRoomsAtom)]); const mutedRooms = new Set([...get(mutedRoomsAtom)]);
if (action.type === 'INITIALIZE') {
set(baseMutedRoomsAtom, new Set([...action.addRooms]));
set(muteChangesAtom, {
added: [...action.addRooms],
removed: [],
});
return;
}
if (action.type === 'UPDATE') { if (action.type === 'UPDATE') {
action.removeRooms.forEach((roomId) => mutedRooms.delete(roomId)); action.removeRooms.forEach((roomId) => mutedRooms.delete(roomId));
action.addRooms.forEach((roomId) => mutedRooms.add(roomId)); action.addRooms.forEach((roomId) => mutedRooms.add(roomId));