Fix init muted room list atom
This commit is contained in:
parent
ddc9bdef70
commit
c7e668eed2
1 changed files with 8 additions and 0 deletions
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue