refactor(app): rename ComponentDispatch to ComponentBus (#1844)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-24 12:29:38 +02:00
1 parent 01a29d629b
commit c285854b71
68 files changed
+219 -219

No files matched your search

@@ -15,7 +15,7 @@ import Messages from '@app/features/messaging/state/MessagingMessages';
import {type CloudAttachment, CloudUpload} from '@app/features/messaging/upload/CloudUpload';
import {isEmbeddableImageFile} from '@app/features/messaging/utils/EmbeddableImageTypes';
import {formatFileSize} from '@app/features/messaging/utils/FileUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import * as MediaViewerCommands from '@app/features/ui/commands/MediaViewerCommands';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
@@ -629,7 +629,7 @@ export const ChannelAttachmentArea = observer(({channelId}: {channelId: string})
forceJumpFrameRef.current = null;
const messages = Messages.getMessages(channelIdRef.current);
if (messages.hasMoreAfter) {
ComponentDispatch.dispatch('FORCE_JUMP_TO_PRESENT');
ComponentBus.dispatch('FORCE_JUMP_TO_PRESENT');
}
});
}, []);
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
export interface ChannelComposerDismissalRequest {
channelId: string;
}
export function requestChannelComposerAffordanceDismissal(channelId: string): boolean {
const result = ComponentDispatch.dispatchToFirstResult(
const result = ComponentBus.dispatchToFirstResult(
'TEXTAREA_DISMISS_AFFORDANCE',
{channelId},
(candidate) => candidate === true,
@@ -78,7 +78,7 @@ import * as NavigationCommands from '@app/features/navigation/commands/Navigatio
import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
import {goBackOr} from '@app/features/platform/components/router/NavigationAdapter';
import {useLocation} from '@app/features/platform/components/router/RouterReact';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {AddFriendsToGroupModal} from '@app/features/relationship/components/modals/AddFriendsToGroupModal';
import Relationships from '@app/features/relationship/state/Relationships';
import type {SearchSegment} from '@app/features/search/utils/SearchSegmentManager';
@@ -329,11 +329,11 @@ export const ChannelHeader = observer(
setInitialTab(initialTab || 'members');
setChannelDetailsOpen(true);
};
return ComponentDispatch.subscribe('CHANNEL_DETAILS_OPEN', handleChannelDetailsOpen);
return ComponentBus.subscribe('CHANNEL_DETAILS_OPEN', handleChannelDetailsOpen);
}, []);
useEffect(() => {
if (!showMembersToggle) return;
return ComponentDispatch.subscribe('CHANNEL_MEMBER_LIST_TOGGLE', () => {
return ComponentBus.subscribe('CHANNEL_MEMBER_LIST_TOGGLE', () => {
if (canFitMemberList) {
if (memberListUsesChannelOverride) {
MemberList.toggleDefaultHiddenChannelMembers(memberListChannelId);
@@ -31,7 +31,7 @@ import {
import LocalUserSpamOverride from '@app/features/moderation/state/LocalUserSpamOverride';
import SelectedChannel from '@app/features/navigation/state/SelectedChannel';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {useScrollManager} from '@app/features/platform/utils/ScrollManager';
import * as ReadStateCommands from '@app/features/read_state/commands/ReadStateCommands';
import ReadStates from '@app/features/read_state/state/ReadStates';
@@ -400,14 +400,14 @@ export const Messages = observer(function Messages({
}
};
const dispatchUnsubs = [
ComponentDispatch.subscribe('SCROLLTO_PRESENT', onScrollToPresent),
ComponentDispatch.subscribe('MESSAGE_SENT', onMessageSent),
ComponentDispatch.subscribe('FORCE_JUMP_TO_PRESENT', onForceJumpToPresent),
ComponentDispatch.subscribe('ESCAPE_PRESSED', onEscapePressed),
ComponentDispatch.subscribe('SCROLL_PAGE_UP', onScrollPageUp),
ComponentDispatch.subscribe('SCROLL_PAGE_DOWN', onScrollPageDown),
ComponentDispatch.subscribe('LAYOUT_RESIZED', onLayoutResized),
ComponentDispatch.subscribe('FOCUS_BOTTOMMOST_MESSAGE', onFocusBottommostMessage),
ComponentBus.subscribe('SCROLL_TO_PRESENT', onScrollToPresent),
ComponentBus.subscribe('MESSAGE_SENT', onMessageSent),
ComponentBus.subscribe('FORCE_JUMP_TO_PRESENT', onForceJumpToPresent),
ComponentBus.subscribe('ESCAPE_PRESSED', onEscapePressed),
ComponentBus.subscribe('SCROLL_PAGE_UP', onScrollPageUp),
ComponentBus.subscribe('SCROLL_PAGE_DOWN', onScrollPageDown),
ComponentBus.subscribe('LAYOUT_RESIZED', onLayoutResized),
ComponentBus.subscribe('FOCUS_BOTTOMMOST_MESSAGE', onFocusBottommostMessage),
];
updateFromState();
return () => {
@@ -477,7 +477,7 @@ export const Messages = observer(function Messages({
return;
}
scrollManager.jumpCancel();
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId: channel.id});
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId: channel.id});
},
allowWhenInactive: true,
});
@@ -4,7 +4,7 @@ import * as ChannelStickerCommands from '@app/features/channel/commands/ChannelS
import styles from '@app/features/channel/components/ChannelStickersArea.module.css';
import ChannelSticker from '@app/features/channel/state/ChannelSticker';
import {useStickerAnimation} from '@app/features/emoji/hooks/useStickerAnimation';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {StickerContextMenuItems} from '@app/features/ui/action_menu/items/StickerContextMenuItems';
import * as ContextMenuCommands from '@app/features/ui/commands/ContextMenuCommands';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
@@ -36,9 +36,9 @@ export const ChannelStickersArea: React.FC<ChannelStickersAreaProps> = observer(
const [previousSticker, setPreviousSticker] = useState(sticker);
useEffect(() => {
if (previousSticker && !sticker) {
ComponentDispatch.dispatch('FORCE_JUMP_TO_PRESENT');
ComponentBus.dispatch('FORCE_JUMP_TO_PRESENT');
} else if (!previousSticker && sticker) {
ComponentDispatch.dispatch('FORCE_JUMP_TO_PRESENT');
ComponentBus.dispatch('FORCE_JUMP_TO_PRESENT');
}
setPreviousSticker(sticker);
}, [sticker, previousSticker]);
@@ -23,7 +23,7 @@ import MessageEdit from '@app/features/messaging/state/MessageEdit';
import {applyMarkdownSegments} from '@app/features/messaging/utils/MarkdownToSegmentUtils';
import type {MentionSegment} from '@app/features/messaging/utils/TextareaSegmentManager';
import {TextareaSegmentManager} from '@app/features/messaging/utils/TextareaSegmentManager';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import * as PopoutCommands from '@app/features/ui/commands/PopoutCommands';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
import {openPopout} from '@app/features/ui/popover/PopoverPopout';
@@ -187,7 +187,7 @@ export const EditingMessageInput = observer(
setExpressionPickerOpen(false);
}, [channel.id, editingDisabled]);
useEffect(() => {
const unsubscribe = ComponentDispatch.subscribe('FOCUS_TEXTAREA', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('FOCUS_TEXTAREA', (payload?: unknown) => {
const data = payload as {channelId?: string; enterKeyboardMode?: boolean} | undefined;
let requestedChannelId: string | null = null;
let enterKeyboardMode: boolean | null = null;
@@ -247,7 +247,7 @@ export const EditingMessageInput = observer(
);
}, [channel.id, editingDisabled, expressionPickerOpen, handleEmojiSelect]);
useEffect(() => {
const unsubscribe = ComponentDispatch.subscribe('EDITING_EXPRESSION_PICKER_TAB_TOGGLE', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('EDITING_EXPRESSION_PICKER_TAB_TOGGLE', (payload?: unknown) => {
const data = payload as {channelId?: string; messageId?: string; tab?: string} | undefined;
if (data == null || data.channelId !== channel.id || data.messageId !== message.id || data.tab !== 'emojis') {
return;
@@ -28,7 +28,7 @@ import {
} from '@app/features/expressions/utils/ExpressionPermissionUtils';
import {getEmojiDisplayDataWithSkinTone} from '@app/features/expressions/utils/SkinToneUtils';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {usePremiumUpsellData} from '@app/features/premium/hooks/usePremiumUpsellData';
import {shouldShowPremiumFeatures} from '@app/features/premium/utils/PremiumUtils';
import {Scroller, type ScrollerHandle} from '@app/features/ui/components/Scroller';
@@ -113,7 +113,7 @@ export const EmojiPicker = observer(
const handleEmojiDataUpdated = () => {
setEmojiDataVersion((version) => version + 1);
};
return ComponentDispatch.subscribe('EMOJI_PICKER_RERENDER', handleEmojiDataUpdated);
return ComponentBus.subscribe('EMOJI_PICKER_RERENDER', handleEmojiDataUpdated);
}, []);
useSearchInputAutofocus(searchInputRef);
const searchItems = useMemo(
@@ -15,7 +15,7 @@ import {
import cardStyles from '@app/features/messaging/components/embeds/embed_card/EmbedCard.module.css';
import {useEmbedSkeletonOverride} from '@app/features/messaging/components/embeds/embed_card/useEmbedSkeletonOverride';
import {Logger} from '@app/features/platform/utils/AppLogger';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {Button} from '@app/features/ui/button/Button';
import Users from '@app/features/user/state/Users';
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
@@ -87,7 +87,7 @@ export const GiftEmbed = observer(function GiftEmbed({code}: GiftEmbedProps) {
useEffect(() => {
const isLoading = !!giftState?.loading;
if (prevLoadingRef.current && !isLoading && giftState) {
ComponentDispatch.dispatch('LAYOUT_RESIZED');
ComponentBus.dispatch('LAYOUT_RESIZED');
}
prevLoadingRef.current = isLoading;
}, [giftState?.loading]);
@@ -49,7 +49,7 @@ import cardStyles from '@app/features/messaging/components/embeds/embed_card/Emb
import {useEmbedSkeletonOverride} from '@app/features/messaging/components/embeds/embed_card/useEmbedSkeletonOverride';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import StreamerMode from '@app/features/streamer_mode/state/StreamerMode';
import {InviteEmbedContextMenu} from '@app/features/ui/action_menu/InviteEmbedContextMenu';
import {Button} from '@app/features/ui/button/Button';
@@ -210,7 +210,7 @@ const InviteEmbedInner = observer(function InviteEmbedInner({
}, [code]);
useEffect(() => {
if (prevLoadingRef.current && !isLoading && currentChannelId) {
ComponentDispatch.dispatch('LAYOUT_RESIZED', {channelId: currentChannelId});
ComponentBus.dispatch('LAYOUT_RESIZED', {channelId: currentChannelId});
}
prevLoadingRef.current = isLoading;
}, [isLoading, currentChannelId]);
@@ -97,7 +97,7 @@ import {
resolveTypedEmojiShortcodes,
resolveTypedEmojiToken,
} from '@app/features/messaging/utils/TypedEmojiShortcodeUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {useSlowmode} from '@app/features/slowmode/hooks/useSlowmode';
import * as ContextMenuCommands from '@app/features/ui/commands/ContextMenuCommands';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
@@ -689,7 +689,7 @@ export const LexicalChannelTextareaContent = observer(
wasAtBottomBeforeComposerBoundaryChange.current &&
(stickerBoundaryChanged || (attachmentBoundaryChanged && Messages.getMessages(channel.id).hasMoreAfter))
) {
ComponentDispatch.dispatch('FORCE_JUMP_TO_PRESENT', {channelId: channel.id});
ComponentBus.dispatch('FORCE_JUMP_TO_PRESENT', {channelId: channel.id});
}
previousComposerBoundaryState.current = {channelId: channel.id, hasAttachments, hasPendingSticker};
const scrollerElement = getActiveMessageScroller();
@@ -789,7 +789,7 @@ export const LexicalChannelTextareaContent = observer(
replyingMessage,
]);
useEffect(() => {
return ComponentDispatch.subscribe('TEXTAREA_DISMISS_AFFORDANCE', (request?: unknown) => {
return ComponentBus.subscribe('TEXTAREA_DISMISS_AFFORDANCE', (request?: unknown) => {
const dismissalRequest = request as ChannelComposerDismissalRequest | undefined;
if (dismissalRequest?.channelId !== channel.id) {
return false;
@@ -863,7 +863,7 @@ export const LexicalChannelTextareaContent = observer(
}, [canSubmit, channel, hasAttachments, onSubmit]);
const handleArrowUpEmpty = useCallback(() => {
if (KeyboardMode.keyboardModeEnabled) {
ComponentDispatch.dispatch('FOCUS_BOTTOMMOST_MESSAGE', {channelId: channel.id});
ComponentBus.dispatch('FOCUS_BOTTOMMOST_MESSAGE', {channelId: channel.id});
return;
}
const message = Messages.getLastEditableMessage(channel.id);
@@ -909,7 +909,7 @@ export const LexicalChannelTextareaContent = observer(
Number.MAX_SAFE_INTEGER,
);
useEffect(() => {
const unsubscribe = ComponentDispatch.subscribe('FOCUS_TEXTAREA', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('FOCUS_TEXTAREA', (payload?: unknown) => {
const payloadValue = payload === null || payload === undefined ? {} : payload;
const {channelId, enterKeyboardMode} = payloadValue as {
channelId?: string;
@@ -944,7 +944,7 @@ export const LexicalChannelTextareaContent = observer(
}, [editingMessageId, mobileLayout.enabled, textareaInputDisabled]);
useEffect(() => {
if (textareaInputDisabled) return;
const unsubscribe = ComponentDispatch.subscribe('TEXTAREA_UPLOAD_FILE', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('TEXTAREA_UPLOAD_FILE', (payload?: unknown) => {
const payloadValue = payload === null || payload === undefined ? {} : payload;
const {channelId} = payloadValue as {channelId?: string};
if (channelId && channelId !== channel.id) return;
@@ -953,7 +953,7 @@ export const LexicalChannelTextareaContent = observer(
return unsubscribe;
}, [channel.id, textareaInputDisabled, handleFileButtonClick]);
useEffect(() => {
const unsubscribe = ComponentDispatch.subscribe('TEXTAREA_SEND_VOICE_MESSAGE', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('TEXTAREA_SEND_VOICE_MESSAGE', (payload?: unknown) => {
const payloadValue = payload === null || payload === undefined ? {} : payload;
const {channelId} = payloadValue as {channelId?: string};
if (channelId && channelId !== channel.id) return undefined;
@@ -38,7 +38,7 @@ import {
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import SavedMessages from '@app/features/messaging/state/SavedMessages';
import {getEmojiNameWithColons, toReactionEmoji} from '@app/features/messaging/utils/ReactionUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import messageStyles from '@app/features/theme/styles/Message.module.css';
import {
AddReactionIcon,
@@ -438,7 +438,7 @@ export const MessageActionBarCore: React.FC<MessageActionBarCoreProps> = observe
);
}, [message, i18n]);
useEffect(() => {
const unsubscribe = ComponentDispatch.subscribe('EMOJI_PICKER_OPEN', (payload?: unknown) => {
const unsubscribe = ComponentBus.subscribe('EMOJI_PICKER_OPEN', (payload?: unknown) => {
const data = (payload ?? {}) as {messageId?: string};
if (data.messageId === message.id && emojiPickerButtonRef.current) {
PopoutCommands.open({
@@ -24,7 +24,7 @@ import {retryFailedMessage} from '@app/features/messaging/utils/MessageRetryUtil
import {type ReactionEmoji, toReactionEmoji} from '@app/features/messaging/utils/ReactionUtils';
import {getDefaultReplyMention} from '@app/features/notification/utils/MentionReplyPreferenceUtils';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import * as ReadStateCommands from '@app/features/read_state/commands/ReadStateCommands';
import Relationships from '@app/features/relationship/state/Relationships';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
@@ -128,7 +128,7 @@ export function canDeleteAttachmentUtil(message: Message | undefined): boolean {
}
export function requestOpenReactionPicker(messageId: string): void {
ComponentDispatch.dispatch('EMOJI_PICKER_OPEN', {messageId});
ComponentBus.dispatch('EMOJI_PICKER_OPEN', {messageId});
}
function messageElementSelector(messageId: string): string {
@@ -145,14 +145,14 @@ export function triggerAddReaction(message: Message): boolean {
}
const messageElement = document.querySelector<HTMLElement>(messageElementSelector(message.id));
if (!messageElement) {
ComponentDispatch.dispatch('EMOJI_PICKER_OPEN', {messageId: message.id});
ComponentBus.dispatch('EMOJI_PICKER_OPEN', {messageId: message.id});
return false;
}
const addReactionButton = messageElement.querySelector<HTMLButtonElement>(
'[data-action="message-add-reaction-button"]',
);
if (!addReactionButton) {
ComponentDispatch.dispatch('EMOJI_PICKER_OPEN', {messageId: message.id});
ComponentBus.dispatch('EMOJI_PICKER_OPEN', {messageId: message.id});
return false;
}
addReactionButton.click();
@@ -27,7 +27,7 @@ import {
} from '@app/features/expressions/utils/ExpressionPermissionUtils';
import {getEmojiDisplayDataWithSkinTone} from '@app/features/expressions/utils/SkinToneUtils';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {usePremiumUpsellData} from '@app/features/premium/hooks/usePremiumUpsellData';
import {shouldShowPremiumFeatures} from '@app/features/premium/utils/PremiumUtils';
import {Scroller, type ScrollerHandle} from '@app/features/ui/components/Scroller';
@@ -86,7 +86,7 @@ export const MobileEmojiPicker = observer(
const handleEmojiDataUpdated = () => {
setEmojiDataVersion((version) => version + 1);
};
return ComponentDispatch.subscribe('EMOJI_PICKER_RERENDER', handleEmojiDataUpdated);
return ComponentBus.subscribe('EMOJI_PICKER_RERENDER', handleEmojiDataUpdated);
}, []);
useEffect(() => {
const updateVisibleViewportWidth = () => {
@@ -19,7 +19,7 @@ import type {FavoriteMeme} from '@app/features/expressions/models/FavoriteMeme';
import FavoriteMemes from '@app/features/expressions/state/FavoriteMemes';
import {AUDIO_DESCRIPTOR, GIFS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {isKeyboardActivationKey} from '@app/features/input/utils/KeyboardUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {DeleteIcon, EditIcon} from '@app/features/ui/action_menu/ContextMenuIcons';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
@@ -269,7 +269,7 @@ export const MobileMemesPicker = observer(({onClose}: MobileMemesPickerProps = {
memeRecord: meme,
onClick: (event?: React.MouseEvent) => {
const shiftKey = event?.shiftKey ?? false;
ComponentDispatch.dispatch('FAVORITE_MEME_SELECT', {meme, autoSend: !shiftKey});
ComponentBus.dispatch('FAVORITE_MEME_SELECT', {meme, autoSend: !shiftKey});
if (!shiftKey) {
onClose?.();
}
@@ -30,7 +30,7 @@ import {
shouldShowStickerPremiumUpsell,
} from '@app/features/expressions/utils/ExpressionPermissionUtils';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {usePremiumUpsellData} from '@app/features/premium/hooks/usePremiumUpsellData';
import {shouldShowPremiumFeatures} from '@app/features/premium/utils/PremiumUtils';
import {Scroller, type ScrollerHandle} from '@app/features/ui/components/Scroller';
@@ -109,7 +109,7 @@ export const MobileStickersPicker = observer(
const handleStickerDataUpdated = () => {
setStickerDataVersion((version) => version + 1);
};
return ComponentDispatch.subscribe('STICKER_PICKER_RERENDER', handleStickerDataUpdated);
return ComponentBus.subscribe('STICKER_PICKER_RERENDER', handleStickerDataUpdated);
}, []);
useSearchInputAutofocus(searchInputRef);
const searchItems = useMemo(
@@ -5,7 +5,7 @@ import {SystemMessageUsername} from '@app/features/channel/components/SystemMess
import {useSystemMessageData} from '@app/features/messaging/hooks/useSystemMessageData';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import {goToMessage} from '@app/features/messaging/utils/MessageNavigator';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import styles from '@app/features/theme/styles/Message.module.css';
import MobileLayout from '@app/features/ui/state/MobileLayout';
import {Trans} from '@lingui/react/macro';
@@ -30,11 +30,11 @@ export const PinSystemMessage = observer(({message}: PinSystemMessageProps) => {
}, [message.channelId, message.id, message.messageReference?.message_id]);
const openPins = useCallback(() => {
if (mobileLayout.enabled) {
ComponentDispatch.dispatch('CHANNEL_DETAILS_OPEN', {
ComponentBus.dispatch('CHANNEL_DETAILS_OPEN', {
initialTab: 'pins',
});
} else {
ComponentDispatch.dispatch('CHANNEL_PINS_OPEN');
ComponentBus.dispatch('CHANNEL_PINS_OPEN');
}
}, [mobileLayout.enabled]);
if (!channel) {
@@ -6,7 +6,7 @@ import {GuildMemberActionsSheet} from '@app/features/guild/components/modals/gui
import type {GuildMember} from '@app/features/member/models/GuildMember';
import GuildMembers from '@app/features/member/state/GuildMembers';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {GuildMemberContextMenu} from '@app/features/ui/action_menu/GuildMemberContextMenu';
import {UserContextMenu} from '@app/features/ui/action_menu/UserContextMenu';
import {WebhookContextMenu} from '@app/features/ui/action_menu/WebhookContextMenu';
@@ -155,7 +155,7 @@ export const PreloadableUserPopout = React.forwardRef<
if (isShiftMentionClick(event)) {
event.preventDefault();
event.stopPropagation();
ComponentDispatch.dispatch('INSERT_MENTION', {userId: user.id});
ComponentBus.dispatch('INSERT_MENTION', {userId: user.id});
return;
}
handleMobileClick();
@@ -217,7 +217,7 @@ export const PreloadableUserPopout = React.forwardRef<
if (isShiftMentionClick(event)) {
event.preventDefault();
event.stopPropagation();
ComponentDispatch.dispatch('INSERT_MENTION', {userId: user.id});
ComponentBus.dispatch('INSERT_MENTION', {userId: user.id});
return;
}
if (originalOnClick) {
@@ -25,7 +25,7 @@ import {
shouldShowStickerPremiumUpsell,
} from '@app/features/expressions/utils/ExpressionPermissionUtils';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {usePremiumUpsellData} from '@app/features/premium/hooks/usePremiumUpsellData';
import {shouldShowPremiumFeatures} from '@app/features/premium/utils/PremiumUtils';
import {Scroller, type ScrollerHandle} from '@app/features/ui/components/Scroller';
@@ -101,7 +101,7 @@ export const StickersPicker = observer(
const handleStickerDataUpdated = () => {
setStickerDataVersion((version) => version + 1);
};
return ComponentDispatch.subscribe('STICKER_PICKER_RERENDER', handleStickerDataUpdated);
return ComponentBus.subscribe('STICKER_PICKER_RERENDER', handleStickerDataUpdated);
}, []);
useSearchInputAutofocus(searchInputRef);
const searchItems = useMemo(
@@ -12,7 +12,7 @@ import MessageQueue from '@app/features/messaging/state/MessageQueue';
import {CloudUpload} from '@app/features/messaging/upload/CloudUpload';
import {isDialogPasteTarget} from '@app/features/messaging/utils/TextInputEditUtils';
import {formatUploadingAttachmentSummary} from '@app/features/messaging/utils/UploadingAttachmentLabelUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {useSlowmode} from '@app/features/slowmode/hooks/useSlowmode';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
@@ -50,7 +50,7 @@ export const UploadManager = observer(({channel, canAttachFiles, canSendMessages
}, []);
const focusTextarea = useCallback(() => {
setTimeout(() => {
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId: channel.id});
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId: channel.id});
}, 0);
}, [channel.id]);
const onDrop = useCallback(
@@ -39,7 +39,7 @@ import Channels from '@app/features/channel/state/Channels';
import * as ChannelUtils from '@app/features/channel/utils/ChannelUtils';
import {INCOMING_CALL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {useMemberListVisible} from '@app/features/member/hooks/useMemberListVisible';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import ReadStates from '@app/features/read_state/state/ReadStates';
import Relationships from '@app/features/relationship/state/Relationships';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
@@ -160,7 +160,7 @@ export const DMChannelView = observer(({channelId}: DMChannelViewProps) => {
});
useEffect(() => {
if (!showCompactVoiceView || !currentChannelId) return;
return ComponentDispatch.subscribe('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', (payload?: unknown) => {
return ComponentBus.subscribe('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', (payload?: unknown) => {
const {channelId: targetChannelId} = (payload ?? {}) as {channelId?: string};
if (targetChannelId && targetChannelId !== currentChannelId) return false;
handleToggleCompactCallExpanded();
@@ -33,7 +33,7 @@ import Guilds from '@app/features/guild/state/Guilds';
import GuildVerification from '@app/features/guild/state/GuildVerification';
import {useMemberListVisible} from '@app/features/member/hooks/useMemberListVisible';
import Permission from '@app/features/permissions/state/Permission';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import ReadStates from '@app/features/read_state/state/ReadStates';
import {Button} from '@app/features/ui/button/Button';
import MobileLayout from '@app/features/ui/state/MobileLayout';
@@ -255,7 +255,7 @@ export const GuildChannelView = observer(({channelId, guildId}: GuildChannelView
}, [handleOpenVoiceCallFromTextChat, handleOpenVoiceTextChat, isVoiceTextCallExpanded]);
useEffect(() => {
if (!isVoiceChannel) return;
return ComponentDispatch.subscribe('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', (payload?: unknown) => {
return ComponentBus.subscribe('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', (payload?: unknown) => {
const {channelId: targetChannelId} = (payload ?? {}) as {channelId?: string};
if (targetChannelId && targetChannelId !== channelId) return false;
handleToggleVoiceTextCallExpanded();
@@ -6,7 +6,7 @@ import {EMOJI_CLAP} from '@app/features/channel/components/emoji_picker/EmojiPic
import * as EmojiCommands from '@app/features/emoji/commands/EmojiCommands';
import Emoji from '@app/features/emoji/state/Emoji';
import * as EmojiUtils from '@app/features/expressions/utils/EmojiUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {SKIN_TONE_SURROGATES} from '@fluxer/constants/src/EmojiConstants';
import {AnimatePresence, motion} from 'framer-motion';
import {observer} from 'mobx-react-lite';
@@ -22,7 +22,7 @@ const SkinTonePicker = observer(({isOpen, onClose, skinTone}: SkinTonePickerProp
const prefersReducedMotion = Accessibility.useReducedMotion;
const handleSelect = (surrogate: string) => {
EmojiCommands.setSkinTone(surrogate);
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
onClose();
};
return (
@@ -24,7 +24,7 @@ import type {LexicalSearchInputHandle} from '@app/features/lexical/search/Lexica
import MemberSearch, {type SearchContext} from '@app/features/member/state/MemberSearch';
import {isIMEComposing} from '@app/features/messaging/utils/IMECompositionUtils';
import SelectedChannel from '@app/features/navigation/state/SelectedChannel';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import SearchHistory, {type SearchHistoryEntry} from '@app/features/search/state/SearchHistory';
import {
buildSearchSegmentsFromHints,
@@ -213,7 +213,7 @@ export function useMessageSearchAutocomplete({
}
}, [channel?.id, channel?.name, contextId, isInGuildChannel, onChange, value]);
useEffect(() => {
return ComponentDispatch.subscribe('MESSAGE_SEARCH_OPEN', () => {
return ComponentBus.subscribe('MESSAGE_SEARCH_OPEN', () => {
openSearchInput();
});
}, [openSearchInput]);
@@ -22,7 +22,7 @@ import {
REMOVE_FROM_FAVORITES_DESCRIPTOR,
} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {isKeyboardActivationKey} from '@app/features/input/utils/KeyboardUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
import {modal, push} from '@app/features/ui/commands/ModalCommands';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
@@ -173,7 +173,7 @@ export const GifPickerGridItem = observer(function GifPickerGridItem({
return;
}
if (gif.favoriteGifLookup) {
ComponentDispatch.dispatch('GIF_SELECT', {
ComponentBus.dispatch('GIF_SELECT', {
gif,
autoSend: autoSendKlipyGifs && !shiftKey,
});
@@ -184,7 +184,7 @@ export const GifPickerGridItem = observer(function GifPickerGridItem({
if (!shareId) return;
GifCommands.registerShare(shareId, searchTerm);
const shareUrl = GifSlugUtils.resolveShareUrl(provider, {url: gif.url, slug: shareId});
ComponentDispatch.dispatch('GIF_SELECT', {
ComponentBus.dispatch('GIF_SELECT', {
gif: {
...gif,
id: shareId,
@@ -14,7 +14,7 @@ import {EditFavoriteMemeModal} from '@app/features/expressions/components/modals
import type {FavoriteMeme} from '@app/features/expressions/models/FavoriteMeme';
import {isKeyboardActivationKey} from '@app/features/input/utils/KeyboardUtils';
import {buildMediaProxyURL, buildStaticGifPreviewURL} from '@app/features/messaging/utils/MediaProxyUtils';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
@@ -157,7 +157,7 @@ export const MemeGridItem = observer(
const handleClick = (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => {
const shiftKey = 'shiftKey' in event ? event.shiftKey : false;
MemesPicker.trackMemeUsage(meme.id);
ComponentDispatch.dispatch('FAVORITE_MEME_SELECT', {meme, autoSend: !shiftKey});
ComponentBus.dispatch('FAVORITE_MEME_SELECT', {meme, autoSend: !shiftKey});
if (!shiftKey) onClose?.();
};
const handleEdit = (event: React.MouseEvent) => {
@@ -4,7 +4,7 @@ import {requestChannelComposerAffordanceDismissal} from '@app/features/channel/c
import type {Channel} from '@app/features/channel/models/Channel';
import type {ComposerHandle} from '@app/features/lexical/composer/ComposerHandle';
import MessageFocus from '@app/features/messaging/state/MessageFocus';
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {canFocusTextarea, safeFocus} from '@app/features/platform/utils/InputFocusManager';
import {isTextInputKeyEvent} from '@app/features/platform/utils/IsTextInputKeyEvent';
import QuickSwitcher from '@app/features/search/state/QuickSwitcher';
@@ -98,7 +98,7 @@ export function useChannelComposerGlobalShortcuts({
event.stopPropagation();
return;
}
ComponentDispatch.dispatch('ESCAPE_PRESSED', {channelId: channel.id});
ComponentBus.dispatch('ESCAPE_PRESSED', {channelId: channel.id});
event.preventDefault();
};
window.addEventListener('keydown', handleKeyDown);