Merge branch 'dev' into Event-maxHeight
This commit is contained in:
22 files changed
+485
-77
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
# Add knocking support when attempting to join a room from the directory, an address, a room mention, or space hierarchy, as well as text command support for knocking. Also improves rendering for knock notifications in rooms.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Removed the blocked users moved notice from notifications setting page.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Replies that mention the OP are now indicated by the OP username being prefixed with @
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Made pin events show a tally of the messages that are pinned.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: fix
|
||||
---
|
||||
|
||||
Made events follow the colors of the name of the person initiating them
|
||||
@@ -0,0 +1,139 @@
|
||||
import { useCallback, useEffect, FormEventHandler } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Dialog,
|
||||
Overlay,
|
||||
OverlayCenter,
|
||||
OverlayBackdrop,
|
||||
Header,
|
||||
config,
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Icon,
|
||||
Icons,
|
||||
Input,
|
||||
color,
|
||||
Button,
|
||||
Spinner,
|
||||
} from 'folds';
|
||||
import { MatrixError } from '$types/matrix-sdk';
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
|
||||
const debugLog = createDebugLogger('KnockRoomPrompt');
|
||||
|
||||
type KnockRoomProps = {
|
||||
roomId: string;
|
||||
via?: string | string[];
|
||||
onDone: () => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [knockState, knockRoom] = useAsyncCallback<undefined, MatrixError, [string?]>(
|
||||
useCallback(
|
||||
async (reason?: string) => {
|
||||
debugLog.info('ui', 'Knock room button clicked', { roomId });
|
||||
mx.knockRoom(roomId, { viaServers: via || undefined, reason });
|
||||
},
|
||||
[mx, roomId, via]
|
||||
)
|
||||
);
|
||||
|
||||
const handleKnock: FormEventHandler<HTMLFormElement> = (evt) => {
|
||||
evt.preventDefault();
|
||||
const target = evt.target as HTMLFormElement;
|
||||
const reasonInput = (target?.reasonInput as HTMLInputElement) || undefined;
|
||||
const reason = reasonInput?.value.trim() || undefined;
|
||||
knockRoom(reason);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (knockState.status === AsyncStatus.Success) {
|
||||
debugLog.info('ui', 'Successfully knocked on room', { roomId });
|
||||
onDone();
|
||||
}
|
||||
}, [knockState, onDone, roomId]);
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: onCancel,
|
||||
clickOutsideDeactivates: true,
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Knock On Room</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleKnock}
|
||||
style={{ padding: config.space.S400 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">
|
||||
Request to join this room. You can optionally leave a reason for the moderators.
|
||||
</Text>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
Reason{' '}
|
||||
<Text as="span" size="T200">
|
||||
(Optional)
|
||||
</Text>
|
||||
</Text>
|
||||
<Input name="reasonInput" variant="Background" />
|
||||
{knockState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to knock! {knockState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
before={
|
||||
knockState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Primary" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
knockState.status === AsyncStatus.Loading ||
|
||||
knockState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{knockState.status === AsyncStatus.Loading ? 'Knocking...' : 'Knock'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './KnockRoomPrompt';
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, Chip, Icon, IconSrc, Icons, Text, as, color, toRem } from 'folds';
|
||||
import { EventTimelineSet, Room, SessionMembershipData } from '$types/matrix-sdk';
|
||||
import { EventTimelineSet, IMentions, Room, SessionMembershipData } from '$types/matrix-sdk';
|
||||
import { MouseEventHandler, ReactNode, useCallback, useMemo } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import classNames from 'classnames';
|
||||
@@ -40,9 +40,11 @@ type ReplyLayoutProps = {
|
||||
userColor?: string;
|
||||
username?: ReactNode;
|
||||
icon?: IconSrc;
|
||||
mentioned: boolean;
|
||||
replyIcon?: JSX.Element;
|
||||
};
|
||||
export const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
({ username, userColor, icon, className, children, ...props }, ref) => (
|
||||
({ username, userColor, icon, className, mentioned, children, replyIcon, ...props }, ref) => (
|
||||
<Box
|
||||
className={classNames(css.Reply, className)}
|
||||
alignItems="Center"
|
||||
@@ -51,10 +53,11 @@ export const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
ref={ref}
|
||||
>
|
||||
<Box style={{ color: userColor }} alignItems="Center" shrink="No">
|
||||
<Icon size="100" src={Icons.ReplyArrow} />
|
||||
{replyIcon || <Icon size="100" src={Icons.ReplyArrow} />}
|
||||
</Box>
|
||||
{!!icon && <Icon style={{ opacity: 0.6 }} size="50" src={icon} />}
|
||||
<Box style={{ color: userColor, maxWidth: toRem(200) }} alignItems="Center" shrink="No">
|
||||
{mentioned && <Icon size="100" src={Icons.Mention} />}
|
||||
{username}
|
||||
</Box>
|
||||
<Box grow="Yes" className={css.ReplyContent}>
|
||||
@@ -83,11 +86,16 @@ type ReplyProps = {
|
||||
timelineSet?: EventTimelineSet;
|
||||
replyEventId: string;
|
||||
threadRootId?: string;
|
||||
mentions?: IMentions;
|
||||
onClick?: MouseEventHandler;
|
||||
replyIcon?: JSX.Element;
|
||||
};
|
||||
|
||||
export const Reply = as<'div', ReplyProps>(
|
||||
({ room, timelineSet, replyEventId, threadRootId, onClick, ...props }, ref) => {
|
||||
(
|
||||
{ room, timelineSet, replyEventId, threadRootId, mentions, onClick, replyIcon, ...props },
|
||||
ref
|
||||
) => {
|
||||
const placeholderWidth = useMemo(() => randomNumberBetween(40, 400), []);
|
||||
const getFromLocalTimeline = useCallback(
|
||||
() => timelineSet?.findEventById(replyEventId),
|
||||
@@ -131,6 +139,7 @@ export const Reply = as<'div', ReplyProps>(
|
||||
|
||||
let bodyJSX: ReactNode = fallbackBody;
|
||||
let image: IconSrc | undefined;
|
||||
let mentioned = sender != null && (mentions?.user_ids?.includes(sender) ?? false);
|
||||
|
||||
const replyLinkifyOpts = useMemo(
|
||||
() => ({
|
||||
@@ -169,6 +178,7 @@ export const Reply = as<'div', ReplyProps>(
|
||||
} else if (eventType === StateEvent.RoomMember && !!replyEvent) {
|
||||
const parsedMemberEvent = parseMemberEvent(replyEvent);
|
||||
image = parsedMemberEvent.icon;
|
||||
mentioned = false;
|
||||
bodyJSX = parsedMemberEvent.body;
|
||||
} else if (eventType === StateEvent.RoomName) {
|
||||
image = Icons.Hash;
|
||||
@@ -183,7 +193,29 @@ export const Reply = as<'div', ReplyProps>(
|
||||
const callJoined = replyEvent.getContent<SessionMembershipData>().application;
|
||||
image = callJoined ? Icons.Phone : Icons.PhoneDown;
|
||||
bodyJSX = callJoined ? ' joined the call' : ' ended the call';
|
||||
} else if (Object.values(MessageEvent).every((v) => v !== eventType)) {
|
||||
} else if (eventType === StateEvent.RoomPinnedEvents && replyEvent) {
|
||||
const { pinned } = replyEvent.getContent();
|
||||
const prevPinned = replyEvent.getPrevContent().pinned;
|
||||
const pinsAdded =
|
||||
prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x));
|
||||
const pinsRemoved =
|
||||
prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x));
|
||||
image = Icons.Pin;
|
||||
bodyJSX = (
|
||||
<>
|
||||
{(pinsAdded?.length > 0 &&
|
||||
`pinned ${pinsAdded.length} message${pinsAdded.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{(pinsAdded?.length > 0 && pinsRemoved?.length > 0 && `and`) || ''}
|
||||
{(pinsRemoved?.length > 0 &&
|
||||
`unpinned ${pinsRemoved.length} message${pinsRemoved.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{(!pinsAdded || pinsAdded.length <= 0) &&
|
||||
(!pinsRemoved || pinsRemoved.length <= 0) &&
|
||||
`has not changed the pins`}
|
||||
</>
|
||||
);
|
||||
} else if (Object.values(MessageEvent).every((v) => v !== eventType && !!eventType)) {
|
||||
image = Icons.Code;
|
||||
bodyJSX = (
|
||||
<>
|
||||
@@ -202,6 +234,8 @@ export const Reply = as<'div', ReplyProps>(
|
||||
as="button"
|
||||
userColor={usernameColor}
|
||||
icon={image}
|
||||
replyIcon={replyIcon}
|
||||
mentioned={mentioned}
|
||||
username={
|
||||
sender &&
|
||||
eventType !== StateEvent.RoomMember && (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ReactNode, useCallback, useRef, useState } from 'react';
|
||||
import { MatrixError, Room } from '$types/matrix-sdk';
|
||||
import { JoinRule, MatrixError, Room } from '$types/matrix-sdk';
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
@@ -31,6 +31,7 @@ import { useElementSizeObserver } from '$hooks/useElementSizeObserver';
|
||||
import { getRoomAvatarUrl, getStateEvent } from '$utils/room';
|
||||
import { useStateEventCallback } from '$hooks/useStateEventCallback';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { KnockRoomPrompt } from '$components/knock-room-prompt';
|
||||
import { RoomAvatar } from '$components/room-avatar';
|
||||
import * as css from './style.css';
|
||||
|
||||
@@ -143,6 +144,7 @@ type RoomCardProps = {
|
||||
topic?: string;
|
||||
memberCount?: number;
|
||||
roomType?: string;
|
||||
joinRule?: JoinRule;
|
||||
viaServers?: string[];
|
||||
onView?: (roomId: string) => void;
|
||||
renderTopicViewer: (name: string, topic: string, requestClose: () => void) => ReactNode;
|
||||
@@ -158,6 +160,7 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
topic,
|
||||
memberCount,
|
||||
roomType,
|
||||
joinRule,
|
||||
viaServers,
|
||||
onView,
|
||||
renderTopicViewer,
|
||||
@@ -172,7 +175,7 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
const [topicEvent, setTopicEvent] = useState(() =>
|
||||
joinedRoom ? getStateEvent(joinedRoom, StateEvent.RoomTopic) : undefined
|
||||
);
|
||||
|
||||
const [knocking, setKnocking] = useState(false);
|
||||
const fallbackName = getMxIdLocalPart(roomIdOrAlias) ?? roomIdOrAlias;
|
||||
const fallbackTopic = roomIdOrAlias;
|
||||
|
||||
@@ -271,19 +274,38 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
{typeof joinedRoomId !== 'string' && joinState.status !== AsyncStatus.Error && (
|
||||
<Button
|
||||
onClick={join}
|
||||
variant="Secondary"
|
||||
size="300"
|
||||
disabled={joining}
|
||||
before={joining && <Spinner size="50" variant="Secondary" fill="Soft" />}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
{joining ? 'Joining' : 'Join'}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
{typeof joinedRoomId !== 'string' &&
|
||||
joinState.status !== AsyncStatus.Error &&
|
||||
(joinRule === JoinRule.Knock ? (
|
||||
<>
|
||||
<Button onClick={() => setKnocking(true)} variant="Secondary" size="300">
|
||||
<Text size="B300" truncate>
|
||||
Knock
|
||||
</Text>
|
||||
</Button>
|
||||
|
||||
{knocking && (
|
||||
<KnockRoomPrompt
|
||||
roomId={roomIdOrAlias}
|
||||
via={viaServers}
|
||||
onDone={() => setKnocking(false)}
|
||||
onCancel={() => setKnocking(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
onClick={join}
|
||||
variant="Secondary"
|
||||
size="300"
|
||||
disabled={joining}
|
||||
before={joining && <Spinner size="50" variant="Secondary" fill="Soft" />}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
{joining ? 'Joining' : 'Join'}
|
||||
</Text>
|
||||
</Button>
|
||||
))}
|
||||
{typeof joinedRoomId !== 'string' && joinState.status === AsyncStatus.Error && (
|
||||
<Box gap="200">
|
||||
<Button
|
||||
|
||||
@@ -65,6 +65,7 @@ export function JoinBeforeNavigate({
|
||||
topic={summary?.topic}
|
||||
memberCount={summary?.num_joined_members}
|
||||
roomType={summary?.room_type}
|
||||
joinRule={summary?.join_rule}
|
||||
viaServers={viaServers}
|
||||
renderTopicViewer={(name, topic, requestClose) => (
|
||||
<RoomTopicViewer name={name} topic={topic} requestClose={requestClose} />
|
||||
|
||||
@@ -25,6 +25,7 @@ import { SequenceCard } from '$components/sequence-card';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { HierarchyItem } from '$hooks/useSpaceHierarchy';
|
||||
import { millify } from '$plugins/millify';
|
||||
import { KnockRoomPrompt } from '$components/knock-room-prompt';
|
||||
import { LocalRoomSummaryLoader } from '$components/RoomSummaryLoader';
|
||||
import { UseStateProvider } from '$components/UseStateProvider';
|
||||
import { RoomTopicViewer } from '$components/room-topic-viewer';
|
||||
@@ -44,7 +45,6 @@ type RoomJoinButtonProps = {
|
||||
};
|
||||
function RoomJoinButton({ roomId, via }: RoomJoinButtonProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [joinState, join] = useAsyncCallback<Room, MatrixError, []>(
|
||||
useCallback(() => mx.joinRoom(roomId, { viaServers: via }), [mx, roomId, via])
|
||||
);
|
||||
@@ -96,6 +96,47 @@ function RoomJoinButton({ roomId, via }: RoomJoinButtonProps) {
|
||||
);
|
||||
}
|
||||
|
||||
function RoomKnockButton({ roomId, via }: RoomJoinButtonProps) {
|
||||
return (
|
||||
<UseStateProvider initial={false}>
|
||||
{(knocking, setKnocking) => (
|
||||
<Box shrink="No" gap="200" alignItems="Center">
|
||||
<Chip
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="400"
|
||||
radii="Pill"
|
||||
before={<Icon src={Icons.MailPlus} size="50" />}
|
||||
onClick={() => setKnocking(true)}
|
||||
>
|
||||
<Text size="B300">Knock</Text>
|
||||
</Chip>
|
||||
{knocking && (
|
||||
<KnockRoomPrompt
|
||||
roomId={roomId}
|
||||
via={via}
|
||||
onDone={() => setKnocking(false)}
|
||||
onCancel={() => setKnocking(false)}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type RoomJoinOrKnockButtonProps = {
|
||||
roomId: string;
|
||||
via?: string[];
|
||||
joinRule?: JoinRule;
|
||||
};
|
||||
function RoomJoinOrKnockButton({ roomId, via, joinRule }: RoomJoinOrKnockButtonProps) {
|
||||
if (joinRule === JoinRule.Knock) {
|
||||
return <RoomKnockButton roomId={roomId} via={via} />;
|
||||
}
|
||||
return <RoomJoinButton roomId={roomId} via={via} />;
|
||||
}
|
||||
|
||||
function RoomProfileLoading() {
|
||||
return (
|
||||
<Box grow="Yes" gap="300">
|
||||
@@ -167,7 +208,7 @@ function RoomProfileError({ roomId, suggested, inaccessibleRoom, via }: RoomProf
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
{!inaccessibleRoom && <RoomJoinButton roomId={roomId} via={via} />}
|
||||
{!inaccessibleRoom && <RoomJoinOrKnockButton roomId={roomId} via={via} />}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -364,7 +405,11 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
|
||||
</Chip>
|
||||
</Box>
|
||||
) : (
|
||||
<RoomJoinButton roomId={roomId} via={content.via} />
|
||||
<RoomJoinOrKnockButton
|
||||
roomId={roomId}
|
||||
via={content.via}
|
||||
joinRule={localSummary.joinRule}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -408,7 +453,13 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
|
||||
memberCount={summary.num_joined_members}
|
||||
suggested={content.suggested}
|
||||
joinRule={summary.join_rule}
|
||||
options={<RoomJoinButton roomId={roomId} via={content.via} />}
|
||||
options={
|
||||
<RoomJoinOrKnockButton
|
||||
roomId={roomId}
|
||||
via={content.via}
|
||||
joinRule={summary.join_rule}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -323,6 +323,7 @@ export function SearchResultGroup({
|
||||
room={room}
|
||||
replyEventId={replyEventId}
|
||||
threadRootId={threadRootId}
|
||||
mentions={event.content['m.mentions']}
|
||||
onClick={handleOpenClick}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -185,6 +185,7 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) {
|
||||
room={room}
|
||||
replyEventId={rootEvent.replyEventId}
|
||||
threadRootId={rootEvent.threadRootId}
|
||||
mentions={rootEvent.getContent()['m.mentions']}
|
||||
onClick={handleJumpClick}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -255,6 +255,7 @@ function ThreadMessage({
|
||||
room={room}
|
||||
timelineSet={timelineSet}
|
||||
replyEventId={replyEventId}
|
||||
mentions={baseContent['m.mentions']}
|
||||
onClick={onReferenceClick}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -134,6 +134,7 @@ function PinnedMessageActiveContent(
|
||||
getMemberDisplayName(room, sender, nicknames) ?? getMxIdLocalPart(sender) ?? sender;
|
||||
const senderAvatarMxc = getMemberAvatarMxc(room, sender);
|
||||
const getContent = (() => pinnedEvent.getContent()) as GetContentCallback;
|
||||
const content = pinnedEvent.getContent();
|
||||
|
||||
const memberPowerTag = getMemberPowerTag(sender);
|
||||
const tagIconSrc = memberPowerTag?.icon
|
||||
@@ -183,6 +184,7 @@ function PinnedMessageActiveContent(
|
||||
room={room}
|
||||
replyEventId={pinnedEvent.replyEventId}
|
||||
threadRootId={pinnedEvent.threadRootId}
|
||||
mentions={content['m.mentions']}
|
||||
onClick={handleOpenClick}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { SequenceCardStyle } from '$features/settings/styles.css';
|
||||
import { SystemNotification } from './SystemNotification';
|
||||
import { AllMessagesNotifications } from './AllMessages';
|
||||
import { SpecialMessagesNotifications } from './SpecialMessages';
|
||||
@@ -36,17 +33,6 @@ export function Notifications({ requestClose }: NotificationsProps) {
|
||||
<AllMessagesNotifications />
|
||||
<SpecialMessagesNotifications />
|
||||
<KeywordMessagesNotifications />
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Block Messages</Text>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile description='This option has been moved to "Account > Block Users" section.' />
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
|
||||
@@ -7,11 +7,12 @@ import {
|
||||
Room,
|
||||
PushProcessor,
|
||||
EventTimelineSet,
|
||||
IContent,
|
||||
} from '$types/matrix-sdk';
|
||||
import { SessionMembershipData } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import { Box, Chip, Avatar, Text, Icons, config, toRem } from 'folds';
|
||||
import { Box, Chip, Avatar, Text, Icons, config, toRem, Icon } from 'folds';
|
||||
import { MessageLayout } from '$state/settings';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
import { useGetMemberPowerTag } from '$hooks/useMemberPowerTag';
|
||||
@@ -52,8 +53,21 @@ import {
|
||||
Message,
|
||||
Reactions,
|
||||
} from '$features/room/message';
|
||||
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
import * as css from './TimelineEventRenderer.css';
|
||||
|
||||
function DecoratedUser({ room, userId, userName }: DecoratedUserProps) {
|
||||
const { color, font } = useSableCosmetics(userId, room ?? ({} as Room));
|
||||
return <b style={{ color, font }}> {userName ?? userId} </b>;
|
||||
}
|
||||
|
||||
type DecoratedUserProps = {
|
||||
room: Room;
|
||||
userId: string;
|
||||
userName?: string;
|
||||
};
|
||||
|
||||
type ThreadReplyChipProps = {
|
||||
room: Room;
|
||||
mEventId: string;
|
||||
@@ -295,10 +309,10 @@ export function useTimelineEventRenderer({
|
||||
editedNewContent = getEditedContent.call(editedEvent)['m.new_content'];
|
||||
}
|
||||
|
||||
const baseContent = (getEventContent.call(mEvent) || {}) as Record<string, any>;
|
||||
const baseContent = getEventContent.call(mEvent) || {};
|
||||
const safeContent = (
|
||||
Object.keys(baseContent).length > 0 ? baseContent : getOriginalContent.call(mEvent)
|
||||
) as Record<string, any>;
|
||||
) as IContent;
|
||||
|
||||
const getContent = (() => editedNewContent ?? safeContent) as GetContentCallback;
|
||||
|
||||
@@ -365,6 +379,7 @@ export function useTimelineEventRenderer({
|
||||
timelineSet={timelineSet}
|
||||
replyEventId={replyEventId}
|
||||
threadRootId={threadRootId}
|
||||
mentions={baseContent['m.mentions']}
|
||||
onClick={handleOpenReply}
|
||||
/>
|
||||
)
|
||||
@@ -610,6 +625,7 @@ export function useTimelineEventRenderer({
|
||||
const senderId = getSender.call(mEvent) ?? '';
|
||||
const senderDisplayName =
|
||||
getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId;
|
||||
const content = getEventContent.call(mEvent) ?? {};
|
||||
|
||||
return (
|
||||
<Message
|
||||
@@ -644,6 +660,7 @@ export function useTimelineEventRenderer({
|
||||
timelineSet={timelineSet}
|
||||
replyEventId={replyEventId}
|
||||
threadRootId={threadRootId}
|
||||
mentions={content['m.mentions']}
|
||||
onClick={handleOpenReply}
|
||||
/>
|
||||
)
|
||||
@@ -764,7 +781,6 @@ export function useTimelineEventRenderer({
|
||||
const senderId = getSender.call(mEvent) ?? '';
|
||||
const senderName =
|
||||
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
|
||||
|
||||
const timeJSX = (
|
||||
<Time
|
||||
ts={getTs.call(mEvent)}
|
||||
@@ -796,7 +812,7 @@ export function useTimelineEventRenderer({
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{t('Organisms.RoomCommon.changed_room_name')}
|
||||
</Text>
|
||||
</Box>
|
||||
@@ -843,7 +859,7 @@ export function useTimelineEventRenderer({
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{' changed room topic'}
|
||||
</Text>
|
||||
</Box>
|
||||
@@ -890,7 +906,7 @@ export function useTimelineEventRenderer({
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{' changed room avatar'}
|
||||
</Text>
|
||||
</Box>
|
||||
@@ -944,7 +960,7 @@ export function useTimelineEventRenderer({
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{callJoined ? ' joined the call' : ' ended the call'}
|
||||
</Text>
|
||||
</Box>
|
||||
@@ -953,6 +969,92 @@ export function useTimelineEventRenderer({
|
||||
</Event>
|
||||
);
|
||||
},
|
||||
[StateEvent.RoomPinnedEvents]: (mEventId, mEvent, item, timelineSet, collapse) => {
|
||||
const { getSender, getTs, getContent, getPrevContent } = mEvent;
|
||||
if (!showHiddenEvents) return null;
|
||||
const highlighted = focusItem?.index === item && focusItem.highlight;
|
||||
const senderId = getSender.call(mEvent) ?? '';
|
||||
const senderName =
|
||||
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
|
||||
|
||||
const { pinned } = getContent.call(mEvent);
|
||||
const prevPinned = getPrevContent.call(mEvent).pinned;
|
||||
const pinsAdded =
|
||||
prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x));
|
||||
const pinsRemoved =
|
||||
prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x));
|
||||
|
||||
const timeJSX = (
|
||||
<Time
|
||||
ts={getTs.call(mEvent)}
|
||||
compact={messageLayout === MessageLayout.Compact}
|
||||
hour24Clock={hour24Clock}
|
||||
dateFormatString={dateFormatString}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Event
|
||||
key={mEventId}
|
||||
data-message-item={item}
|
||||
data-message-id={mEventId}
|
||||
room={room}
|
||||
mEvent={mEvent}
|
||||
highlight={highlighted}
|
||||
collapse={collapse}
|
||||
canDelete={canRedact || senderId === mx.getUserId()}
|
||||
onReplyClick={onReplyClick}
|
||||
hideReadReceipts={hideReads}
|
||||
showDeveloperTools={showDeveloperTools}
|
||||
messageSpacing={messageSpacing}
|
||||
>
|
||||
<EventContent
|
||||
messageLayout={messageLayout}
|
||||
time={timeJSX}
|
||||
iconSrc={Icons.Pin}
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300">
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{(pinsAdded?.length > 0 &&
|
||||
`pinned ${pinsAdded.length} message${pinsAdded.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{(pinsAdded?.length > 0 && pinsRemoved?.length > 0 && ` and`) || ''}
|
||||
{(pinsRemoved?.length > 0 &&
|
||||
`unpinned ${pinsRemoved.length} message${pinsRemoved.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{((!pinsAdded || pinsAdded.length <= 0) &&
|
||||
(!pinsRemoved || pinsRemoved.length <= 0) &&
|
||||
`has not changed the pins`) ||
|
||||
`:`}
|
||||
</Text>
|
||||
{(pinsAdded || pinsRemoved) &&
|
||||
pinsAdded
|
||||
.concat(pinsRemoved)
|
||||
.slice(0, 4)
|
||||
.map((x: string) => (
|
||||
<Reply
|
||||
style={{ opacity: '80%' }}
|
||||
room={room}
|
||||
replyEventId={x ?? ''}
|
||||
onClick={handleOpenReply}
|
||||
replyIcon={
|
||||
<>
|
||||
<Icon size="100" src={Icons.Pin} />
|
||||
<Icon
|
||||
size="100"
|
||||
src={pinned.includes(x) ? Icons.Plus : Icons.Minus}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
</Event>
|
||||
);
|
||||
},
|
||||
},
|
||||
(mEventId, mEvent, item, timelineSet, collapse) => {
|
||||
const { getSender, getTs, getType } = mEvent;
|
||||
@@ -992,8 +1094,8 @@ export function useTimelineEventRenderer({
|
||||
iconSrc={Icons.Code}
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300">
|
||||
<b>{senderName}</b>
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<DecoratedUser userId={senderId} userName={senderName} room={room} />
|
||||
{' sent '}
|
||||
<code className={customHtmlCss.Code}>{getType.call(mEvent)}</code>
|
||||
{' state event'}
|
||||
@@ -1053,7 +1155,7 @@ export function useTimelineEventRenderer({
|
||||
iconSrc={Icons.Code}
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300">
|
||||
<Text size="T300" priority="300" className={css.StateEvent}>
|
||||
<b>{senderName}</b>
|
||||
{' sent '}
|
||||
<code className={customHtmlCss.Code}>{getType.call(mEvent)}</code>
|
||||
|
||||
@@ -233,6 +233,7 @@ export enum Command {
|
||||
Delete = 'delete',
|
||||
Acl = 'acl',
|
||||
// Sable commands
|
||||
Knock = 'knock',
|
||||
Color = 'color',
|
||||
SColor = 'scolor',
|
||||
Font = 'font',
|
||||
@@ -763,6 +764,20 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
},
|
||||
},
|
||||
// Sable commands
|
||||
[Command.Knock]: {
|
||||
name: Command.Knock,
|
||||
description:
|
||||
'Knock on (request to join) room with address. Example: /knock address1 address2',
|
||||
exe: async (payload) => {
|
||||
const rawIds = splitWithSpace(payload);
|
||||
const roomIdOrAliases = rawIds.filter(
|
||||
(idOrAlias) => isRoomId(idOrAlias) || isRoomAlias(idOrAlias)
|
||||
);
|
||||
roomIdOrAliases.forEach(async (idOrAlias) => {
|
||||
await mx.knockRoom(idOrAlias);
|
||||
});
|
||||
},
|
||||
},
|
||||
[Command.Color]: {
|
||||
name: Command.Color,
|
||||
description: 'Set a room-specific color. Example: /color #ff00ff | /color reset',
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { IconSrc, Icons } from 'folds';
|
||||
import { MatrixEvent } from '$types/matrix-sdk';
|
||||
import { MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { IMemberContent, Membership } from '$types/matrix/room';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { isMembershipChanged } from '$utils/room';
|
||||
import { useSableCosmetics } from './useSableCosmetics';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
|
||||
type DecoratedUserProps = {
|
||||
roomId: string;
|
||||
userId: string;
|
||||
userName?: string;
|
||||
};
|
||||
|
||||
function DecoratedUser({ roomId, userId, userName }: DecoratedUserProps) {
|
||||
const mx = useMatrixClient();
|
||||
const room = mx.getRoom(roomId);
|
||||
const { color, font } = useSableCosmetics(userId, room ?? ({} as Room));
|
||||
return <b style={{ color, font }}> {userName ?? userId} </b>;
|
||||
}
|
||||
|
||||
export type ParsedResult = {
|
||||
icon: IconSrc;
|
||||
@@ -18,6 +33,7 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
const prevContent = mEvent.getPrevContent() as IMemberContent;
|
||||
const senderId = mEvent.getSender();
|
||||
const userId = mEvent.getStateKey();
|
||||
const roomId = mEvent.getRoomId();
|
||||
const reason = typeof content.reason === 'string' ? content.reason : undefined;
|
||||
|
||||
if (!senderId || !userId)
|
||||
@@ -39,9 +55,9 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
icon: Icons.ArrowGoRightPlus,
|
||||
body: (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' accepted '}
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{`'s join request `}
|
||||
{reason}
|
||||
</>
|
||||
@@ -53,9 +69,10 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
icon: Icons.ArrowGoRightPlus,
|
||||
body: (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' invited '}
|
||||
<b>{userName}</b> {reason}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{reason}
|
||||
</>
|
||||
),
|
||||
};
|
||||
@@ -63,12 +80,12 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
|
||||
if (content.membership === Membership.Knock) {
|
||||
return {
|
||||
icon: Icons.ArrowGoRightPlus,
|
||||
icon: Icons.Mail,
|
||||
body: (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
{' request to join room '}
|
||||
{reason}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' requested to join room: '}
|
||||
<i>{reason}</i>
|
||||
</>
|
||||
),
|
||||
};
|
||||
@@ -79,7 +96,7 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
icon: Icons.ArrowGoRight,
|
||||
body: (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' joined the room'}
|
||||
</>
|
||||
),
|
||||
@@ -93,15 +110,15 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' rejected the invitation '}
|
||||
{reason}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' rejected '}
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{`'s join request `}
|
||||
{reason}
|
||||
</>
|
||||
@@ -115,15 +132,15 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' revoked joined request '}
|
||||
{reason}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' revoked '}
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{`'s invite `}
|
||||
{reason}
|
||||
</>
|
||||
@@ -136,9 +153,10 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
icon: Icons.ArrowGoLeft,
|
||||
body: (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' unbanned '}
|
||||
<b>{userName}</b> {reason}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{reason}
|
||||
</>
|
||||
),
|
||||
};
|
||||
@@ -149,15 +167,16 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' left the room '}
|
||||
{reason}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' kicked '}
|
||||
<b>{userName}</b> {reason}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{reason}
|
||||
</>
|
||||
),
|
||||
};
|
||||
@@ -168,9 +187,10 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
icon: Icons.ArrowGoLeft,
|
||||
body: (
|
||||
<>
|
||||
<b>{senderName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' banned '}
|
||||
<b>{userName}</b> {reason}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{reason}
|
||||
</>
|
||||
),
|
||||
};
|
||||
@@ -188,13 +208,13 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
body:
|
||||
typeof content.displayname === 'string' ? (
|
||||
<>
|
||||
<b>{prevUserName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
{' changed display name to '}
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<b>{prevUserName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
{' removed their display name '}
|
||||
</>
|
||||
),
|
||||
@@ -206,12 +226,12 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
body:
|
||||
content.avatar_url && typeof content.avatar_url === 'string' ? (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' changed their avatar'}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<b>{userName}</b>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
{' removed their avatar '}
|
||||
</>
|
||||
),
|
||||
|
||||
@@ -67,6 +67,7 @@ export function FeaturedRooms() {
|
||||
name={roomSummary?.name}
|
||||
topic={roomSummary?.topic}
|
||||
memberCount={roomSummary?.num_joined_members}
|
||||
joinRule={roomSummary?.join_rule}
|
||||
onView={navigateSpace}
|
||||
renderTopicViewer={(name, topic, requestClose) => (
|
||||
<RoomTopicViewer
|
||||
@@ -96,6 +97,7 @@ export function FeaturedRooms() {
|
||||
name={roomSummary?.name}
|
||||
topic={roomSummary?.topic}
|
||||
memberCount={roomSummary?.num_joined_members}
|
||||
joinRule={roomSummary?.join_rule}
|
||||
onView={navigateRoom}
|
||||
renderTopicViewer={(name, topic, requestClose) => (
|
||||
<RoomTopicViewer
|
||||
|
||||
@@ -599,6 +599,7 @@ export function PublicRooms() {
|
||||
topic={chunkRoom.topic}
|
||||
memberCount={chunkRoom.num_joined_members}
|
||||
roomType={chunkRoom.room_type}
|
||||
joinRule={chunkRoom.join_rule}
|
||||
onView={
|
||||
chunkRoom.room_type === RoomType.Space
|
||||
? navigateSpace
|
||||
|
||||
@@ -468,6 +468,9 @@ function RoomNotificationsGroupComp({
|
||||
const replyEventId = relation?.['m.in_reply_to']?.event_id;
|
||||
const threadRootId =
|
||||
relation?.rel_type === RelationType.Thread ? relation.event_id : undefined;
|
||||
// doesn't work for encrypted rooms
|
||||
// not a big deal really, don't want to bother with finding the event by id and decrypting
|
||||
const mentions = event.content['m.mentions'];
|
||||
|
||||
const memberPowerTag = getMemberPowerTag(event.sender);
|
||||
const tagColor = memberPowerTag?.color
|
||||
@@ -543,6 +546,7 @@ function RoomNotificationsGroupComp({
|
||||
room={room}
|
||||
replyEventId={replyEventId}
|
||||
threadRootId={threadRootId}
|
||||
mentions={mentions}
|
||||
onClick={handleOpenClick}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user