Files
cinny/src/app/state/spaceRooms.ts
T
Lotus Bot d32055ee3d chore: bulk dependency updates + fix immer v11 default import + sentry test
Package updates (safe minor/major bumps, all build-verified):
- @tanstack/react-query 5.24->5.100, react-virtual 3.2->3.13
- jotai 2.6->2.20, immer 9->11, dayjs, chroma-js, classnames, blurhash
- slate/slate-dom/slate-react 0.123->0.124
- focus-trap-react 10->12, react-error-boundary 4->6
- html-dom-parser 4->7, html-react-parser 4->6
- pdfjs-dist 4->5, ua-parser-js 1->2
- i18next-http-backend 3->4, i18next-browser-languagedetector 8.0->8.2
- react-aria 3.29->3.48, matrix-widget-api 1.16->1.17
- @atlaskit/pragmatic-drag-and-drop* minor bumps
- @rollup/plugin-inject 5.0.3->5.0.5, @rollup/plugin-wasm 6.1->6.2
- @element-hq/element-call-embedded 0.19.3->0.19.4
- @types/* patches, eslint-plugin-* minors

Breaking change fix:
- immer v11 removed default export; updated 11 files to named import

Temporary: add Sentry test button to WelcomePage for verification.
Remove after confirming errors reach the dashboard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 22:23:19 -04:00

60 lines
1.4 KiB
TypeScript

import { atom } from 'jotai';
import { produce } from 'immer';
import {
atomWithLocalStorage,
getLocalStorageItem,
setLocalStorageItem,
} from './utils/atomWithLocalStorage';
const SPACE_ROOMS = 'spaceRooms';
const baseSpaceRoomsAtom = atomWithLocalStorage<Set<string>>(
SPACE_ROOMS,
(key) => {
const arrayValue = getLocalStorageItem<string[]>(key, []);
return new Set(arrayValue);
},
(key, value) => {
const arrayValue = Array.from(value);
setLocalStorageItem(key, arrayValue);
}
);
type SpaceRoomsAction =
| {
type: 'PUT';
roomIds: string[];
}
| {
type: 'DELETE';
roomIds: string[];
};
export const spaceRoomsAtom = atom<Set<string>, [SpaceRoomsAction], undefined>(
(get) => get(baseSpaceRoomsAtom),
(get, set, action) => {
const current = get(baseSpaceRoomsAtom);
const { type, roomIds } = action;
if (type === 'DELETE' && roomIds.find((roomId) => current.has(roomId))) {
set(
baseSpaceRoomsAtom,
produce(current, (draft) => {
roomIds.forEach((roomId) => draft.delete(roomId));
})
);
return;
}
if (type === 'PUT') {
const newEntries = roomIds.filter((roomId) => !current.has(roomId));
if (newEntries.length > 0)
set(
baseSpaceRoomsAtom,
produce(current, (draft) => {
newEntries.forEach((roomId) => draft.add(roomId));
})
);
}
}
);