Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(app): flatten DM list, details and composer choices

Hampusaf438c0761ed
diff --git a/fluxer_app/src/features/channel/components/ReplyPreview.tsx b/fluxer_app/src/features/channel/components/ReplyPreview.tsx
index b18525d13..da0507347 100644
--- a/fluxer_app/src/features/channel/components/ReplyPreview.tsx
+++ b/fluxer_app/src/features/channel/components/ReplyPreview.tsx
@@ -14,10 +14,10 @@ import markupStyles from '@app/features/theme/styles/Markup.module.css';
import styles from '@app/features/theme/styles/Message.module.css';
import {Avatar} from '@app/features/ui/components/Avatar';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
+import {ArrowBendUpLeftIcon} from '@app/features/ui/icons/DirectionalIcons';
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
import {msg} from '@lingui/core/macro';
import {useLingui} from '@lingui/react/macro';
-import {ArrowBendUpLeftIcon} from '@phosphor-icons/react';
import {clsx} from 'clsx';
import {observer} from 'mobx-react-lite';
import {type CSSProperties, useCallback} from 'react';
@@ -70,7 +70,9 @@ export const ReplyPreview = observer(
});
}
}, [referenceChannelId, message.channelId, message.id, message.messageReference]);
- if (!message.messageReference || message.isCrosspostCopy) return null;
+ if (!message.messageReference || message.isCrosspostCopy) {
+ return null;
+ }
if (resolution.state !== MessageReferenceState.LOADED) {
const isDeleted = resolution.state === MessageReferenceState.DELETED;
return (
@@ -125,12 +127,12 @@ export const ReplyPreview = observer(
referencedMessage.author.id !== Authentication.currentUserId &&
LocalUserSpamOverride.isUserMarkedAsSpammer(referencedMessage.author.id, referencedMessage.author.flags);
const isCollapsedReferenceRevealed = isMessageRevealed(referencedMessage);
- const hiddenReplyReason =
- referencedMessage.blocked && !isCollapsedReferenceRevealed
- ? i18n._(REPLY_HIDDEN_BECAUSE_THE_ORIGINAL_AUTHOR_IS_BLOCKED_DESCRIPTOR)
- : isSpammerReply && !isCollapsedReferenceRevealed
- ? i18n._(REPLY_HIDDEN_BECAUSE_THE_ORIGINAL_AUTHOR_IS_MARKED_DESCRIPTOR)
- : null;
+ let hiddenReplyReason: string | null = null;
+ if (referencedMessage.blocked && !isCollapsedReferenceRevealed) {
+ hiddenReplyReason = i18n._(REPLY_HIDDEN_BECAUSE_THE_ORIGINAL_AUTHOR_IS_BLOCKED_DESCRIPTOR);
+ } else if (isSpammerReply && !isCollapsedReferenceRevealed) {
+ hiddenReplyReason = i18n._(REPLY_HIDDEN_BECAUSE_THE_ORIGINAL_AUTHOR_IS_MARKED_DESCRIPTOR);
+ }
if (hiddenReplyReason) {
return (
<div
diff --git a/fluxer_app/src/features/channel/components/UserMessage.tsx b/fluxer_app/src/features/channel/components/UserMessage.tsx
index 837d95a71..3ede089c2 100644
--- a/fluxer_app/src/features/channel/components/UserMessage.tsx
+++ b/fluxer_app/src/features/channel/components/UserMessage.tsx
@@ -180,12 +180,12 @@ export const UserMessage = observer(() => {
message.state === MessageStates.FAILED && (mobileLayout.enabled || shouldHideContent || !hasStyleableTextContent);
const shouldApplyFailedTextStyling =
message.state === MessageStates.FAILED && !shouldHideContent && hasStyleableTextContent;
- const messageStateClassName =
- message.state === MessageStates.FAILED
- ? shouldApplyFailedTextStyling
- ? styles.messageFailed
- : undefined
- : MessageStateToClassName[message.state];
+ let messageStateClassName: string | undefined;
+ if (message.state !== MessageStates.FAILED) {
+ messageStateClassName = MessageStateToClassName[message.state];
+ } else if (shouldApplyFailedTextStyling) {
+ messageStateClassName = styles.messageFailed;
+ }
const checkCustomEmojiAvailability = useCallback(
(content: string): boolean => {
CUSTOM_EMOJI_MARKDOWN_PATTERN.lastIndex = 0;
@@ -308,6 +308,7 @@ export const UserMessage = observer(() => {
return (
<div
className={clsx(markupStyles.markup)}
+ dir="auto"
data-search-highlight-scope="message"
data-flx="channel.user-message.render-message-content.div"
{...messageContentCopyBlockProps(contentCopyText)}
@@ -443,6 +444,7 @@ export const UserMessage = observer(() => {
<div className={styles.messageText} data-flx="channel.user-message.message-text">
<div
className={clsx(markupStyles.markup)}
+ dir="auto"
data-search-highlight-scope="message"
data-flx="channel.user-message.div"
{...messageContentCopyBlockProps(contentCopyText)}
diff --git a/fluxer_app/src/features/channel/components/bottomsheets/channel_details_bottom_sheet/ChannelInfoHeader.tsx b/fluxer_app/src/features/channel/components/bottomsheets/channel_details_bottom_sheet/ChannelInfoHeader.tsx
index 0606c11af..eb8781586 100644
--- a/fluxer_app/src/features/channel/components/bottomsheets/channel_details_bottom_sheet/ChannelInfoHeader.tsx
+++ b/fluxer_app/src/features/channel/components/bottomsheets/channel_details_bottom_sheet/ChannelInfoHeader.tsx
@@ -36,122 +36,134 @@ export const ChannelInfoHeader: React.FC<ChannelInfoHeaderProps> = ({
const isPersonalNotes = channel.type === ChannelTypes.DM_PERSONAL_NOTES;
const isGroupDM = channel.type === ChannelTypes.GROUP_DM;
const recipientDisplayName = recipient ? NicknameUtils.getNickname(recipient, null, channel.id) : '';
- return (
- <div className={styles.channelInfoSection} data-flx="channel.channel-details-bottom-sheet.channel-info-section">
- <Sheet.CloseButton
- onClick={onClose}
- className={styles.closeButton}
- data-flx="channel.channel-details-bottom-sheet.close-button"
+ const sectionClassName = styles.channelInfoSection;
+ const closeButton = (
+ <Sheet.CloseButton
+ onClick={onClose}
+ className={styles.closeButton}
+ data-flx="channel.channel-details-bottom-sheet.close-button"
+ />
+ );
+ const containerClassName = styles.channelInfoContainer;
+ let avatar: React.ReactNode;
+ if (isDM && recipient) {
+ avatar = (
+ <StatusAwareAvatar
+ user={recipient}
+ size={48}
+ data-flx="channel.channel-details-bottom-sheet.status-aware-avatar"
/>
- <div
- className={styles.channelInfoContainer}
- data-flx="channel.channel-details-bottom-sheet.channel-info-container"
- >
- {isDM && recipient ? (
- <StatusAwareAvatar
- user={recipient}
- size={48}
- data-flx="channel.channel-details-bottom-sheet.status-aware-avatar"
- />
- ) : isGroupDM ? (
- <GroupDMAvatar channel={channel} size={48} data-flx="channel.channel-details-bottom-sheet.group-dm-avatar" />
- ) : isPersonalNotes && currentUser ? (
- <StatusAwareAvatar
- user={currentUser}
- size={48}
- data-flx="channel.channel-details-bottom-sheet.status-aware-avatar--2"
+ );
+ } else if (isGroupDM) {
+ avatar = (
+ <GroupDMAvatar channel={channel} size={48} data-flx="channel.channel-details-bottom-sheet.group-dm-avatar" />
+ );
+ } else if (isPersonalNotes && currentUser) {
+ avatar = (
+ <StatusAwareAvatar
+ user={currentUser}
+ size={48}
+ data-flx="channel.channel-details-bottom-sheet.status-aware-avatar--2"
+ />
+ );
+ } else {
+ avatar = (
+ <div className={styles.channelAvatar} data-flx="channel.channel-details-bottom-sheet.channel-avatar">
+ {ChannelUtils.getIcon(channel, {className: styles.iconLarge})}
+ </div>
+ );
+ }
+ const contentClassName = styles.channelInfoContent;
+ let title: React.ReactNode;
+ if (isDM && recipient) {
+ title = (
+ <>
+ <div
+ className={styles.channelInfoUserContainer}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-user-container"
+ >
+ <span
+ className={styles.channelInfoUsername}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-username"
+ >
+ {recipientDisplayName}
+ </span>
+ <span
+ className={styles.channelInfoDiscriminator}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-discriminator"
+ >
+ {NicknameUtils.formatUserTagForStreamerMode(recipient)}
+ </span>
+ </div>
+ {recipient.bot && (
+ <UserTag
+ className={styles.channelInfoTag}
+ system={recipient.system}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-tag"
/>
- ) : (
- <div className={styles.channelAvatar} data-flx="channel.channel-details-bottom-sheet.channel-avatar">
- {ChannelUtils.getIcon(channel, {className: styles.iconLarge})}
- </div>
)}
- <div className={styles.channelInfoContent} data-flx="channel.channel-details-bottom-sheet.channel-info-content">
- {isDM && recipient ? (
- <>
- <div
- className={styles.channelInfoUserContainer}
- data-flx="channel.channel-details-bottom-sheet.channel-info-user-container"
- >
- <span
- className={styles.channelInfoUsername}
- data-flx="channel.channel-details-bottom-sheet.channel-info-username"
- >
- {recipientDisplayName}
- </span>
- <span
- className={styles.channelInfoDiscriminator}
- data-flx="channel.channel-details-bottom-sheet.channel-info-discriminator"
- >
- {NicknameUtils.formatUserTagForStreamerMode(recipient)}
- </span>
- </div>
- {recipient.bot && (
- <UserTag
- className={styles.channelInfoTag}
- system={recipient.system}
- data-flx="channel.channel-details-bottom-sheet.channel-info-tag"
- />
- )}
- </>
- ) : isGroupDM ? (
- <>
- <h2
- className={styles.channelInfoTitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-title"
- >
- {ChannelUtils.getDMDisplayName(channel)}
- </h2>
- <p
- className={styles.channelInfoSubtitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle"
- >
- {plural(
- {count: channel.recipientIds.length + 1},
- {
- one: 'Group DM · # member',
- other: 'Group DM · # members',
- },
- )}
- </p>
- </>
- ) : isPersonalNotes ? (
- <>
- <h2
- className={styles.channelInfoTitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-title--2"
- >
- {i18n._(PERSONAL_NOTES_DESCRIPTOR)}
- </h2>
- <p
- className={styles.channelInfoSubtitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle--2"
- >
- <Trans>Your private space</Trans>
- </p>
- </>
- ) : (
- <>
- <h2
- className={styles.channelInfoTitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-title--3"
- >
- <span
- className={styles.channelNameWithIcon}
- data-flx="channel.channel-details-bottom-sheet.channel-name-with-icon"
- >
- {ChannelUtils.getIcon(channel, {className: styles.channelNameIcon})}
- {channel.name}
- </span>
- </h2>
- <p
- className={styles.channelInfoSubtitle}
- data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle--3"
- >
- {channelTypeLabel}
- </p>
- </>
+ </>
+ );
+ } else if (isGroupDM) {
+ title = (
+ <>
+ <h2 className={styles.channelInfoTitle} data-flx="channel.channel-details-bottom-sheet.channel-info-title">
+ {ChannelUtils.getDMDisplayName(channel)}
+ </h2>
+ <p className={styles.channelInfoSubtitle} data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle">
+ {plural(
+ {count: channel.recipientIds.length + 1},
+ {
+ one: 'Group DM · # member',
+ other: 'Group DM · # members',
+ },
)}
+ </p>
+ </>
+ );
+ } else if (isPersonalNotes) {
+ title = (
+ <>
+ <h2 className={styles.channelInfoTitle} data-flx="channel.channel-details-bottom-sheet.channel-info-title--2">
+ {i18n._(PERSONAL_NOTES_DESCRIPTOR)}
+ </h2>
+ <p
+ className={styles.channelInfoSubtitle}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle--2"
+ >
+ <Trans>Your private space</Trans>
+ </p>
+ </>
+ );
+ } else {
+ title = (
+ <>
+ <h2 className={styles.channelInfoTitle} data-flx="channel.channel-details-bottom-sheet.channel-info-title--3">
+ <span
+ className={styles.channelNameWithIcon}
+ data-flx="channel.channel-details-bottom-sheet.channel-name-with-icon"
+ >
+ {ChannelUtils.getIcon(channel, {className: styles.channelNameIcon})}
+ {channel.name}
+ </span>
+ </h2>
+ <p
+ className={styles.channelInfoSubtitle}
+ data-flx="channel.channel-details-bottom-sheet.channel-info-subtitle--3"
+ >
+ {channelTypeLabel}
+ </p>
+ </>
+ );
+ }
+
+ return (
+ <div className={sectionClassName} data-flx="channel.channel-details-bottom-sheet.channel-info-section">
+ {closeButton}
+ <div className={containerClassName} data-flx="channel.channel-details-bottom-sheet.channel-info-container">
+ {avatar}
+ <div className={contentClassName} data-flx="channel.channel-details-bottom-sheet.channel-info-content">
+ {title}
</div>
</div>
{channel.topic && !isDM && !isPersonalNotes && (
diff --git a/fluxer_app/src/features/channel/components/direct_message/DMListItem.tsx b/fluxer_app/src/features/channel/components/direct_message/DMListItem.tsx
index c4d6b8e5e..69944a00b 100644
--- a/fluxer_app/src/features/channel/components/direct_message/DMListItem.tsx
+++ b/fluxer_app/src/features/channel/components/direct_message/DMListItem.tsx
@@ -324,6 +324,12 @@ const ResolvedDMListItem = observer(function ResolvedDMListItem({
}
};
if (isMobile) {
+ let mobileItemClassName = styles.dmItemMobile;
+ if (isSelected) {
+ mobileItemClassName = styles.dmItemMobileSelected;
+ } else if (hasUnreadMessages()) {
+ mobileItemClassName = styles.dmItemMobileUnread;
+ }
return (
<>
<FocusRing offset={-2} data-flx="channel.direct-message.dm-list-item.focus-ring">
@@ -331,11 +337,7 @@ const ResolvedDMListItem = observer(function ResolvedDMListItem({
ref={setMobileRef}
onLongPress={() => setMenuOpen(true)}
className={clsx(
- isSelected
- ? styles.dmItemMobileSelected
- : hasUnreadMessages()
- ? styles.dmItemMobileUnread
- : styles.dmItemMobile,
+ mobileItemClassName,
isMuted && styles.dmItemMobileMuted,
contextMenuOpen && styles.contextMenuActive,
)}
@@ -472,147 +474,144 @@ const ResolvedDMListItem = observer(function ResolvedDMListItem({
</>
);
}
+ let itemClassName = styles.dmItem;
+ if (isSelected) {
+ itemClassName = styles.dmItemSelected;
+ } else if (hasUnreadMessages()) {
+ itemClassName = styles.dmItemUnread;
+ }
return (
- <>
- <FocusRing offset={-2} data-flx="channel.direct-message.dm-list-item.focus-ring--2">
- <div
- ref={setDesktopRef}
- className={clsx(
- isSelected ? styles.dmItemSelected : hasUnreadMessages() ? styles.dmItemUnread : styles.dmItem,
- isMuted && styles.dmItemMuted,
- contextMenuOpen && styles.contextMenuActive,
- )}
- onClick={handleNavigate}
- onContextMenu={handleContextMenu}
- onMouseEnter={scheduleChannelPreload}
- onMouseLeave={cancelChannelPreload}
- onFocus={() => setIsFocused(true)}
- onBlur={() => setIsFocused(false)}
- data-dm-list-focus-item="true"
- role="link"
- tabIndex={0}
- aria-label={dmAriaLabel}
- aria-current={isSelected ? 'page' : undefined}
- onKeyDown={(event) => {
- if (event.target !== event.currentTarget) return;
- if (!isKeyboardActivationKey(event.key)) return;
- event.preventDefault();
- handleNavigate();
- }}
- data-flx="channel.direct-message.dm-list-item.dm-item-selected.navigate-to"
- >
- <AnimatePresence data-flx="channel.direct-message.dm-list-item.animate-presence--2">
- {unreadState.shouldShowUnreadIndicator && (
- <div
- className={styles.dmItemUnreadIndicatorContainerDesktop}
- data-flx="channel.direct-message.dm-list-item.dm-item-unread-indicator-container-desktop"
- >
- <motion.span
- data-flx="channel.direct-message.dm-list-item.dm-item-unread-indicator--2"
- {...motionSettings}
- className={styles.dmItemUnreadIndicator}
- />
- </div>
- )}
- </AnimatePresence>
- <div className={styles.dmItemContent} data-flx="channel.direct-message.dm-list-item.dm-item-content--2">
+ <FocusRing offset={-2} data-flx="channel.direct-message.dm-list-item.focus-ring--2">
+ <div
+ ref={setDesktopRef}
+ className={clsx(itemClassName, isMuted && styles.dmItemMuted, contextMenuOpen && styles.contextMenuActive)}
+ onClick={handleNavigate}
+ onContextMenu={handleContextMenu}
+ onMouseEnter={scheduleChannelPreload}
+ onMouseLeave={cancelChannelPreload}
+ onFocus={() => setIsFocused(true)}
+ onBlur={() => setIsFocused(false)}
+ data-dm-list-focus-item="true"
+ role="link"
+ tabIndex={0}
+ aria-label={dmAriaLabel}
+ aria-current={isSelected ? 'page' : undefined}
+ onKeyDown={(event) => {
+ if (event.target !== event.currentTarget) return;
+ if (!isKeyboardActivationKey(event.key)) return;
+ event.preventDefault();
+ handleNavigate();
+ }}
+ data-flx="channel.direct-message.dm-list-item.dm-item-selected.navigate-to"
+ >
+ <AnimatePresence data-flx="channel.direct-message.dm-list-item.animate-presence--2">
+ {unreadState.shouldShowUnreadIndicator && (
<div
- className={styles.dmItemAvatarWrapper}
- data-flx="channel.direct-message.dm-list-item.dm-item-avatar-wrapper--2"
+ className={styles.dmItemUnreadIndicatorContainerDesktop}
+ data-flx="channel.direct-message.dm-list-item.dm-item-unread-indicator-container-desktop"
>
- {isGroupDM ? (
- <GroupDMAvatar
- channel={channel}
- size={32}
- isTyping={isTyping}
- data-flx="channel.direct-message.dm-list-item.group-dm-avatar--2"
- />
- ) : (
- <ListStatusAwareAvatar
- user={recipient!}
- size={32}
- isTyping={isTyping}
- showOffline={true}
- data-flx="channel.direct-message.dm-list-item.status-aware-avatar--2"
- />
- )}
+ <motion.span
+ data-flx="channel.direct-message.dm-list-item.dm-item-unread-indicator--2"
+ {...motionSettings}
+ className={styles.dmItemUnreadIndicator}
+ />
</div>
- <div className={styles.dmItemInfo} data-flx="channel.direct-message.dm-list-item.dm-item-info--2">
- <span className={styles.dmItemName} data-flx="channel.direct-message.dm-list-item.dm-item-name--2">
- {channel.isPinned && (
- <PushPinIcon
- weight="fill"
- className={styles.dmItemPinIcon}
- data-flx="channel.direct-message.dm-list-item.dm-item-pin-icon--2"
- />
- )}
- <DMListItemNameText
- displayName={displayName}
- dataFlx="channel.direct-message.dm-list-item.dm-item-name-text--2"
- data-flx="channel.direct-message.dm-list-item.resolved-dm-list-item.dm-list-item-name-text--2"
- />
- {!isGroupDM && isBotDM && (
- <UserTag
- className={styles.dmItemUserTag}
- system={recipient?.system}
- data-flx="channel.direct-message.dm-list-item.dm-item-user-tag--2"
- />
- )}
- </span>
- {!isGroupDM && recipient && !messagePreview && (
- <CustomStatusDisplay
- userId={recipient.id}
- className={styles.dmItemCustomStatus}
- showTooltip
- tooltipPosition="bottom"
- animateOnParentHover
- data-flx="channel.direct-message.dm-list-item.dm-item-custom-status--2"
+ )}
+ </AnimatePresence>
+ <div className={styles.dmItemContent} data-flx="channel.direct-message.dm-list-item.dm-item-content--2">
+ <div
+ className={styles.dmItemAvatarWrapper}
+ data-flx="channel.direct-message.dm-list-item.dm-item-avatar-wrapper--2"
+ >
+ {isGroupDM ? (
+ <GroupDMAvatar
+ channel={channel}
+ size={32}
+ isTyping={isTyping}
+ data-flx="channel.direct-message.dm-list-item.group-dm-avatar--2"
+ />
+ ) : (
+ <ListStatusAwareAvatar
+ user={recipient!}
+ size={32}
+ isTyping={isTyping}
+ showOffline={true}
+ data-flx="channel.direct-message.dm-list-item.status-aware-avatar--2"
+ />
+ )}
+ </div>
+ <div className={styles.dmItemInfo} data-flx="channel.direct-message.dm-list-item.dm-item-info--2">
+ <span className={styles.dmItemName} data-flx="channel.direct-message.dm-list-item.dm-item-name--2">
+ {channel.isPinned && (
+ <PushPinIcon
+ weight="fill"
+ className={styles.dmItemPinIcon}
+ data-flx="channel.direct-message.dm-list-item.dm-item-pin-icon--2"
/>
)}
- {isGroupDM && (
- <span
- className={clsx(styles.dmItemSubtext, styles.dmItemMembersSubtext)}
- data-flx="channel.direct-message.dm-list-item.dm-item--2"
- >
- {plural(
- {count: channel.recipientIds.length + 1},
- {
- one: '# member',
- other: '# members',
- },
- )}
- </span>
- )}
- {!isGroupDM && messagePreview && (
- <span
- className={styles.dmItemSubtext}
- data-flx="channel.direct-message.dm-list-item.dm-item-subtext--2"
- >
- {messagePreview}
- </span>
+ <DMListItemNameText
+ displayName={displayName}
+ dataFlx="channel.direct-message.dm-list-item.dm-item-name-text--2"
+ data-flx="channel.direct-message.dm-list-item.resolved-dm-list-item.dm-list-item-name-text--2"
+ />
+ {!isGroupDM && isBotDM && (
+ <UserTag
+ className={styles.dmItemUserTag}
+ system={recipient?.system}
+ data-flx="channel.direct-message.dm-list-item.dm-item-user-tag--2"
+ />
)}
- </div>
- <FocusRing offset={-2} data-flx="channel.direct-message.dm-list-item.focus-ring--3">
- <button
- type="button"
- tabIndex={-1}
- className={styles.dmItemCloseButton}
- style={{opacity: isFocused && keyboardModeEnabled ? 1 : undefined}}
- onClick={handlers.handleRemoveChannel}
- aria-label={i18n._(CLOSE_DIRECT_MESSAGE_WITH_DESCRIPTOR, {displayName})}
- data-flx="channel.direct-message.dm-list-item.dm-item-close-button.remove-channel"
+ </span>
+ {!isGroupDM && recipient && !messagePreview && (
+ <CustomStatusDisplay
+ userId={recipient.id}
+ className={styles.dmItemCustomStatus}
+ showTooltip
+ tooltipPosition="bottom"
+ animateOnParentHover
+ data-flx="channel.direct-message.dm-list-item.dm-item-custom-status--2"
+ />
+ )}
+ {isGroupDM && (
+ <span
+ className={clsx(styles.dmItemSubtext, styles.dmItemMembersSubtext)}
+ data-flx="channel.direct-message.dm-list-item.dm-item--2"
>
- <XIcon
- weight="bold"
- className={styles.iconSize4}
- data-flx="channel.direct-message.dm-list-item.icon-size4"
- />
- </button>
- </FocusRing>
+ {plural(
+ {count: channel.recipientIds.length + 1},
+ {
+ one: '# member',
+ other: '# members',
+ },
+ )}
+ </span>
+ )}
+ {!isGroupDM && messagePreview && (
+ <span className={styles.dmItemSubtext} data-flx="channel.direct-message.dm-list-item.dm-item-subtext--2">
+ {messagePreview}
+ </span>
+ )}
</div>
+ <FocusRing offset={-2} data-flx="channel.direct-message.dm-list-item.focus-ring--3">
+ <button
+ type="button"
+ tabIndex={-1}
+ className={styles.dmItemCloseButton}
+ style={{opacity: isFocused && keyboardModeEnabled ? 1 : undefined}}
+ onClick={handlers.handleRemoveChannel}
+ aria-label={i18n._(CLOSE_DIRECT_MESSAGE_WITH_DESCRIPTOR, {displayName})}
+ data-flx="channel.direct-message.dm-list-item.dm-item-close-button.remove-channel"
+ >
+ <XIcon
+ weight="bold"
+ className={styles.iconSize4}
+ data-flx="channel.direct-message.dm-list-item.icon-size4"
+ />
+ </button>
+ </FocusRing>
</div>
- </FocusRing>
- </>
+ </div>
+ </FocusRing>
);
});
export const DMListItem = observer((props: DMListItemProps) => {
diff --git a/fluxer_app/src/features/channel/components/textarea/MobileTextareaButtonStateMachine.ts b/fluxer_app/src/features/channel/components/textarea/MobileTextareaButtonStateMachine.ts
index 521ca8b24..ba54b86a7 100644
--- a/fluxer_app/src/features/channel/components/textarea/MobileTextareaButtonStateMachine.ts
+++ b/fluxer_app/src/features/channel/components/textarea/MobileTextareaButtonStateMachine.ts
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {hasVisibleContent as hasVisibleMessageContent} from '@fluxer/schema/src/primitives/MessageValidators';
-import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate';
+import {assign, initialTransition, setup, transition} from 'xstate';
type MobileTextareaVisibleButton = 'send' | 'voice';
type MobileTextareaButtonMode = 'voice' | 'sendReady' | 'sendBlocked';
-export interface MobileTextareaButtonSignals {
+interface MobileTextareaButtonSignals {
disabled: boolean;
canRecordVoice: boolean;
value: string;
@@ -18,7 +18,7 @@ export interface MobileTextareaButtonSignals {
hasPendingSticker: boolean;
}
-export interface MobileTextareaButtonModel {
+interface MobileTextareaButtonModel {
mode: MobileTextareaButtonMode;
visibleButton: MobileTextareaVisibleButton;
sendButton: {
@@ -40,12 +40,9 @@ interface MobileTextareaButtonContext {
model: MobileTextareaButtonModel;
}
-function hasTypedText(value: string): boolean {
- return hasVisibleMessageContent(value.trim());
-}
-
function selectMobileTextareaButtonModel(signals: MobileTextareaButtonSignals): MobileTextareaButtonModel {
- const typedText = hasTypedText(signals.value);
+ const value = signals.value;
+ const typedText = hasVisibleMessageContent(value.trim());
const hasTextContent = signals.hasContent || typedText;
const hasSubmissionContent = hasTextContent || signals.hasAttachments || signals.hasPendingSticker;
const shouldShowVoice = signals.canRecordVoice && !signals.isEditingMessage && !hasSubmissionContent;
@@ -56,7 +53,14 @@ function selectMobileTextareaButtonModel(signals: MobileTextareaButtonSignals):
(!hasSubmissionContent && !signals.isEditingMessage);
const voiceDisabled = signals.disabled || signals.isSlowmodeActive || signals.isOverCharacterLimit;
const visibleButton = shouldShowVoice ? 'voice' : 'send';
- const mode = visibleButton === 'voice' ? 'voice' : sendDisabled ? 'sendBlocked' : 'sendReady';
+ let mode: MobileTextareaButtonMode;
+ if (visibleButton === 'voice') {
+ mode = 'voice';
+ } else if (sendDisabled) {
+ mode = 'sendBlocked';
+ } else {
+ mode = 'sendReady';
+ }
return {
mode,
visibleButton,
@@ -137,23 +141,11 @@ const mobileTextareaButtonStateMachine = setup({
},
});
-type MobileTextareaButtonSnapshot = SnapshotFrom<typeof mobileTextareaButtonStateMachine>;
-
-function createMobileTextareaButtonSnapshot(): MobileTextareaButtonSnapshot {
- return initialTransition(mobileTextareaButtonStateMachine)[0];
-}
-
-function transitionMobileTextareaButtonSnapshot(
- snapshot: MobileTextareaButtonSnapshot,
- event: MobileTextareaButtonEvent,
-): MobileTextareaButtonSnapshot {
- return transition(mobileTextareaButtonStateMachine, snapshot, event)[0] as MobileTextareaButtonSnapshot;
-}
-
export function transitionMobileTextareaButtonState(signals: MobileTextareaButtonSignals): MobileTextareaButtonModel {
- const snapshot = transitionMobileTextareaButtonSnapshot(createMobileTextareaButtonSnapshot(), {
+ const initial = initialTransition(mobileTextareaButtonStateMachine)[0];
+ const snapshot = transition(mobileTextareaButtonStateMachine, initial, {
type: 'mobileTextareaButtons.evaluate',
signals,
- });
+ })[0];
return snapshot.context.model;
}
diff --git a/fluxer_app/src/features/channel/utils/CreateDMModalUtils.tsx b/fluxer_app/src/features/channel/utils/CreateDMModalUtils.tsx
index 68d41de99..05a5eb2e0 100644
--- a/fluxer_app/src/features/channel/utils/CreateDMModalUtils.tsx
+++ b/fluxer_app/src/features/channel/utils/CreateDMModalUtils.tsx
@@ -2,15 +2,11 @@
import i18n from '@app/app/I18n';
import {showDmActionErrorModal} from '@app/features/app/components/alerts/DmActionErrorModal';
-import {StatusSlate} from '@app/features/app/components/dialogs/shared/StatusSlate';
-import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';
-import {useVerifyEmailAction} from '@app/features/auth/hooks/useVerifyEmailAction';
import * as PrivateChannelCommands from '@app/features/channel/commands/PrivateChannelCommands';
import type {UnaddableRecipient} from '@app/features/channel/components/modals/UnaddableRecipientsConfirmModal';
import {UnaddableRecipientsConfirmModal} from '@app/features/channel/components/modals/UnaddableRecipientsConfirmModal';
import type {Channel} from '@app/features/channel/models/Channel';
import {getDuplicateGroupDMChannels, getMaxGroupDmOtherRecipients} from '@app/features/channel/utils/GroupDmUtils';
-import {CLAIM_ACCOUNT_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {focusChannelTextareaAfterNavigation} from '@app/features/messaging/utils/ChannelTextareaFocusUtils';
import * as NavigationCommands from '@app/features/navigation/commands/NavigationCommands';
import {HttpError} from '@app/features/platform/types/EndpointError';
@@ -19,13 +15,14 @@ import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
import type {User} from '@app/features/user/models/User';
import Users from '@app/features/user/state/Users';
+import {AccountGateSlate, accountGateReason} from '@app/features/user/utils/AccountGatePresentation';
+import {canPerform} from '@app/features/user/utils/AccountGates';
import {blockIfAccountLimited} from '@app/features/user/utils/AccountLimitUtils';
+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';
+import type {TierGateDenial} from '@fluxer/constants/src/AccountTierRules';
import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';
import {ME} from '@fluxer/constants/src/AppConstants';
-import type {I18n} from '@lingui/core';
import {msg} from '@lingui/core/macro';
-import {useLingui} from '@lingui/react/macro';
-import {EnvelopeSimpleIcon, WarningCircleIcon} from '@phosphor-icons/react';
import type React from 'react';
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
@@ -41,22 +38,6 @@ const CHOOSE_FRIENDS_TO_MESSAGE_DESCRIPTOR = msg({
message: 'Choose friends to message.',
comment: 'Subtitle in the create-DM modal. Keep it short and calm.',
});
-const CLAIM_YOUR_ACCOUNT_DESCRIPTOR = msg({
- message: 'Claim your account',
- comment: 'Title shown when an unclaimed account cannot start a DM or group DM.',
-});
-const CLAIM_ACCOUNT_TO_START_DMS_DESCRIPTOR = msg({
- message: 'Claim your account to start DMs.',
- comment: 'Blocked-state text shown when an unclaimed account cannot start a DM or group DM.',
-});
-const VERIFY_YOUR_EMAIL_DESCRIPTOR = msg({
- message: 'Verify your email',
- comment: 'Title shown when an unverified account cannot start a DM or group DM.',
-});
-const VERIFY_EMAIL_TO_START_DMS_DESCRIPTOR = msg({
- message: 'Verify your email to start DMs.',
- comment: 'Blocked-state text shown when an unverified account cannot start a DM or group DM.',
-});
export const DUPLICATE_GROUP_MODAL_KEY = 'create-dm-duplicate-group';
const UNADDABLE_RECIPIENTS_MODAL_KEY = 'create-dm-unaddable-recipients';
@@ -106,9 +87,9 @@ export interface CreateDMModalProps {
resetKey?: unknown;
}
-export type CreateDmRestriction = 'unclaimed' | 'unverified';
+type CreateDmRestriction = TierGateDenial;
-export interface CreateDMModalLogicState {
+interface CreateDMModalLogicState {
selectedUserIds: Array<string>;
isCreating: boolean;
searchQuery: string;
@@ -118,7 +99,7 @@ export interface CreateDMModalLogicState {
restriction: CreateDmRestriction | null;
}
-export interface CreateDMModalLogicActions {
+interface CreateDMModalLogicActions {
handleToggle: (userId: string) => void;
handleCreate: () => Promise<{
duplicates: Array<Channel>;
@@ -129,54 +110,21 @@ export interface CreateDMModalLogicActions {
}
export function getCreateDmRestriction(user: User | null | undefined): CreateDmRestriction | null {
- if (user && !user.isClaimed()) {
- return 'unclaimed';
- }
- if (user?.verified === false) {
- return 'unverified';
- }
- return null;
-}
-
-export function getCreateDMRestrictionMessage(i18nApi: I18n, restriction: CreateDmRestriction): string {
- if (restriction === 'unclaimed') {
- return i18nApi._(CLAIM_ACCOUNT_TO_START_DMS_DESCRIPTOR);
- }
- return i18nApi._(VERIFY_EMAIL_TO_START_DMS_DESCRIPTOR);
+ const gate = canPerform(user, TierGatedActions.DIRECT_MESSAGE_OPEN);
+ return gate.allowed ? null : gate;
}
export const CreateDMRestrictionSlate: React.FC<
{restriction: CreateDmRestriction; fullHeight?: boolean} & React.HTMLAttributes<HTMLDivElement>
-> = ({restriction, fullHeight = true, ...props}) => {
- const {i18n: lingui} = useLingui();
- const isUnclaimed = restriction === 'unclaimed';
- const verifyEmailAction = useVerifyEmailAction();
- return (
- <div data-flx="channel.create-dm-modal-utils.create-dm-restriction-slate.div" {...props}>
- <StatusSlate
- Icon={isUnclaimed ? WarningCircleIcon : EnvelopeSimpleIcon}
- title={lingui._(isUnclaimed ? CLAIM_YOUR_ACCOUNT_DESCRIPTOR : VERIFY_YOUR_EMAIL_DESCRIPTOR)}
- description={getCreateDMRestrictionMessage(lingui, restriction)}
- actions={[
- isUnclaimed
- ? {
- text: lingui._(CLAIM_ACCOUNT_DESCRIPTOR),
- onClick: () => openClaimAccountModal({force: true}),
- variant: 'primary',
- }
- : {
- text: verifyEmailAction.text,
- onClick: verifyEmailAction.onClick,
- submitting: verifyEmailAction.submitting,
- variant: 'primary',
- },
- ]}
- fullHeight={fullHeight}
- data-flx="channel.create-dm-modal-utils.create-dm-restriction-slate.status-slate"
- />
- </div>
- );
-};
+> = ({restriction, fullHeight = true, ...props}) => (
+ <div data-flx="channel.create-dm-modal-utils.create-dm-restriction-slate.div" {...props}>
+ <AccountGateSlate
+ gate={restriction}
+ fullHeight={fullHeight}
+ data-flx="channel.create-dm-modal-utils.create-dm-restriction-slate.account-gate-slate"
+ />
+ </div>
+);
export function useCreateDMModalLogic(
_props: CreateDMModalProps = {},
@@ -219,12 +167,14 @@ export function useCreateDMModalLogic(
if (userIds.length !== 1 && blockIfAccountLimited()) return;
setIsCreating(true);
try {
- const channel =
- userIds.length === 0
- ? await PrivateChannelCommands.createGroupDM([])
- : userIds.length === 1
- ? await PrivateChannelCommands.create(userIds[0])
- : await PrivateChannelCommands.createGroupDM(userIds);
+ let channel: Awaited<ReturnType<typeof PrivateChannelCommands.create>>;
+ if (userIds.length === 0) {
+ channel = await PrivateChannelCommands.createGroupDM([]);
+ } else if (userIds.length === 1) {
+ channel = await PrivateChannelCommands.create(userIds[0]);
+ } else {
+ channel = await PrivateChannelCommands.createGroupDM(userIds);
+ }
ModalCommands.popWithKey(UNADDABLE_RECIPIENTS_MODAL_KEY);
ModalCommands.popWithKey(DUPLICATE_GROUP_MODAL_KEY);
if (autoCloseOnCreate) {
diff --git a/fluxer_app/src/features/theme/styles/Message.module.css b/fluxer_app/src/features/theme/styles/Message.module.css
index 0ff717951..14463b235 100644
--- a/fluxer_app/src/features/theme/styles/Message.module.css
+++ b/fluxer_app/src/features/theme/styles/Message.module.css
@@ -22,7 +22,7 @@
}
.message {
- text-align: left;
+ text-align: start;
position: relative;
user-select: text;
-webkit-user-select: text;
@@ -50,10 +50,6 @@
--message-media-max-width: 100%;
}
-.messageHovered {
- --message-hovered: 1;
-}
-
.focusRingAnchor {
position: absolute;
inset-block: 0;
@@ -162,7 +158,7 @@
user-select: text;
-webkit-user-select: text;
word-break: break-word;
- text-align: left;
+ text-align: start;
-webkit-tap-highlight-color: transparent;
display: grid;
grid-template-columns: var(--message-compact-horizontal-padding) minmax(0, 1fr);
@@ -589,7 +585,7 @@
justify-content: flex-end;
width: var(--message-avatar-size);
height: var(--message-line-height);
- text-align: right;
+ text-align: end;
user-select: none;
-webkit-user-select: none;
white-space: nowrap;
@@ -610,7 +606,7 @@
width: max-content;
height: var(--message-timestamp-compact-height);
font-size: var(--message-timestamp-compact-font-size);
- text-align: left;
+ text-align: start;
display: inline-block;
vertical-align: middle;
line-height: var(--message-line-height);
@@ -634,7 +630,7 @@
vertical-align: middle;
line-height: var(--message-line-height);
cursor: default;
- text-align: left;
+ text-align: start;
flex-shrink: 0;
opacity: 0;
pointer-events: none;
@@ -772,14 +768,14 @@
box-sizing: border-box;
top: 50%;
bottom: calc(-1 * (var(--reply-spacing) + var(--reply-spine-terminal-gap)));
- right: calc(100% + var(--reply-spine-terminal-gap));
- left: calc(-1 * (0.5 * var(--avatar-size) + var(--gutter)));
+ inset-inline-end: calc(100% + var(--reply-spine-terminal-gap));
+ inset-inline-start: calc(-1 * (0.5 * var(--avatar-size) + var(--gutter)));
margin-block-start: calc(-0.5 * var(--spine-width));
margin-inline-start: 0;
border-color: var(--reply-spine-color);
border-width: var(--spine-width) 0 0 var(--spine-width);
border-style: solid;
- border-top-left-radius: var(--reply-spine-radius);
+ border-start-start-radius: var(--reply-spine-radius);
}
.repliedMessageCompact {
@@ -816,7 +812,7 @@
border-color: var(--reply-spine-color);
border-width: var(--spine-width) 0 0 var(--spine-width);
border-style: solid;
- border-top-left-radius: var(--reply-spine-radius);
+ border-start-start-radius: var(--reply-spine-radius);
}
.repliedTextPreview {
@@ -1085,7 +1081,7 @@
display: inline-block;
width: max-content;
vertical-align: baseline;
- text-align: left;
+ text-align: start;
}
.systemMessageContent .container {