mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-16 12:10:28 +03:00
Added option to fav spaces (#52)
This commit is contained in:
parent
2e58757bc9
commit
cdf421f0f1
17 changed files with 269 additions and 112 deletions
|
|
@ -5,20 +5,25 @@ import PropTypes from 'prop-types';
|
|||
import initMatrix from '../../../client/initMatrix';
|
||||
import { doesRoomHaveUnread } from '../../../util/matrixUtil';
|
||||
import navigation from '../../../client/state/navigation';
|
||||
import { createSpaceShortcut, deleteSpaceShortcut } from '../../../client/action/room';
|
||||
|
||||
import IconButton from '../../atoms/button/IconButton';
|
||||
import RoomSelector from '../../molecules/room-selector/RoomSelector';
|
||||
|
||||
import HashIC from '../../../../public/res/ic/outlined/hash.svg';
|
||||
import HashLockIC from '../../../../public/res/ic/outlined/hash-lock.svg';
|
||||
import SpaceIC from '../../../../public/res/ic/outlined/space.svg';
|
||||
import SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg';
|
||||
import StarIC from '../../../../public/res/ic/outlined/star.svg';
|
||||
import FilledStarIC from '../../../../public/res/ic/filled/star.svg';
|
||||
|
||||
function Selector({
|
||||
roomId, isDM, drawerPostie, onClick,
|
||||
}) {
|
||||
const mx = initMatrix.matrixClient;
|
||||
const room = mx.getRoom(roomId);
|
||||
const imageSrc = room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
|
||||
let imageSrc = room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
|
||||
if (imageSrc === null) imageSrc = room.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
|
||||
|
||||
const [isSelected, setIsSelected] = useState(navigation.selectedRoomId === roomId);
|
||||
const [, forceUpdate] = useState({});
|
||||
|
|
@ -60,6 +65,23 @@ function Selector({
|
|||
notificationCount={room.getUnreadNotificationCount('total') || 0}
|
||||
isAlert={room.getUnreadNotificationCount('highlight') !== 0}
|
||||
onClick={onClick}
|
||||
options={(
|
||||
!room.isSpaceRoom()
|
||||
? null
|
||||
: (
|
||||
<IconButton
|
||||
size="extra-small"
|
||||
variant={initMatrix.roomList.spaceShortcut.has(roomId) ? 'positive' : 'surface'}
|
||||
tooltip={initMatrix.roomList.spaceShortcut.has(roomId) ? 'Remove favourite' : 'Favourite'}
|
||||
src={initMatrix.roomList.spaceShortcut.has(roomId) ? FilledStarIC : StarIC}
|
||||
onClick={() => {
|
||||
if (initMatrix.roomList.spaceShortcut.has(roomId)) deleteSpaceShortcut(roomId);
|
||||
else createSpaceShortcut(roomId);
|
||||
forceUpdate({});
|
||||
}}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue