Add categorize space option

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-02 21:30:14 +05:30
parent e63f8ab8b8
commit 116a9c9de0

View file

@ -6,7 +6,12 @@ import { twemojify } from '../../../util/twemojify';
import initMatrix from '../../../client/initMatrix'; import initMatrix from '../../../client/initMatrix';
import { openSpaceSettings, openSpaceManage, openInviteUser } from '../../../client/action/navigation'; import { openSpaceSettings, openSpaceManage, openInviteUser } from '../../../client/action/navigation';
import { leave } from '../../../client/action/room'; import { leave } from '../../../client/action/room';
import { createSpaceShortcut, deleteSpaceShortcut } from '../../../client/action/accountData'; import {
createSpaceShortcut,
deleteSpaceShortcut,
categorizeSpace,
unCategorizeSpace,
} from '../../../client/action/accountData';
import { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu'; import { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu';
@ -24,6 +29,7 @@ function SpaceOptions({ roomId, afterOptionSelect }) {
const room = mx.getRoom(roomId); const room = mx.getRoom(roomId);
const canInvite = room?.canInvite(mx.getUserId()); const canInvite = room?.canInvite(mx.getUserId());
const isPinned = initMatrix.accountData.spaceShortcut.has(roomId); const isPinned = initMatrix.accountData.spaceShortcut.has(roomId);
const isCategorized = initMatrix.accountData.categorizedSpaces.has(roomId);
const handleInviteClick = () => { const handleInviteClick = () => {
openInviteUser(roomId); openInviteUser(roomId);
@ -35,7 +41,8 @@ function SpaceOptions({ roomId, afterOptionSelect }) {
afterOptionSelect(); afterOptionSelect();
}; };
const handleCategorizeClick = () => { const handleCategorizeClick = () => {
alert('categorize'); if (isCategorized) unCategorizeSpace(roomId);
else categorizeSpace(roomId);
afterOptionSelect(); afterOptionSelect();
}; };
const handleSettingsClick = () => { const handleSettingsClick = () => {
@ -59,9 +66,9 @@ function SpaceOptions({ roomId, afterOptionSelect }) {
<MenuHeader>{twemojify(`Options for ${initMatrix.matrixClient.getRoom(roomId)?.name}`)}</MenuHeader> <MenuHeader>{twemojify(`Options for ${initMatrix.matrixClient.getRoom(roomId)?.name}`)}</MenuHeader>
<MenuItem <MenuItem
onClick={handleCategorizeClick} onClick={handleCategorizeClick}
iconSrc={CategoryIC} iconSrc={isCategorized ? CategoryFilledIC : CategoryIC}
> >
Categorize subspaces {isCategorized ? 'Uncategorize subspaces' : 'Categorize subspaces'}
</MenuItem> </MenuItem>
<MenuItem <MenuItem
onClick={handlePinClick} onClick={handlePinClick}