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 channel embed and permission ternaries

Hampusa7f65ac7de16
diff --git a/fluxer_app/src/features/channel/components/CallMessage.tsx b/fluxer_app/src/features/channel/components/CallMessage.tsx
index 416af0eb5..8dbcf58ee 100644
--- a/fluxer_app/src/features/channel/components/CallMessage.tsx
+++ b/fluxer_app/src/features/channel/components/CallMessage.tsx
@@ -235,10 +235,13 @@ export const CallMessage = observer(({message}: {message: Message}) => {
</Trans>
);
}
- const iconClassname = clsx(
- styles.icon,
- callEnded ? (isMissedCall ? styles.iconMissed : styles.iconEnded) : styles.iconActive,
- );
+ let iconStateClassname = styles.iconActive;
+ if (callEnded && isMissedCall) {
+ iconStateClassname = styles.iconMissed;
+ } else if (callEnded) {
+ iconStateClassname = styles.iconEnded;
+ }
+ const iconClassname = clsx(styles.icon, iconStateClassname);
return (
<SystemMessage
icon={PhoneIcon}
diff --git a/fluxer_app/src/features/channel/components/ChannelAttachmentArea.tsx b/fluxer_app/src/features/channel/components/ChannelAttachmentArea.tsx
index b968a2f4f..7d031ad1b 100644
--- a/fluxer_app/src/features/channel/components/ChannelAttachmentArea.tsx
+++ b/fluxer_app/src/features/channel/components/ChannelAttachmentArea.tsx
@@ -377,6 +377,24 @@ const SortableAttachmentItem = observer(
const isMedia = hasRenderableLocalPreview(attachment);
const isHiddenSpoiler = isSpoiler && spoilerHidden;
const IconComponent = getFileIcon(attachment.file);
+ let thumbnail: React.ReactNode = null;
+ if (isEmbeddableImageFile(attachment.file)) {
+ thumbnail = (
+ <ImageThumbnail
+ attachment={attachment}
+ spoiler={isHiddenSpoiler}
+ data-flx="channel.channel-attachment-area.sortable-attachment-item.image-thumbnail"
+ />
+ );
+ } else if (attachment.file.type.startsWith('video/')) {
+ thumbnail = (
+ <VideoThumbnail
+ attachment={attachment}
+ spoiler={isHiddenSpoiler}
+ data-flx="channel.channel-attachment-area.sortable-attachment-item.video-thumbnail"
+ />
+ );
+ }
return (
<li
ref={setRefs}
@@ -434,19 +452,7 @@ const SortableAttachmentItem = observer(
className={styles.spoilerWrapper}
data-flx="channel.channel-attachment-area.sortable-attachment-item.spoiler-wrapper"
>
- {isEmbeddableImageFile(attachment.file) ? (
- <ImageThumbnail
- attachment={attachment}
- spoiler={isHiddenSpoiler}
- data-flx="channel.channel-attachment-area.sortable-attachment-item.image-thumbnail"
- />
- ) : attachment.file.type.startsWith('video/') ? (
- <VideoThumbnail
- attachment={attachment}
- spoiler={isHiddenSpoiler}
- data-flx="channel.channel-attachment-area.sortable-attachment-item.video-thumbnail"
- />
- ) : null}
+ {thumbnail}
<div
className={styles.tags}
data-flx="channel.channel-attachment-area.sortable-attachment-item.tags"
diff --git a/fluxer_app/src/features/channel/components/ChannelMessages.tsx b/fluxer_app/src/features/channel/components/ChannelMessages.tsx
index c122ffe0d..1c92ab32b 100644
--- a/fluxer_app/src/features/channel/components/ChannelMessages.tsx
+++ b/fluxer_app/src/features/channel/components/ChannelMessages.tsx
@@ -609,21 +609,25 @@ const CachedMessages = observer(function CachedMessages({channel, allowAutoAck =
onMessageEdit,
onReveal,
]);
- const bottomBar =
- windowBar === 'retry' ? (
+ let bottomBar: React.ReactNode = null;
+ if (windowBar === 'retry') {
+ bottomBar = (
<LoadErrorBar
loading={safeMessages.loadingMore}
onRetry={onRetryLoadMessages}
data-flx="channel.messages.load-error-bar"
/>
- ) : windowBar === 'present' ? (
+ );
+ } else if (windowBar === 'present') {
+ bottomBar = (
<JumpToPresentBar
loadingMore={safeMessages.loadingMore}
landedAtLiveEdge={safeMessages.landedAtLiveEdge}
onJumpToPresent={onScrollToPresent}
data-flx="channel.messages.jump-to-present-bar"
/>
- ) : null;
+ );
+ }
const showNewMessagesBar = Boolean(windowStatus.phase === 'stream' && state.unreadCount > 0);
const unreadTimestampMessageId = state.oldestUnreadMessageId ?? state.ackMessageId;
const topBar = showNewMessagesBar ? (
diff --git a/fluxer_app/src/features/channel/components/LexicalChannelTextareaContent.tsx b/fluxer_app/src/features/channel/components/LexicalChannelTextareaContent.tsx
index f926eada7..2587729ef 100644
--- a/fluxer_app/src/features/channel/components/LexicalChannelTextareaContent.tsx
+++ b/fluxer_app/src/features/channel/components/LexicalChannelTextareaContent.tsx
@@ -985,15 +985,18 @@ export const LexicalChannelTextareaContent = observer(
isFocused,
handleArrowUpEmpty,
});
- const placeholderText = placeholder
- ? placeholder
- : disabled
- ? i18n._(YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_MESSAGES_DESCRIPTOR)
- : channel.guildId != null
- ? i18n._(MESSAGE_CHANNEL_DESCRIPTOR, {channelName: channel.name || i18n._(CHANNEL_DESCRIPTOR)})
- : channel.isDM()
- ? i18n._(MESSAGE_USER_DESCRIPTOR, {userName: ChannelDisplayUtils.getDMDisplayName(channel)})
- : i18n._(MESSAGE_GROUP_DESCRIPTOR, {groupName: ChannelDisplayUtils.getDMDisplayName(channel)});
+ let placeholderText: string;
+ if (placeholder) {
+ placeholderText = placeholder;
+ } else if (disabled) {
+ placeholderText = i18n._(YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_MESSAGES_DESCRIPTOR);
+ } else if (channel.guildId != null) {
+ placeholderText = i18n._(MESSAGE_CHANNEL_DESCRIPTOR, {channelName: channel.name || i18n._(CHANNEL_DESCRIPTOR)});
+ } else if (channel.isDM()) {
+ placeholderText = i18n._(MESSAGE_USER_DESCRIPTOR, {userName: ChannelDisplayUtils.getDMDisplayName(channel)});
+ } else {
+ placeholderText = i18n._(MESSAGE_GROUP_DESCRIPTOR, {groupName: ChannelDisplayUtils.getDMDisplayName(channel)});
+ }
useEffect(() => ActiveComposer.register(draftChannelId ?? channel.id), [channel.id, draftChannelId]);
useEffect(() => {
const unsubscribe = ComponentBus.subscribe('FOCUS_TEXTAREA', (payload?: unknown) => {
diff --git a/fluxer_app/src/features/channel/components/SlashCommandParamBar.tsx b/fluxer_app/src/features/channel/components/SlashCommandParamBar.tsx
index 4b9ceba4b..846ba1c71 100644
--- a/fluxer_app/src/features/channel/components/SlashCommandParamBar.tsx
+++ b/fluxer_app/src/features/channel/components/SlashCommandParamBar.tsx
@@ -48,15 +48,16 @@ export const SlashCommandParamBar = ({activeSlot, onClear}: SlashCommandParamBar
<span className={styles.name} data-flx="channel.slash-command-param-bar.name">
{activeSlot.optionName}
</span>
- {showRequiredError ? (
+ {showRequiredError && (
<span className={styles.requiredError} data-flx="channel.slash-command-param-bar.required-error">
{i18n._(OPTION_IS_REQUIRED_DESCRIPTOR)}
</span>
- ) : showDescription ? (
+ )}
+ {showDescription && (
<span className={styles.description} data-flx="channel.slash-command-param-bar.description">
{activeSlot.description}
</span>
- ) : null}
+ )}
</flx-channel-slash-command-param-bar-text>
<flx-channel-slash-command-param-bar-controls
className={flxElementClassName(styles.controls)}
diff --git a/fluxer_app/src/features/channel/components/active_now/useActiveFriendVoiceStates.ts b/fluxer_app/src/features/channel/components/active_now/useActiveFriendVoiceStates.ts
index ab83f0711..ccdb02ffe 100644
--- a/fluxer_app/src/features/channel/components/active_now/useActiveFriendVoiceStates.ts
+++ b/fluxer_app/src/features/channel/components/active_now/useActiveFriendVoiceStates.ts
@@ -79,11 +79,12 @@ export function useActiveFriendVoiceStates(): ReadonlyArray<UserVoiceActivity> {
const channel = Channels.getChannel(channelId);
const guild = effectiveGuildId ? Guilds.getGuild(effectiveGuildId) : undefined;
const isStreaming = voiceState.self_stream === true;
- const streamKey = isStreaming
- ? effectiveGuildId
- ? `${effectiveGuildId}:${channelId}:${connectionId}`
- : `dm:${channelId}:${connectionId}`
- : null;
+ let streamKey: string | null = null;
+ if (isStreaming && effectiveGuildId) {
+ streamKey = `${effectiveGuildId}:${channelId}:${connectionId}`;
+ } else if (isStreaming) {
+ streamKey = `dm:${channelId}:${connectionId}`;
+ }
const {participantUserIds, participantUsers} = collectParticipantUsers(channelStates);
activities.push({
voiceState,
diff --git a/fluxer_app/src/features/channel/components/channel_header_components/ChannelNotificationSettingsDropdown.tsx b/fluxer_app/src/features/channel/components/channel_header_components/ChannelNotificationSettingsDropdown.tsx
index 94c6ace03..97f161edf 100644
--- a/fluxer_app/src/features/channel/components/channel_header_components/ChannelNotificationSettingsDropdown.tsx
+++ b/fluxer_app/src/features/channel/components/channel_header_components/ChannelNotificationSettingsDropdown.tsx
@@ -59,11 +59,7 @@ export const ChannelNotificationSettingsDropdown: React.FC<Props> = observer(({c
channelNotifications ?? (isGuildChannel ? MessageNotifications.INHERIT : MessageNotifications.ALL_MESSAGES);
const channelUnreadBadges = channelOverride?.unread_badges;
const currentUnreadBadgesLevel =
- channelUnreadBadges == null
- ? isGuildChannel
- ? MessageNotifications.INHERIT
- : MessageNotifications.ALL_MESSAGES
- : channelUnreadBadges;
+ channelUnreadBadges ?? (isGuildChannel ? MessageNotifications.INHERIT : MessageNotifications.ALL_MESSAGES);
const showUnreadBadgeCustomization = AdvancedSettings.unreadBadgeCustomizationEnabled;
const categoryId = channel.parentId;
const effectiveDefaultLevel = guildId
diff --git a/fluxer_app/src/features/channel/components/embeds/attachments/AttachmentGridItem.tsx b/fluxer_app/src/features/channel/components/embeds/attachments/AttachmentGridItem.tsx
index d32b0a97e..324a8fee3 100644
--- a/fluxer_app/src/features/channel/components/embeds/attachments/AttachmentGridItem.tsx
+++ b/fluxer_app/src/features/channel/components/embeds/attachments/AttachmentGridItem.tsx
@@ -151,21 +151,23 @@ export const AttachmentGridItem: FC<AttachmentGridItemProps> = observer(
const proxyUrl = attachment.proxy_url ?? attachment.url ?? '';
const isBlob = proxyUrl.startsWith('blob:');
const isPlainGif = attachmentMediaType === 'gif';
- const thumbnailSrc =
- proxyUrl.length === 0
- ? ''
- : isBlob
- ? proxyUrl
- : isPlainGif
- ? shouldAnimateGif
- ? buildAnimatedImageProxyURL(proxyUrl, targetWidth, targetHeight)
- : buildStaticGifPreviewURL(proxyUrl, targetWidth, targetHeight)
- : buildMediaProxyURL(proxyUrl, {
- format: resolvePreferredImageFormat(attachment.content_type),
- width: targetWidth,
- height: targetHeight,
- animated: isAnimatedGif && shouldAnimateGif,
- });
+ let thumbnailSrc: string;
+ if (proxyUrl.length === 0) {
+ thumbnailSrc = '';
+ } else if (isBlob) {
+ thumbnailSrc = proxyUrl;
+ } else if (isPlainGif && shouldAnimateGif) {
+ thumbnailSrc = buildAnimatedImageProxyURL(proxyUrl, targetWidth, targetHeight);
+ } else if (isPlainGif) {
+ thumbnailSrc = buildStaticGifPreviewURL(proxyUrl, targetWidth, targetHeight);
+ } else {
+ thumbnailSrc = buildMediaProxyURL(proxyUrl, {
+ format: resolvePreferredImageFormat(attachment.content_type),
+ width: targetWidth,
+ height: targetHeight,
+ animated: isAnimatedGif && shouldAnimateGif,
+ });
+ }
const {ref: visibilityRef, isNearViewport} = useNearViewport<HTMLDivElement>({rememberKey: thumbnailSrc});
const shouldLoadMedia = isNearViewport && !shouldBlur && !spoilerHidden;
const {
diff --git a/fluxer_app/src/features/channel/components/embeds/channel_embed/BlueskyEmbed.tsx b/fluxer_app/src/features/channel/components/embeds/channel_embed/BlueskyEmbed.tsx
index 47538d2c5..1ac35c88e 100644
--- a/fluxer_app/src/features/channel/components/embeds/channel_embed/BlueskyEmbed.tsx
+++ b/fluxer_app/src/features/channel/components/embeds/channel_embed/BlueskyEmbed.tsx
@@ -128,7 +128,14 @@ export const BlueskyEmbed: FC<BlueskyEmbedProps> = observer(
const shouldRenderMedia = hasAnyMedia || showGallery;
const blueskyMediaMaxWidth = useMemo(() => {
if (showGallery || isNested) return undefined;
- const primaryMedia = hasVideo ? embed.video : hasImage ? embed.image : hasThumbnail ? embed.thumbnail : undefined;
+ let primaryMedia: EmbedMedia | undefined;
+ if (hasVideo) {
+ primaryMedia = embed.video;
+ } else if (hasImage) {
+ primaryMedia = embed.image;
+ } else if (hasThumbnail) {
+ primaryMedia = embed.thumbnail;
+ }
if (!primaryMedia || !isValidMedia(primaryMedia)) return undefined;
return calculateMediaDimensions(primaryMedia).width;
}, [embed.video, embed.image, embed.thumbnail, hasVideo, hasImage, hasThumbnail, isNested, showGallery]);
diff --git a/fluxer_app/src/features/channel/components/embeds/channel_embed/ChannelEmbedShared.ts b/fluxer_app/src/features/channel/components/embeds/channel_embed/ChannelEmbedShared.ts
index 45715c7bb..249d6cf58 100644
--- a/fluxer_app/src/features/channel/components/embeds/channel_embed/ChannelEmbedShared.ts
+++ b/fluxer_app/src/features/channel/components/embeds/channel_embed/ChannelEmbedShared.ts
@@ -287,12 +287,11 @@ const getEmbedListRenderMetadata = (embedList: ReadonlyArray<MessageEmbed>): Emb
const firstIndex = firstIndexByNormalizedUrl.get(normalizedUrl);
if (firstIndex === undefined) continue;
const candidate = embedList[index];
- const candidateMedia = isValidMedia(candidate?.image)
- ? candidate.image
- : isValidMedia(candidate?.thumbnail)
- ? candidate.thumbnail
- : undefined;
- tryAddGalleryMedia(firstIndex, candidateMedia);
+ if (isValidMedia(candidate?.image)) {
+ tryAddGalleryMedia(firstIndex, candidate.image);
+ } else if (isValidMedia(candidate?.thumbnail)) {
+ tryAddGalleryMedia(firstIndex, candidate.thumbnail);
+ }
}
const metadata = {normalizedUrls, firstIndexByNormalizedUrl, galleryImagesByFirstIndex};
embedListRenderMetadataCache.set(embedList, metadata);
diff --git a/fluxer_app/src/features/channel/components/embeds/channel_embed/EmbedParts.tsx b/fluxer_app/src/features/channel/components/embeds/channel_embed/EmbedParts.tsx
index 3c8e4a7e1..e4e1cc18f 100644
--- a/fluxer_app/src/features/channel/components/embeds/channel_embed/EmbedParts.tsx
+++ b/fluxer_app/src/features/channel/components/embeds/channel_embed/EmbedParts.tsx
@@ -158,7 +158,7 @@ export const EmbedFields: FC<{fields?: ReadonlyArray<EmbedField>; messageId?: st
{groupedFields.map((group, groupIndex) => {
const groupLength = group.length;
return group.map(({name, value}, index) => {
- const span = groupLength === 1 ? 12 : groupLength === 2 ? 6 : 4;
+ const span = 12 / groupLength;
const gridColumnStart = index * span + 1;
const gridColumnEnd = gridColumnStart + span;
return (
diff --git a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_overview_tab/MatureContentSection.tsx b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_overview_tab/MatureContentSection.tsx
index 441f222c6..0b87c1daa 100644
--- a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_overview_tab/MatureContentSection.tsx
+++ b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_overview_tab/MatureContentSection.tsx
@@ -77,7 +77,12 @@ export const MatureContentSection: React.FC<MatureContentSectionProps> = ({form,
label: i18n._(OFF_2_DESCRIPTOR),
},
];
- const overrideToKey = (v: boolean | null): string => (v === null ? 'inherit' : v ? 'on' : 'off');
+ const overrideToKey = (v: boolean | null): string => {
+ if (v === null) {
+ return 'inherit';
+ }
+ return v ? 'on' : 'off';
+ };
const keyToOverride = (k: string): boolean | null => (k === 'inherit' ? null : k === 'on');
const inheritedWarningText = inheritedWarning.text ?? i18n._(THIS_CONTAINS_SENSITIVE_CONTENT_DESCRIPTOR);
return (
diff --git a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/MobileOverrideRow.tsx b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/MobileOverrideRow.tsx
index 212eb8129..7c301ab21 100644
--- a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/MobileOverrideRow.tsx
+++ b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/MobileOverrideRow.tsx
@@ -6,8 +6,9 @@ import type {PermissionOverwrite} from '@app/features/channel/components/modals/
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
import {openRoleContextMenu} from '@app/features/ui/action_menu/RoleContextMenu';
import {Avatar} from '@app/features/ui/components/Avatar';
+import {CaretRightIcon} from '@app/features/ui/icons/DirectionalIcons';
import type {User} from '@app/features/user/models/User';
-import {CaretRightIcon, UsersIcon} from '@phosphor-icons/react';
+import {UsersIcon} from '@phosphor-icons/react';
import type React from 'react';
interface MobileOverrideRowProps {
@@ -31,6 +32,35 @@ export const MobileOverrideRow: React.FC<MobileOverrideRowProps> = ({
guildId,
onClick,
}) => {
+ let icon: React.ReactNode;
+ if (overwrite.type === 0 && !isEveryone) {
+ icon = (
+ <div
+ className={styles.roleDot}
+ style={{
+ backgroundColor: color === 0 ? DEFAULT_ROLE_COLOR_HEX : getRoleColor(color || 0),
+ }}
+ data-flx="channel.channel-tabs.channel-permissions-tab.role-dot"
+ />
+ );
+ } else if (overwrite.type === 1 && user) {
+ icon = (
+ <Avatar
+ user={user}
+ size={12}
+ className={styles.overwriteIcon}
+ guildId={guildId}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-icon"
+ />
+ );
+ } else {
+ icon = (
+ <UsersIcon
+ className={styles.overwriteIcon}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-icon--2"
+ />
+ );
+ }
return (
<button
type="button"
@@ -39,28 +69,7 @@ export const MobileOverrideRow: React.FC<MobileOverrideRowProps> = ({
onContextMenu={roleId ? (event) => openRoleContextMenu(event, roleId) : undefined}
data-flx="channel.channel-tabs.channel-permissions-tab.mobile-override-item.mobile-overwrite-select.button"
>
- {overwrite.type === 0 && !isEveryone ? (
- <div
- className={styles.roleDot}
- style={{
- backgroundColor: color === 0 ? DEFAULT_ROLE_COLOR_HEX : getRoleColor(color || 0),
- }}
- data-flx="channel.channel-tabs.channel-permissions-tab.role-dot"
- />
- ) : overwrite.type === 1 && user ? (
- <Avatar
- user={user}
- size={12}
- className={styles.overwriteIcon}
- guildId={guildId}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-icon"
- />
- ) : (
- <UsersIcon
- className={styles.overwriteIcon}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-icon--2"
- />
- )}
+ {icon}
<span
className={styles.mobileOverrideName}
data-flx="channel.channel-tabs.channel-permissions-tab.mobile-override-name"
diff --git a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteContextMenu.tsx b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteContextMenu.tsx
index 8cd4c69ef..6f5c649ca 100644
--- a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteContextMenu.tsx
+++ b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteContextMenu.tsx
@@ -34,22 +34,28 @@ interface OverwriteContextMenuProps {
export const OverwriteContextMenu: React.FC<OverwriteContextMenuProps> = observer(
({overwrite, roleId, user, canDelete, onDelete, onClose}) => {
const {i18n} = useLingui();
+ let copyIdMenuItem: React.ReactNode = null;
+ if (overwrite.type === 0 && roleId) {
+ copyIdMenuItem = (
+ <CopyRoleIdMenuItem
+ roleId={roleId}
+ onClose={onClose}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.copy-role-id-menu-item"
+ />
+ );
+ } else if (user) {
+ copyIdMenuItem = (
+ <CopyUserIdMenuItem
+ user={user}
+ onClose={onClose}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.copy-user-id-menu-item"
+ />
+ );
+ }
return (
<>
<MenuGroup data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.menu-group">
- {overwrite.type === 0 && roleId ? (
- <CopyRoleIdMenuItem
- roleId={roleId}
- onClose={onClose}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.copy-role-id-menu-item"
- />
- ) : user ? (
- <CopyUserIdMenuItem
- user={user}
- onClose={onClose}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.copy-user-id-menu-item"
- />
- ) : null}
+ {copyIdMenuItem}
</MenuGroup>
{canDelete && (
<MenuGroup data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-context-menu.menu-group--2">
diff --git a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteItem.tsx b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteItem.tsx
index 116195a6b..befce4926 100644
--- a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteItem.tsx
+++ b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/OverwriteItem.tsx
@@ -48,6 +48,33 @@ export const OverwriteItem: React.FC<OverwriteItemProps> = observer(
},
[overwrite, roleId, user, canDelete, onDelete],
);
+ let overwriteIcon: React.ReactNode;
+ if (overwrite.type === 0 && !isEveryone) {
+ overwriteIcon = (
+ <div
+ className={styles.roleDot}
+ style={{backgroundColor: color === 0 ? DEFAULT_ROLE_COLOR_HEX : getRoleColor(color || 0)}}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.role-dot"
+ />
+ );
+ } else if (overwrite.type === 1 && user) {
+ overwriteIcon = (
+ <Avatar
+ user={user}
+ size={12}
+ className={styles.overwriteIcon}
+ guildId={guildId}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-icon"
+ />
+ );
+ } else {
+ overwriteIcon = (
+ <UsersIcon
+ className={styles.overwriteIcon}
+ data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-icon--2"
+ />
+ );
+ }
return (
<button
ref={buttonRef}
@@ -61,26 +88,7 @@ export const OverwriteItem: React.FC<OverwriteItemProps> = observer(
onContextMenu={handleContextMenu}
data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-item.click.button"
>
- {overwrite.type === 0 && !isEveryone ? (
- <div
- className={styles.roleDot}
- style={{backgroundColor: color === 0 ? DEFAULT_ROLE_COLOR_HEX : getRoleColor(color || 0)}}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.role-dot"
- />
- ) : overwrite.type === 1 && user ? (
- <Avatar
- user={user}
- size={12}
- className={styles.overwriteIcon}
- guildId={guildId}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-icon"
- />
- ) : (
- <UsersIcon
- className={styles.overwriteIcon}
- data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-icon--2"
- />
- )}
+ {overwriteIcon}
<span
className={styles.overwriteName}
data-flx="channel.channel-tabs.channel-permissions-tab.overwrite-item.overwrite-name"
diff --git a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/PermissionEditorPanel.tsx b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/PermissionEditorPanel.tsx
index 6ef4fcffb..c1e88a0b9 100644
--- a/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/PermissionEditorPanel.tsx
+++ b/fluxer_app/src/features/channel/components/modals/channel_tabs/channel_permissions_tab/PermissionEditorPanel.tsx
@@ -61,6 +61,14 @@ export const PermissionEditorPanel: React.FC<PermissionEditorPanelProps> = ({
getPermissionWarning,
}) => {
const {i18n} = useLingui();
+ let subtleText: React.ReactNode;
+ if (isEveryoneSelected) {
+ subtleText = <Trans>Configure base access for this channel</Trans>;
+ } else if (selectedOverwrite?.type === 0) {
+ subtleText = <Trans>Configure overrides for this role</Trans>;
+ } else {
+ subtleText = <Trans>Configure overrides for this member</Trans>;
+ }
return (
<>
{isMobile && (
@@ -81,13 +89,7 @@ export const PermissionEditorPanel: React.FC<PermissionEditorPanelProps> = ({
<Trans>Edit access for {getOverwriteName(selectedOverwrite)}</Trans>
</h2>
<p className={styles.subtleText} data-flx="channel.channel-tabs.channel-permissions-tab.subtle-text">
- {isEveryoneSelected ? (
- <Trans>Configure base access for this channel</Trans>
- ) : selectedOverwrite?.type === 0 ? (
- <Trans>Configure overrides for this role</Trans>
- ) : (
- <Trans>Configure overrides for this member</Trans>
- )}
+ {subtleText}
</p>
</div>
{!isEveryoneSelected && (
diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGrid.tsx b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGrid.tsx
index 4b33bf8f1..7c092656f 100644
--- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGrid.tsx
+++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGrid.tsx
@@ -58,8 +58,14 @@ export const GifPickerGrid = observer(
const useSavedMediaForGifFavorites = FavoriteGif.saveGifFavoritesAsSavedMedia;
const attachmentUrlRevision = AttachmentUrlRefresher.revision;
const data: Array<GifPickerGridItemData> = useMemo(() => {
+ let surface: 'favorites' | 'featured' | 'results' = 'results';
+ if (store.isShowingFavorites) {
+ surface = 'favorites';
+ } else if (store.isShowingFeatured) {
+ surface = 'featured';
+ }
return buildGifPickerGridData({
- surface: store.isShowingFavorites ? 'favorites' : store.isShowingFeatured ? 'featured' : 'results',
+ surface,
loading: store.loading,
columns,
provider: RuntimeConfig.gifProvider,
diff --git a/fluxer_app/src/features/channel/components/textarea/TextareaPlusMenu.tsx b/fluxer_app/src/features/channel/components/textarea/TextareaPlusMenu.tsx
index 7591f8936..c4b35190e 100644
--- a/fluxer_app/src/features/channel/components/textarea/TextareaPlusMenu.tsx
+++ b/fluxer_app/src/features/channel/components/textarea/TextareaPlusMenu.tsx
@@ -100,11 +100,6 @@ export const TextareaPlusMenu = observer(
uploadActionHint = cannotUploadFilesHint;
}
const sendGiftHint = !canSendMessages ? cannotSendMessagesHint : undefined;
- const sendVoiceMessageDisabledHint = !canSendMessages
- ? cannotSendMessagesHint
- : !canAttachFiles
- ? cannotUploadFilesHint
- : undefined;
const sendVoiceMessageKeybind = Keybind.getByAction('chat_send_voice_message').combo;
const sendVoiceMessageKeybindHint =
sendVoiceMessageKeybind.key || sendVoiceMessageKeybind.code ? (
@@ -160,7 +155,7 @@ export const TextareaPlusMenu = observer(
icon={<MicrophoneIcon weight="bold" data-flx="channel.textarea.textarea-plus-menu.microphone-icon" />}
onClick={onSendVoiceMessage}
disabled={!canSendMessages || !canAttachFiles}
- hint={sendVoiceMessageDisabledHint ?? sendVoiceMessageKeybindHint}
+ hint={uploadActionHint ?? sendVoiceMessageKeybindHint}
data-flx="channel.textarea.textarea-plus-menu.menu-item.send-voice-message"
>
{i18n._(SEND_VOICE_MESSAGE_DESCRIPTOR)}