A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): follow the newest forward target for mention autocomplete (#2001)
Hampus1153327c7566
diff --git a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSelection.ts b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSelection.tsindex 3ff7cb81f..8be59a9e4 100644--- a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSelection.ts+++ b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSelection.ts@@ -27,6 +27,7 @@ export interface ForwardChannelSelectionState {readonly handleToggleChannel: (channelId: string) => void;readonly isChannelSelectionDisabled: (option: ForwardChannelOption) => boolean;readonly maxSelections: number;+ readonly mostRecentlySelectedChannelId: string | null;readonly searchQuery: string;readonly selectedChannelIds: ReadonlySet<string>;readonly setSearchQuery: Dispatch<SetStateAction<string>>;@@ -104,12 +105,20 @@ export function useForwardChannelSelection({() => selectedChannelOptions.filter((option) => option.slowmodeRemainingMs > 0),[selectedChannelOptions],);+ const mostRecentlySelectedChannelId = useMemo(() => {+ let mostRecent: string | null = null;+ for (const channelId of selectedChannelIds) {+ mostRecent = channelId;+ }+ return mostRecent;+ }, [selectedChannelIds]);return {filteredChannels,handleToggleChannel,isChannelSelectionDisabled,maxSelections,+ mostRecentlySelectedChannelId,searchQuery,selectedChannelIds,setSearchQuery,diff --git a/fluxer_app/src/features/messaging/components/modals/ForwardModal.tsx b/fluxer_app/src/features/messaging/components/modals/ForwardModal.tsxindex 9cdd28a5c..a390d2a17 100644--- a/fluxer_app/src/features/messaging/components/modals/ForwardModal.tsx+++ b/fluxer_app/src/features/messaging/components/modals/ForwardModal.tsx@@ -184,6 +184,7 @@ export const ForwardModal = observer(filteredChannels,handleToggleChannel,isChannelSelectionDisabled,+ mostRecentlySelectedChannelId,searchQuery,selectedChannelIds,setSearchQuery,@@ -195,7 +196,6 @@ export const ForwardModal = observer(message,mediaSelection: mediaSelectionCapability,});- const [optionalMessage, setOptionalMessage] = useState('');const [actualOptionalMessage, setActualOptionalMessage] = useState('');const [isForwarding, setIsForwarding] = useState(false);const [expressionPickerOpen, setExpressionPickerOpen] = useState(false);@@ -216,9 +216,15 @@ export const ForwardModal = observer(dataFlx: 'messaging.forward-modal.optional-message-too-long.generic-error-modal',});}, [i18n]);- const channel = resolveForwardSourceChannel(sourceChannel, message.channelId);- const handleCommentChange = useCallback((display: string, _segments: Array<MentionSegment>, wire: string) => {- setOptionalMessage(display);+ const sourceForwardChannel = resolveForwardSourceChannel(sourceChannel, message.channelId);+ const composerChannel = useMemo(() => {+ if (mostRecentlySelectedChannelId == null) {+ return null;+ }+ const selectedChannel = Channels.getChannel(mostRecentlySelectedChannelId);+ return selectedChannel == null ? null : selectedChannel;+ }, [mostRecentlySelectedChannelId]);+ const handleCommentChange = useCallback((_display: string, _segments: Array<MentionSegment>, wire: string) => {setActualOptionalMessage(wire);}, []);const isCommentOverLimit = actualOptionalMessage.length > user.maxMessageLength;@@ -269,10 +275,11 @@ export const ForwardModal = observer(setIsForwarding(true);try {let actualMessage: string | undefined;- if (!isCommentComposerDisabled && optionalMessage.trim().length > 0) {- actualMessage = actualOptionalMessage;+ const trimmedOptionalMessage = actualOptionalMessage.trim();+ if (!isCommentComposerDisabled && trimmedOptionalMessage.length > 0) {+ actualMessage = trimmedOptionalMessage;}- const guildId = resolveForwardReferenceGuildId(channel, message);+ const guildId = resolveForwardReferenceGuildId(sourceForwardChannel, message);let attachmentIds: ReadonlyArray<string> | undefined;let embedIndices: ReadonlyArray<number> | undefined;if (mediaSelection !== undefined) {@@ -509,7 +516,7 @@ export const ForwardModal = observer(initialValue=""initialSegments={EMPTY_FORWARD_COMMENT_SEGMENTS}className={modalStyles.richInput}- channel={channel}+ channel={composerChannel}disabled={isCommentComposerDisabled}markdown={true}singleLine={false}