mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-23 13:43:07 +01:00
rename closedRoomCategories to closedNavCategories
This commit is contained in:
parent
08f7fc438f
commit
f951df1e89
4 changed files with 23 additions and 23 deletions
|
@ -28,7 +28,7 @@ import { useDirectCreateSelected } from '../../../hooks/router/useDirectSelected
|
|||
import { VirtualTile } from '../../../components/virtualizer';
|
||||
import { RoomNavCategoryButton, RoomNavItem } from '../../../features/room-nav';
|
||||
import { muteChangesAtom } from '../../../state/room-list/mutedRoomList';
|
||||
import { closedRoomCategories, makeRoomCategoryId } from '../../../state/closedRoomCategories';
|
||||
import { closedNavCategories, makeNavCategoryId } from '../../../state/closedNavCategories';
|
||||
import { roomToUnreadAtom } from '../../../state/room/roomToUnread';
|
||||
|
||||
function DirectEmpty() {
|
||||
|
@ -58,7 +58,7 @@ function DirectEmpty() {
|
|||
);
|
||||
}
|
||||
|
||||
const DEFAULT_CATEGORY_ID = makeRoomCategoryId('direct', 'direct');
|
||||
const DEFAULT_CATEGORY_ID = makeNavCategoryId('direct', 'direct');
|
||||
export function Direct() {
|
||||
const mx = useMatrixClient();
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
@ -71,7 +71,7 @@ export function Direct() {
|
|||
const selectedRoomId = useSelectedRoom();
|
||||
const createSelected = useDirectCreateSelected();
|
||||
const noRoomToDisplay = directs.length === 0;
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedRoomCategories);
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedNavCategories);
|
||||
|
||||
const sortedDirects = useMemo(() => {
|
||||
const items = Array.from(directs).sort(factoryRoomIdByActivity(mx));
|
||||
|
|
|
@ -36,7 +36,7 @@ import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
|||
import { VirtualTile } from '../../../components/virtualizer';
|
||||
import { RoomNavCategoryButton, RoomNavItem } from '../../../features/room-nav';
|
||||
import { muteChangesAtom } from '../../../state/room-list/mutedRoomList';
|
||||
import { closedRoomCategories, makeRoomCategoryId } from '../../../state/closedRoomCategories';
|
||||
import { closedNavCategories, makeNavCategoryId } from '../../../state/closedNavCategories';
|
||||
import { roomToUnreadAtom } from '../../../state/room/roomToUnread';
|
||||
|
||||
function HomeEmpty() {
|
||||
|
@ -80,7 +80,7 @@ function HomeEmpty() {
|
|||
);
|
||||
}
|
||||
|
||||
const DEFAULT_CATEGORY_ID = makeRoomCategoryId('home', 'room');
|
||||
const DEFAULT_CATEGORY_ID = makeNavCategoryId('home', 'room');
|
||||
export function Home() {
|
||||
const mx = useMatrixClient();
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
@ -94,7 +94,7 @@ export function Home() {
|
|||
const joinSelected = useHomeJoinSelected();
|
||||
const searchSelected = useHomeSearchSelected();
|
||||
const noRoomToDisplay = rooms.length === 0;
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedRoomCategories);
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedNavCategories);
|
||||
|
||||
const sortedRooms = useMemo(() => {
|
||||
const items = Array.from(rooms).sort(factoryRoomIdByAtoZ(mx));
|
||||
|
|
|
@ -28,7 +28,7 @@ import { VirtualTile } from '../../../components/virtualizer';
|
|||
import { useSpaceHierarchy } from './useSpaceHierarchy';
|
||||
import { RoomNavCategoryButton, RoomNavItem } from '../../../features/room-nav';
|
||||
import { muteChangesAtom } from '../../../state/room-list/mutedRoomList';
|
||||
import { closedRoomCategories, makeRoomCategoryId } from '../../../state/closedRoomCategories';
|
||||
import { closedNavCategories, makeNavCategoryId } from '../../../state/closedNavCategories';
|
||||
import { roomToUnreadAtom } from '../../../state/room/roomToUnread';
|
||||
|
||||
export function Space() {
|
||||
|
@ -45,15 +45,15 @@ export function Space() {
|
|||
const lobbySelected = useSpaceLobbySelected(spaceIdOrAlias);
|
||||
const searchSelected = useSpaceSearchSelected(spaceIdOrAlias);
|
||||
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedRoomCategories);
|
||||
const [closedCategories, setClosedCategory] = useAtom(closedNavCategories);
|
||||
const hierarchy = useSpaceHierarchy(
|
||||
space.roomId,
|
||||
useCallback(
|
||||
(spaceRoomId, directCategory) => {
|
||||
if (directCategory) {
|
||||
return closedCategories.has(makeRoomCategoryId(space.roomId, spaceRoomId, 'direct'));
|
||||
return closedCategories.has(makeNavCategoryId(space.roomId, spaceRoomId, 'direct'));
|
||||
}
|
||||
return closedCategories.has(makeRoomCategoryId(space.roomId, spaceRoomId));
|
||||
return closedCategories.has(makeNavCategoryId(space.roomId, spaceRoomId));
|
||||
},
|
||||
[space.roomId, closedCategories]
|
||||
),
|
||||
|
@ -148,8 +148,8 @@ export function Space() {
|
|||
const dmCategory = lastSpaceId === roomId;
|
||||
lastSpaceId = roomId;
|
||||
const categoryId = dmCategory
|
||||
? makeRoomCategoryId(space.roomId, roomId, 'direct')
|
||||
: makeRoomCategoryId(space.roomId, roomId);
|
||||
? makeNavCategoryId(space.roomId, roomId, 'direct')
|
||||
: makeNavCategoryId(space.roomId, roomId);
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
|
|
|
@ -6,10 +6,10 @@ import {
|
|||
setLocalStorageItem,
|
||||
} from './utils/atomWithLocalStorage';
|
||||
|
||||
const CLOSED_ROOM_CATEGORY = 'closedRoomCategories';
|
||||
const CLOSED_NAV_CATEGORY = 'closedNavCategories';
|
||||
|
||||
const baseClosedRoomCategories = atomWithLocalStorage<Set<string>>(
|
||||
CLOSED_ROOM_CATEGORY,
|
||||
const baseClosedNavCategories = atomWithLocalStorage<Set<string>>(
|
||||
CLOSED_NAV_CATEGORY,
|
||||
(key) => {
|
||||
const arrayValue = getLocalStorageItem<string[]>(key, []);
|
||||
return new Set(arrayValue);
|
||||
|
@ -20,7 +20,7 @@ const baseClosedRoomCategories = atomWithLocalStorage<Set<string>>(
|
|||
}
|
||||
);
|
||||
|
||||
type ClosedRoomCategoriesAction =
|
||||
type ClosedNavCategoriesAction =
|
||||
| {
|
||||
type: 'PUT';
|
||||
categoryId: string;
|
||||
|
@ -30,13 +30,13 @@ type ClosedRoomCategoriesAction =
|
|||
categoryId: string;
|
||||
};
|
||||
|
||||
export const closedRoomCategories = atom<Set<string>, [ClosedRoomCategoriesAction], undefined>(
|
||||
(get) => get(baseClosedRoomCategories),
|
||||
export const closedNavCategories = atom<Set<string>, [ClosedNavCategoriesAction], undefined>(
|
||||
(get) => get(baseClosedNavCategories),
|
||||
(get, set, action) => {
|
||||
if (action.type === 'DELETE') {
|
||||
set(
|
||||
baseClosedRoomCategories,
|
||||
produce(get(baseClosedRoomCategories), (draft) => {
|
||||
baseClosedNavCategories,
|
||||
produce(get(baseClosedNavCategories), (draft) => {
|
||||
draft.delete(action.categoryId);
|
||||
})
|
||||
);
|
||||
|
@ -44,8 +44,8 @@ export const closedRoomCategories = atom<Set<string>, [ClosedRoomCategoriesActio
|
|||
}
|
||||
if (action.type === 'PUT') {
|
||||
set(
|
||||
baseClosedRoomCategories,
|
||||
produce(get(baseClosedRoomCategories), (draft) => {
|
||||
baseClosedNavCategories,
|
||||
produce(get(baseClosedNavCategories), (draft) => {
|
||||
draft.add(action.categoryId);
|
||||
})
|
||||
);
|
||||
|
@ -53,4 +53,4 @@ export const closedRoomCategories = atom<Set<string>, [ClosedRoomCategoriesActio
|
|||
}
|
||||
);
|
||||
|
||||
export const makeRoomCategoryId = (...args: string[]): string => args.join('|');
|
||||
export const makeNavCategoryId = (...args: string[]): string => args.join('|');
|
Loading…
Reference in a new issue