feat: add notifications and invites routes to the router and update path utilities
This commit is contained in:
@@ -221,6 +221,8 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
|||||||
>
|
>
|
||||||
{mobile ? null : <Route index element={<WelcomePage />} />}
|
{mobile ? null : <Route index element={<WelcomePage />} />}
|
||||||
<Route path={_CREATE_PATH} element={<DirectCreate />} />
|
<Route path={_CREATE_PATH} element={<DirectCreate />} />
|
||||||
|
<Route path={_NOTIFICATIONS_PATH} element={<Notifications />} />
|
||||||
|
<Route path={_INVITES_PATH} element={<Invites />} />
|
||||||
<Route
|
<Route
|
||||||
path={_ROOM_PATH}
|
path={_ROOM_PATH}
|
||||||
element={
|
element={
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
NavItemContent,
|
NavItemContent,
|
||||||
NavLink,
|
NavLink,
|
||||||
} from '../../../components/nav';
|
} from '../../../components/nav';
|
||||||
import { getDirectCreatePath, getDirectRoomPath, getInboxInvitesPath, getInboxNotificationsPath } from '../../pathUtils';
|
import { getDirectCreatePath, getDirectRoomPath, getDirectNotificationsPath, getDirectInvitesPath } from '../../pathUtils';
|
||||||
import { getCanonicalAliasOrRoomId } from '../../../utils/matrix';
|
import { getCanonicalAliasOrRoomId } from '../../../utils/matrix';
|
||||||
import { useSelectedRoom } from '../../../hooks/router/useSelectedRoom';
|
import { useSelectedRoom } from '../../../hooks/router/useSelectedRoom';
|
||||||
import { VirtualTile } from '../../../components/virtualizer';
|
import { VirtualTile } from '../../../components/virtualizer';
|
||||||
@@ -55,7 +55,6 @@ import {
|
|||||||
} from '../../../hooks/useRoomsNotificationPreferences';
|
} from '../../../hooks/useRoomsNotificationPreferences';
|
||||||
import { useDirectCreateSelected } from '../../../hooks/router/useDirectSelected';
|
import { useDirectCreateSelected } from '../../../hooks/router/useDirectSelected';
|
||||||
import { allInvitesAtom } from '../../../state/room-list/inviteList';
|
import { allInvitesAtom } from '../../../state/room-list/inviteList';
|
||||||
import { useInboxInvitesSelected, useInboxNotificationsSelected } from '../../../hooks/router/useInbox';
|
|
||||||
import { UnreadBadge } from '../../../components/unread-badge';
|
import { UnreadBadge } from '../../../components/unread-badge';
|
||||||
|
|
||||||
type DirectMenuProps = {
|
type DirectMenuProps = {
|
||||||
@@ -178,7 +177,6 @@ function DirectEmpty() {
|
|||||||
* Navigation item for room invites
|
* Navigation item for room invites
|
||||||
*/
|
*/
|
||||||
function InvitesNavItem() {
|
function InvitesNavItem() {
|
||||||
const invitesSelected = useInboxInvitesSelected();
|
|
||||||
const allInvites = useAtomValue(allInvitesAtom);
|
const allInvites = useAtomValue(allInvitesAtom);
|
||||||
const inviteCount = allInvites.length;
|
const inviteCount = allInvites.length;
|
||||||
|
|
||||||
@@ -187,13 +185,12 @@ function InvitesNavItem() {
|
|||||||
variant="Background"
|
variant="Background"
|
||||||
radii="400"
|
radii="400"
|
||||||
highlight={inviteCount > 0}
|
highlight={inviteCount > 0}
|
||||||
aria-selected={invitesSelected}
|
|
||||||
>
|
>
|
||||||
<NavLink to={getInboxInvitesPath()}>
|
<NavLink to={getDirectInvitesPath()}>
|
||||||
<NavItemContent>
|
<NavItemContent>
|
||||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||||
<Avatar size="200" radii="400">
|
<Avatar size="200" radii="400">
|
||||||
<Icon src={Icons.Mail} size="100" filled={invitesSelected} />
|
<Icon src={Icons.Mail} size="100" />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<Box as="span" grow="Yes">
|
<Box as="span" grow="Yes">
|
||||||
<Text as="span" size="Inherit" truncate>
|
<Text as="span" size="Inherit" truncate>
|
||||||
@@ -212,15 +209,13 @@ function InvitesNavItem() {
|
|||||||
* Navigation item for notifications
|
* Navigation item for notifications
|
||||||
*/
|
*/
|
||||||
function NotificationsNavItem() {
|
function NotificationsNavItem() {
|
||||||
const notificationsSelected = useInboxNotificationsSelected();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavItem variant="Background" radii="400" aria-selected={notificationsSelected}>
|
<NavItem variant="Background" radii="400">
|
||||||
<NavLink to={getInboxNotificationsPath()}>
|
<NavLink to={getDirectNotificationsPath()}>
|
||||||
<NavItemContent>
|
<NavItemContent>
|
||||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||||
<Avatar size="200" radii="400">
|
<Avatar size="200" radii="400">
|
||||||
<Icon src={Icons.MessageUnread} size="100" filled={notificationsSelected} />
|
<Icon src={Icons.MessageUnread} size="100" />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<Box as="span" grow="Yes">
|
<Box as="span" grow="Yes">
|
||||||
<Text as="span" size="Inherit" truncate>
|
<Text as="span" size="Inherit" truncate>
|
||||||
@@ -235,6 +230,7 @@ function NotificationsNavItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_CATEGORY_ID = makeNavCategoryId('direct', 'direct');
|
const DEFAULT_CATEGORY_ID = makeNavCategoryId('direct', 'direct');
|
||||||
|
|
||||||
export function Direct() {
|
export function Direct() {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
useNavToActivePathMapper('direct');
|
useNavToActivePathMapper('direct');
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import {
|
|||||||
DIRECT_CREATE_PATH,
|
DIRECT_CREATE_PATH,
|
||||||
DIRECT_PATH,
|
DIRECT_PATH,
|
||||||
DIRECT_ROOM_PATH,
|
DIRECT_ROOM_PATH,
|
||||||
|
DIRECT_NOTIFICATIONS_PATH,
|
||||||
|
DIRECT_INVITES_PATH,
|
||||||
EXPLORE_FEATURED_PATH,
|
EXPLORE_FEATURED_PATH,
|
||||||
EXPLORE_PATH,
|
EXPLORE_PATH,
|
||||||
EXPLORE_SERVER_PATH,
|
EXPLORE_SERVER_PATH,
|
||||||
@@ -110,6 +112,8 @@ export const getDirectRoomPath = (roomIdOrAlias: string, eventId?: string): stri
|
|||||||
|
|
||||||
return generatePath(DIRECT_ROOM_PATH, params);
|
return generatePath(DIRECT_ROOM_PATH, params);
|
||||||
};
|
};
|
||||||
|
export const getDirectNotificationsPath = (): string => DIRECT_NOTIFICATIONS_PATH;
|
||||||
|
export const getDirectInvitesPath = (): string => DIRECT_INVITES_PATH;
|
||||||
|
|
||||||
export const getSpacePath = (spaceIdOrAlias: string): string => {
|
export const getSpacePath = (spaceIdOrAlias: string): string => {
|
||||||
const params = {
|
const params = {
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ export type InboxNotificationsPathSearchParams = {
|
|||||||
export const INBOX_NOTIFICATIONS_PATH = `/inbox/${_NOTIFICATIONS_PATH}`;
|
export const INBOX_NOTIFICATIONS_PATH = `/inbox/${_NOTIFICATIONS_PATH}`;
|
||||||
export const INBOX_INVITES_PATH = `/inbox/${_INVITES_PATH}`;
|
export const INBOX_INVITES_PATH = `/inbox/${_INVITES_PATH}`;
|
||||||
|
|
||||||
|
export const DIRECT_NOTIFICATIONS_PATH = `/direct/${_NOTIFICATIONS_PATH}`;
|
||||||
|
export const DIRECT_INVITES_PATH = `/direct/${_INVITES_PATH}`;
|
||||||
|
|
||||||
export const SPACE_SETTINGS_PATH = '/space-settings/';
|
export const SPACE_SETTINGS_PATH = '/space-settings/';
|
||||||
|
|
||||||
export const ROOM_SETTINGS_PATH = '/room-settings/';
|
export const ROOM_SETTINGS_PATH = '/room-settings/';
|
||||||
|
|||||||
Reference in New Issue
Block a user