mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-03 15:22:22 -08:00
fix: adapt forum view to current dev APIs
This commit is contained in:
9 files changed
+49
-75
No files matched your search
@@ -598,6 +598,7 @@ export type OptionMenuProps = {
|
||||
onEditId?: (eventId?: string) => void;
|
||||
onReproxyId?: (profileId?: string) => void;
|
||||
hideReadReceipts?: boolean;
|
||||
hideReplyButton?: boolean;
|
||||
showDeveloperTools?: boolean;
|
||||
canPinEvent?: boolean;
|
||||
canDelete?: boolean;
|
||||
@@ -622,6 +623,7 @@ function OptionMenu({
|
||||
onReplyClick,
|
||||
onEditId,
|
||||
hideReadReceipts,
|
||||
hideReplyButton,
|
||||
showDeveloperTools,
|
||||
canPinEvent,
|
||||
canDelete,
|
||||
@@ -808,20 +810,22 @@ function OptionMenu({
|
||||
{isGif && isModal && (
|
||||
<MessageFavoriteGifItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
)}
|
||||
<MenuItem
|
||||
size="300"
|
||||
after={menuIcon(ArrowBendUpLeftIcon)}
|
||||
radii="300"
|
||||
data-event-id={mEvent.getId()}
|
||||
onClick={(evt) => {
|
||||
onReplyClick(evt);
|
||||
onTotalClose();
|
||||
}}
|
||||
>
|
||||
<Text className={css.MessageMenuItemText} as="span" size="T300" truncate>
|
||||
Reply
|
||||
</Text>
|
||||
</MenuItem>
|
||||
{!hideReplyButton && (
|
||||
<MenuItem
|
||||
size="300"
|
||||
after={menuIcon(ArrowBendUpLeftIcon)}
|
||||
radii="300"
|
||||
data-event-id={mEvent.getId()}
|
||||
onClick={(evt) => {
|
||||
onReplyClick(evt);
|
||||
onTotalClose();
|
||||
}}
|
||||
>
|
||||
<Text className={css.MessageMenuItemText} as="span" size="T300" truncate>
|
||||
Reply
|
||||
</Text>
|
||||
</MenuItem>
|
||||
)}
|
||||
{!isThreadedMessage && (
|
||||
<MenuItem
|
||||
size="300"
|
||||
|
||||
@@ -16,10 +16,7 @@ type UploadBoardProps = {
|
||||
export const UploadBoard = as<'div', UploadBoardProps>(
|
||||
({ header, showUploadCardBottom, children, ...props }, ref) => (
|
||||
<Box className={css.UploadBoardBase} {...props} ref={ref}>
|
||||
<Box
|
||||
className={css.UploadBoardContainer({ isBottom: showUploadCardBottom === true })}
|
||||
justifyContent="End"
|
||||
>
|
||||
<Box className={css.UploadBoardContainer} justifyContent="End">
|
||||
<Box className={classNames(css.UploadBoard)} direction="Column">
|
||||
<Box grow="Yes" direction="Column">
|
||||
{children}
|
||||
|
||||
@@ -35,11 +35,17 @@ import { BackRouteHandler } from '$components/BackRouteHandler';
|
||||
import { mxcUrlToHttp } from '$utils/matrix';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { useRoomPinnedEvents } from '$hooks/useRoomPinnedEvents';
|
||||
import { getPinsHash } from '$utils/room';
|
||||
import { RoomPinMenu } from '$features/room/room-pin-menu';
|
||||
import { ForumMenu } from './ForumMenu';
|
||||
import * as css from './ForumView.css';
|
||||
|
||||
const getPinsHash = async (pinnedIds: string[]): Promise<string> =>
|
||||
crypto.subtle
|
||||
.digest('SHA-256', new TextEncoder().encode(pinnedIds.join()))
|
||||
.then((hash) =>
|
||||
Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, '0')).join('')
|
||||
);
|
||||
|
||||
type ForumHeaderProps = {
|
||||
room: Room;
|
||||
showProfile?: boolean;
|
||||
|
||||
@@ -2,8 +2,6 @@ import { forwardRef, useState } from 'react';
|
||||
import { Box, Line, Menu, MenuItem, Text, config, toRem } from 'folds';
|
||||
import type { Room } from 'matrix-js-sdk';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { UseStateProvider } from '$components/UseStateProvider';
|
||||
import { LeaveRoomPrompt } from '$components/leave-room-prompt';
|
||||
import { InviteUserPrompt } from '$components/invite-user-prompt';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useIsDirectRoom } from '$hooks/useRoom';
|
||||
@@ -20,15 +18,7 @@ import { getCanonicalAliasOrRoomId, isRoomAlias } from '$utils/matrix';
|
||||
import { getHomeRoomPath, getDirectRoomPath, getSpaceRoomPath } from '$pages/pathUtils';
|
||||
import { getMatrixToRoom } from '$plugins/matrix-to';
|
||||
import { getViaServers } from '$plugins/via-servers';
|
||||
import {
|
||||
Checks,
|
||||
GearSix,
|
||||
Link,
|
||||
menuIcon,
|
||||
SignOut,
|
||||
Terminal,
|
||||
UserPlus,
|
||||
} from '$components/icons/phosphor';
|
||||
import { Checks, GearSix, Link, menuIcon, Terminal, UserPlus } from '$components/icons/phosphor';
|
||||
|
||||
type ForumMenuProps = {
|
||||
room: Room;
|
||||
@@ -141,35 +131,6 @@ export const ForumMenu = forwardRef<HTMLDivElement, ForumMenuProps>(
|
||||
</MenuItem>
|
||||
)}
|
||||
</Box>
|
||||
<Line variant="Surface" size="300" />
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
<UseStateProvider initial={false}>
|
||||
{(promptLeave, setPromptLeave) => (
|
||||
<>
|
||||
<MenuItem
|
||||
onClick={() => setPromptLeave(true)}
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
size="300"
|
||||
after={menuIcon(SignOut)}
|
||||
radii="300"
|
||||
aria-pressed={promptLeave}
|
||||
>
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Leave Room
|
||||
</Text>
|
||||
</MenuItem>
|
||||
{promptLeave && (
|
||||
<LeaveRoomPrompt
|
||||
roomId={room.roomId}
|
||||
onDone={requestClose}
|
||||
onCancel={() => setPromptLeave(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
</Box>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ import type { Thread } from 'matrix-js-sdk/lib/models/thread';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room/display';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix';
|
||||
import { UserAvatar } from '$components/user-avatar';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
import type { ThreadRootItemProps } from '$features/room/ThreadRootItem';
|
||||
import { ThreadRootItem } from '$features/room/ThreadRootItem';
|
||||
import { getThreadReplyEvents } from '$features/room/ThreadDrawer';
|
||||
import { getThreadReplyEvents } from '$utils/room/relations';
|
||||
import * as css from './ForumView.css';
|
||||
|
||||
type ForumThreadItemProps = ThreadRootItemProps & {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { Page, PageContent, PageContentCenter, PageHeroSection } from '$components/page';
|
||||
import { CaretUp, Chats, composerIcon, sizedIcon } from '$components/icons/phosphor';
|
||||
import { MembersDrawer } from '$features/room/MembersDrawer';
|
||||
import { ThreadDrawer, getThreadReplyEvents } from '$features/room/ThreadDrawer';
|
||||
import { ThreadDrawer } from '$features/room/ThreadDrawer';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
@@ -26,7 +26,7 @@ import { PowerLevelsContextProvider, usePowerLevels } from '$hooks/usePowerLevel
|
||||
import { roomIdToOpenThreadAtomFamily } from '$state/room/roomToOpenThread';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { useRoomMembers } from '$hooks/useRoomMembers';
|
||||
import { reactionOrEditEvent } from '$utils/room';
|
||||
import { getThreadReplyEvents, reactionOrEditEvent } from '$utils/room/relations';
|
||||
import { mxcUrlToHttp, toggleReaction } from '$utils/matrix';
|
||||
import { useStateEvent } from '$hooks/useStateEvent';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
@@ -341,6 +341,7 @@ export function ForumView() {
|
||||
room.roomId,
|
||||
undefined,
|
||||
userId,
|
||||
undefined,
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
);
|
||||
},
|
||||
@@ -358,6 +359,7 @@ export function ForumView() {
|
||||
room.roomId,
|
||||
undefined,
|
||||
userId,
|
||||
undefined,
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
);
|
||||
},
|
||||
@@ -467,7 +469,6 @@ export function ForumView() {
|
||||
editor={editor}
|
||||
roomId={room.roomId}
|
||||
fileDropContainerRef={roomViewRef}
|
||||
showUploadCardBottom
|
||||
/>
|
||||
)}
|
||||
{!canMessage && (
|
||||
|
||||
@@ -270,16 +270,6 @@ function AddRoomButton({ item }: { item: HierarchyItem }) {
|
||||
>
|
||||
<Text size="T300">New Room</Text>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
size="300"
|
||||
radii="300"
|
||||
variant="Primary"
|
||||
fill="None"
|
||||
onClick={() => handleCreateRoom(CreateRoomType.ForumRoom)}
|
||||
after={<BetaNoticeBadge />}
|
||||
>
|
||||
<Text size="T300">Forum Room</Text>
|
||||
</MenuItem>
|
||||
<MenuItem size="300" radii="300" fill="None" onClick={handleAddExisting}>
|
||||
<Text size="T300">Existing Room</Text>
|
||||
</MenuItem>
|
||||
|
||||
@@ -8,7 +8,8 @@ import type { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import type { Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import { Image } from '$components/media';
|
||||
import { ImageViewer } from '$components/image-viewer';
|
||||
import { getEditedEvent, getEventReactions, getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberDisplayName } from '$utils/room/display';
|
||||
import { getEditedEvent, getEventReactions } from '$utils/room/relations';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { ImageContent, MSticker, RedactedContent, Reply } from '$components/message';
|
||||
import { RenderMessageContent } from '$components/RenderMessageContent';
|
||||
|
||||
@@ -33,6 +33,9 @@ import {
|
||||
NAVIGATE_PATH,
|
||||
PROFILE_PATH,
|
||||
INBOX_BOOKMARKS_PATH,
|
||||
HOME_ROOM_FORUM_PATH,
|
||||
DIRECT_ROOM_FORUM_PATH,
|
||||
SPACE_ROOM_FORUM_PATH,
|
||||
} from './paths';
|
||||
|
||||
export const joinPathComponent = (path: Path): string => path.pathname + path.search + path.hash;
|
||||
@@ -108,6 +111,9 @@ export const getHomeRoomPath = (roomIdOrAlias: string, eventId?: string): string
|
||||
return generatePath(HOME_ROOM_PATH, params);
|
||||
};
|
||||
|
||||
export const getHomeForumPath = (roomIdOrAlias: string): string =>
|
||||
generatePath(HOME_ROOM_FORUM_PATH, { roomIdOrAlias: encodeURIComponent(roomIdOrAlias) });
|
||||
|
||||
export const getDirectPath = (): string => DIRECT_PATH;
|
||||
export const getDirectCreatePath = (): string => DIRECT_CREATE_PATH;
|
||||
export const getDirectRoomPath = (roomIdOrAlias: string, eventId?: string): string => {
|
||||
@@ -119,6 +125,9 @@ export const getDirectRoomPath = (roomIdOrAlias: string, eventId?: string): stri
|
||||
return generatePath(DIRECT_ROOM_PATH, params);
|
||||
};
|
||||
|
||||
export const getDirectForumPath = (roomIdOrAlias: string): string =>
|
||||
generatePath(DIRECT_ROOM_FORUM_PATH, { roomIdOrAlias: encodeURIComponent(roomIdOrAlias) });
|
||||
|
||||
export const getSpacePath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
@@ -151,6 +160,11 @@ export const getSpaceRoomPath = (
|
||||
|
||||
return generatePath(SPACE_ROOM_PATH, params);
|
||||
};
|
||||
export const getSpaceForumPath = (spaceIdOrAlias: string, roomIdOrAlias: string): string =>
|
||||
generatePath(SPACE_ROOM_FORUM_PATH, {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
roomIdOrAlias: encodeURIComponent(roomIdOrAlias),
|
||||
});
|
||||
|
||||
export const getExplorePath = (): string => EXPLORE_PATH;
|
||||
export const getExploreFeaturedPath = (): string => EXPLORE_FEATURED_PATH;
|
||||
|
||||
Reference in new issue
Block a user