mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
refactor(app): rename ComponentDispatch to ComponentBus (#1844)
This commit is contained in:
1 parent
01a29d629b
commit
c285854b71
68 files changed
+219
-219
No files matched your search
@@ -31,7 +31,7 @@ import {
|
||||
SEARCH_SETTINGS_PLACEHOLDER_DESCRIPTOR,
|
||||
SIGN_OUT_DESCRIPTOR,
|
||||
} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
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 {Button} from '@app/features/ui/button/Button';
|
||||
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
|
||||
@@ -223,7 +223,7 @@ const SidebarSections: React.FC<SidebarSectionsProps> = observer(
|
||||
scrollSpyContext.scrollToSection(sectionId);
|
||||
return;
|
||||
}
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: tabType, section: sectionId});
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: tabType, section: sectionId});
|
||||
};
|
||||
return (
|
||||
<SettingsModalSidebarSubItems
|
||||
|
||||
@@ -21,7 +21,7 @@ import {SubscriptionCard} from '@app/features/app/components/dialogs/components/
|
||||
import {PREMIUM_PRODUCT_FULL_NAME, PREMIUM_PRODUCT_NAME} from '@app/features/app/config/I18nDisplayConstants';
|
||||
import GeoIP from '@app/features/app/state/GeoIP';
|
||||
import Guilds from '@app/features/guild/state/Guilds';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands';
|
||||
import PremiumState from '@app/features/premium/state/PremiumState';
|
||||
import {
|
||||
@@ -122,7 +122,7 @@ export const PlutoniumContent = observer(({defaultGiftMode = false}: PlutoniumCo
|
||||
perksSectionRef.current?.scrollIntoView({behavior: 'auto', block: 'start'});
|
||||
}, []);
|
||||
const navigateToRedeemGift = useCallback(() => {
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'gift_inventory'});
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'gift_inventory'});
|
||||
}, []);
|
||||
const handleCancelSubscriptionConfirmed = useCallback(() => {
|
||||
ModalCommands.push(
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import styles from '@app/features/app/components/dialogs/components/plutonium/GiftInventoryBanner.module.css';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {shouldShowPremiumFeatures} from '@app/features/premium/utils/PremiumUtils';
|
||||
import {Button} from '@app/features/ui/button/Button';
|
||||
import type {User} from '@app/features/user/models/User';
|
||||
@@ -37,7 +37,7 @@ export const GiftInventoryBanner: React.FC<GiftInventoryBannerProps> = observer(
|
||||
<Button
|
||||
variant="secondary"
|
||||
small
|
||||
onClick={() => ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'gift_inventory'})}
|
||||
onClick={() => ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'gift_inventory'})}
|
||||
data-flx="app.plutonium.gift-inventory-banner.button.dispatch"
|
||||
>
|
||||
<Trans>View gifts</Trans>
|
||||
|
||||
@@ -27,7 +27,7 @@ import SelectedChannel from '@app/features/navigation/state/SelectedChannel';
|
||||
import Permission from '@app/features/permissions/state/Permission';
|
||||
import * as PermissionUtils from '@app/features/permissions/utils/PermissionUtils';
|
||||
import {useParams} from '@app/features/platform/components/router/RouterReact';
|
||||
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 * as NagbarCommands from '@app/features/ui/commands/NagbarCommands';
|
||||
@@ -433,7 +433,7 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
|
||||
useEffect(() => {
|
||||
if (prevNagbarCount.current !== nagbarCount) {
|
||||
prevNagbarCount.current = nagbarCount;
|
||||
ComponentDispatch.dispatch('LAYOUT_RESIZED');
|
||||
ComponentBus.dispatch('LAYOUT_RESIZED');
|
||||
}
|
||||
}, [nagbarCount]);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -90,7 +90,7 @@ import {openMacPermissionsModal} from '@app/features/permissions/system/commands
|
||||
import MacPermissions from '@app/features/permissions/system/state/MacPermissions';
|
||||
import {useLocation} from '@app/features/platform/components/router/RouterReact';
|
||||
import {Platform} from '@app/features/platform/types/Platform';
|
||||
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 {getRemScaleForDocument} from '@app/features/theme/layout/RemFromPx';
|
||||
import {AxisOrientation, type VerticalEdge} from '@app/features/ui/AxisOrientation';
|
||||
@@ -2166,7 +2166,7 @@ export const GuildsLayout = observer(({children}: {children: React.ReactNode}) =
|
||||
useEffect(() => {
|
||||
if (prevNagbarCount.current !== activeNagbars.length) {
|
||||
prevNagbarCount.current = activeNagbars.length;
|
||||
ComponentDispatch.dispatch('LAYOUT_RESIZED');
|
||||
ComponentBus.dispatch('LAYOUT_RESIZED');
|
||||
}
|
||||
}, [activeNagbars.length]);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {Routes} from '@app/app/Routes';
|
||||
import {CHANNEL_TEXTAREA_SELECTOR} from '@app/features/app/keybindings/utils/EditableElement';
|
||||
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 FocusRingManager from '@app/features/ui/focus_ring/FocusRingManager';
|
||||
import KeyboardMode from '@app/features/ui/state/KeyboardMode';
|
||||
import {
|
||||
@@ -61,7 +61,7 @@ export const KeyboardModeListener = observer(() => {
|
||||
const composer = document.querySelector<HTMLTextAreaElement>(CHANNEL_TEXTAREA_SELECTOR);
|
||||
if (canRedirectTabToComposer(composer)) {
|
||||
event.preventDefault();
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {enterKeyboardMode: true});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {enterKeyboardMode: true});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -31,7 +31,7 @@ import SelectedChannel from '@app/features/navigation/state/SelectedChannel';
|
||||
import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
|
||||
import MentionFeed from '@app/features/notification/state/MentionFeed';
|
||||
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 ReadStates from '@app/features/read_state/state/ReadStates';
|
||||
import QuickSwitcher from '@app/features/search/state/QuickSwitcher';
|
||||
@@ -128,7 +128,7 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
});
|
||||
host.register('misc_search', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('MESSAGE_SEARCH_OPEN');
|
||||
ComponentBus.dispatch('MESSAGE_SEARCH_OPEN');
|
||||
});
|
||||
host.register('voice_toggle_mute', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
@@ -283,13 +283,13 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
});
|
||||
host.register('voice_toggle_soundboard', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('SOUNDBOARD_TOGGLE');
|
||||
ComponentBus.dispatch('SOUNDBOARD_TOGGLE');
|
||||
});
|
||||
host.register('voice_toggle_compact_call_view', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', {channelId});
|
||||
ComponentBus.dispatch('COMPACT_VOICE_CALL_EXPANSION_TOGGLE', {channelId});
|
||||
});
|
||||
host.register('chat_copy_channel_link', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
@@ -304,15 +304,15 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
});
|
||||
host.register('chat_scroll_up', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('SCROLL_PAGE_UP');
|
||||
ComponentBus.dispatch('SCROLL_PAGE_UP');
|
||||
});
|
||||
host.register('chat_scroll_down', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('SCROLL_PAGE_DOWN');
|
||||
ComponentBus.dispatch('SCROLL_PAGE_DOWN');
|
||||
});
|
||||
host.register('chat_jump_oldest_unread', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
@@ -328,7 +328,7 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
if (!channelId) return;
|
||||
if (requestChannelComposerAffordanceDismissal(channelId)) return;
|
||||
if (ReadStates.hasUnread(channelId)) {
|
||||
ComponentDispatch.dispatch('ESCAPE_PRESSED', {channelId});
|
||||
ComponentBus.dispatch('ESCAPE_PRESSED', {channelId});
|
||||
}
|
||||
});
|
||||
host.register('chat_mark_guild_read', ({type}) => {
|
||||
@@ -465,15 +465,15 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
});
|
||||
host.register('chat_toggle_pins', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('CHANNEL_PINS_OPEN');
|
||||
ComponentBus.dispatch('CHANNEL_PINS_OPEN');
|
||||
});
|
||||
host.register('chat_toggle_inbox', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('INBOX_OPEN');
|
||||
ComponentBus.dispatch('INBOX_OPEN');
|
||||
});
|
||||
host.register('chat_toggle_member_list', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
ComponentDispatch.dispatch('CHANNEL_MEMBER_LIST_TOGGLE');
|
||||
ComponentBus.dispatch('CHANNEL_MEMBER_LIST_TOGGLE');
|
||||
});
|
||||
host.register('chat_toggle_emoji', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
@@ -481,38 +481,38 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
if (!channelId) return;
|
||||
const editingMessageId = MessageEdit.getEditingMessageId(channelId);
|
||||
if (editingMessageId) {
|
||||
ComponentDispatch.dispatch('EDITING_EXPRESSION_PICKER_TAB_TOGGLE', {
|
||||
ComponentBus.dispatch('EDITING_EXPRESSION_PICKER_TAB_TOGGLE', {
|
||||
channelId,
|
||||
messageId: editingMessageId,
|
||||
tab: 'emojis',
|
||||
});
|
||||
return;
|
||||
}
|
||||
ComponentDispatch.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'emojis'});
|
||||
ComponentBus.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'emojis'});
|
||||
});
|
||||
host.register('chat_toggle_gif', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'gifs'});
|
||||
ComponentBus.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'gifs'});
|
||||
});
|
||||
host.register('chat_toggle_sticker', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'stickers'});
|
||||
ComponentBus.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'stickers'});
|
||||
});
|
||||
host.register('chat_toggle_saved_media', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'memes'});
|
||||
ComponentBus.dispatch('EXPRESSION_PICKER_TAB_TOGGLE', {channelId, tab: 'memes'});
|
||||
});
|
||||
host.register('chat_send_voice_message', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId ?? Navigation.channelId;
|
||||
if (!channelId) return;
|
||||
const textareaResult = ComponentDispatch.dispatchToFirstResult(
|
||||
const textareaResult = ComponentBus.dispatchToFirstResult(
|
||||
'TEXTAREA_SEND_VOICE_MESSAGE',
|
||||
{channelId},
|
||||
(result) => result === true || result === false,
|
||||
@@ -537,13 +537,13 @@ export function registerDefaultKeybindHandlers(host: HandlerHost, i18n: I18n): v
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
});
|
||||
host.register('chat_upload', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
const channelId = host.currentChannelId;
|
||||
if (!channelId) return;
|
||||
ComponentDispatch.dispatch('TEXTAREA_UPLOAD_FILE', {channelId});
|
||||
ComponentBus.dispatch('TEXTAREA_UPLOAD_FILE', {channelId});
|
||||
});
|
||||
host.register('system_zoom_in', ({type}) => {
|
||||
if (type !== 'press') return;
|
||||
|
||||
@@ -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 (
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {useEffect, useRef} from 'react';
|
||||
|
||||
export function useChannelMemberListVisibility(channelId: string | null, visible: boolean): void {
|
||||
@@ -10,6 +10,6 @@ export function useChannelMemberListVisibility(channelId: string | null, visible
|
||||
previousVisibilityRef.current = {channelId, visible};
|
||||
if (!channelId) return;
|
||||
if (previousVisibility.channelId === channelId && previousVisibility.visible === visible) return;
|
||||
ComponentDispatch.dispatch('LAYOUT_RESIZED', {channelId});
|
||||
ComponentBus.dispatch('LAYOUT_RESIZED', {channelId});
|
||||
}, [channelId, visible]);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {useEffect, useRef} from 'react';
|
||||
|
||||
export function useChannelSearchVisibility(channelId: string | null, visible: boolean): void {
|
||||
@@ -10,6 +10,6 @@ export function useChannelSearchVisibility(channelId: string | null, visible: bo
|
||||
previousVisibilityRef.current = {channelId, visible};
|
||||
if (!channelId) return;
|
||||
if (previousVisibility.channelId === channelId && previousVisibility.visible === visible) return;
|
||||
ComponentDispatch.dispatch('LAYOUT_RESIZED', {channelId});
|
||||
ComponentBus.dispatch('LAYOUT_RESIZED', {channelId});
|
||||
}, [channelId, visible]);
|
||||
}
|
||||
@@ -9,13 +9,13 @@ type QuickReactionSnapshot = ReadonlyArray<FlatEmoji>;
|
||||
type EmojiState = typeof import('@app/features/emoji/state/Emoji')['default'];
|
||||
type EmojiPickerState = typeof import('@app/features/emoji/state/EmojiPicker')['default'];
|
||||
type PermissionState = typeof import('@app/features/permissions/state/Permission')['default'];
|
||||
type ComponentDispatchState = typeof import('@app/features/platform/utils/ComponentBus')['ComponentDispatch'];
|
||||
type ComponentBusState = typeof import('@app/features/platform/utils/ComponentBus')['ComponentBus'];
|
||||
|
||||
interface QuickReactionDependencies {
|
||||
Emoji: EmojiState;
|
||||
EmojiPicker: EmojiPickerState;
|
||||
Permission: PermissionState;
|
||||
ComponentDispatch: ComponentDispatchState;
|
||||
ComponentBus: ComponentBusState;
|
||||
}
|
||||
|
||||
const EMPTY_QUICK_REACTIONS: QuickReactionSnapshot = Object.freeze([]);
|
||||
@@ -39,11 +39,11 @@ function loadQuickReactionDependencies(): Promise<QuickReactionDependencies> {
|
||||
Emoji: emojiModule.default,
|
||||
EmojiPicker: emojiPickerModule.default,
|
||||
Permission: permissionModule.default,
|
||||
ComponentDispatch: componentBusModule.ComponentDispatch,
|
||||
ComponentBus: componentBusModule.ComponentBus,
|
||||
};
|
||||
if (!dependencies) {
|
||||
dependencies = loaded;
|
||||
loaded.ComponentDispatch.subscribe('EMOJI_PICKER_RERENDER', () => {
|
||||
loaded.ComponentBus.subscribe('EMOJI_PICKER_RERENDER', () => {
|
||||
cacheEpoch += 1;
|
||||
});
|
||||
loaded.Permission.subscribe(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {Channel} from '@app/features/channel/models/Channel';
|
||||
import DeveloperOptions, {type DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions';
|
||||
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 {User} from '@app/features/user/models/User';
|
||||
import Users from '@app/features/user/state/Users';
|
||||
import MockIncomingCall from '@app/features/voice/state/MockIncomingCall';
|
||||
@@ -18,7 +18,7 @@ type AttachmentMock = DeveloperOptionsState['mockAttachmentStates'][string];
|
||||
export type MockIncomingCallVariant = 'dm' | 'group-dm';
|
||||
|
||||
function publishLayoutResize(): void {
|
||||
ComponentDispatch.dispatch('LAYOUT_RESIZED');
|
||||
ComponentBus.dispatch('LAYOUT_RESIZED');
|
||||
}
|
||||
|
||||
function nextAttachmentMocks(
|
||||
|
||||
@@ -13,7 +13,7 @@ import {checkEmojiAvailability} from '@app/features/expressions/utils/Expression
|
||||
import UnicodeEmojis from '@app/features/expressions/utils/UnicodeEmojis';
|
||||
import type {GuildReadyData} from '@app/features/gateway/types/GatewayGuildTypes';
|
||||
import GuildList from '@app/features/guild/state/GuildList';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {makeSyncedField} from '@app/features/user/state/SyncedField';
|
||||
import type {GuildEmoji as WireGuildEmoji} from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas';
|
||||
import type {Guild as WireGuild} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas';
|
||||
@@ -452,27 +452,27 @@ class Emoji {
|
||||
for (const guild of guilds) {
|
||||
emojiGuildRegistry.updateGuild(guild.id, guild.emojis);
|
||||
}
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
handleGuildUpdate({guild}: {guild: GuildReadyData | WireGuild}): void {
|
||||
if (!('emojis' in guild)) {
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
return;
|
||||
}
|
||||
emojiGuildRegistry.updateGuild(guild.id, guild.emojis);
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
handleGuildEmojiUpdated({guildId, emojis}: {guildId: string; emojis: ReadonlyArray<WireGuildEmoji>}): void {
|
||||
emojiGuildRegistry.updateGuild(guildId, emojis);
|
||||
patchGuildEmojiCacheFromGateway(guildId, emojis);
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
handleGuildDelete({guildId}: {guildId: string}): void {
|
||||
emojiGuildRegistry.deleteGuild(guildId);
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '@app/features/emoji/state/UsageFrecency';
|
||||
import type {FlatEmoji} from '@app/features/emoji/types/EmojiTypes';
|
||||
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 {makeSyncedField} from '@app/features/user/state/SyncedField';
|
||||
import {EmojiPickerStateSchema} from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/pickers_pb';
|
||||
import {makeAutoObservable, untracked} from 'mobx';
|
||||
@@ -125,7 +125,7 @@ class EmojiPicker {
|
||||
this._favoriteSet = new Set(this.favoriteEmojis);
|
||||
this._collapsedSet = new Set(this.collapsedCategories);
|
||||
this.rankingDirty = true;
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
getRanking(): UsageRanking {
|
||||
@@ -167,7 +167,7 @@ class EmojiPicker {
|
||||
this._favoriteSet.add(emojiKey);
|
||||
this.favoriteEmojis.push(emojiKey);
|
||||
}
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
toggleCategory(category: string): void {
|
||||
@@ -182,7 +182,7 @@ class EmojiPicker {
|
||||
this._collapsedSet.add(category);
|
||||
this.collapsedCategories.push(category);
|
||||
}
|
||||
ComponentDispatch.dispatch('EMOJI_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('EMOJI_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
isFavorite(emoji: FlatEmoji): boolean {
|
||||
|
||||
@@ -5,7 +5,7 @@ import StickerPicker from '@app/features/emoji/state/StickerPicker';
|
||||
import {GuildSticker} from '@app/features/expressions/models/GuildSticker';
|
||||
import {patchGuildStickerCacheFromGateway} from '@app/features/expressions/state/GuildExpressionTabCache';
|
||||
import type {GuildReadyData} from '@app/features/gateway/types/GatewayGuildTypes';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import type {GuildSticker as WireGuildSticker} from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas';
|
||||
import {sortBySnowflakeDesc} from '@fluxer/snowflake/src/SnowflakeUtils';
|
||||
import {makeAutoObservable} from 'mobx';
|
||||
@@ -104,7 +104,7 @@ class Sticker {
|
||||
}
|
||||
}
|
||||
}
|
||||
ComponentDispatch.dispatch('STICKER_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('STICKER_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
handleGuildUpdate(guild: GuildStickersPayload): void {
|
||||
@@ -125,7 +125,7 @@ class Sticker {
|
||||
this.stickerById.delete(oldSticker.id);
|
||||
}
|
||||
this.guildStickers.delete(guildId);
|
||||
ComponentDispatch.dispatch('STICKER_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('STICKER_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
private updateGuildStickers(guildId: string, guildStickers: ReadonlyArray<WireGuildSticker>): void {
|
||||
@@ -139,7 +139,7 @@ class Sticker {
|
||||
for (const sticker of sortedStickers) {
|
||||
this.stickerById.set(sticker.id, sticker);
|
||||
}
|
||||
ComponentDispatch.dispatch('STICKER_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('STICKER_PICKER_RERENDER');
|
||||
}
|
||||
|
||||
private sortByFrecency(stickers: ReadonlyArray<GuildSticker>): ReadonlyArray<GuildSticker> {
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@app/features/emoji/state/UsageFrecency';
|
||||
import type {FavoriteMeme} from '@app/features/expressions/models/FavoriteMeme';
|
||||
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 {makeSyncedField} from '@app/features/user/state/SyncedField';
|
||||
import {MemesPickerStateSchema} from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/pickers_pb';
|
||||
import {makeAutoObservable} from 'mobx';
|
||||
@@ -81,7 +81,7 @@ class MemesPicker {
|
||||
} else {
|
||||
this.favoriteMemes.push(memeKey);
|
||||
}
|
||||
ComponentDispatch.dispatch('MEMES_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('MEMES_PICKER_RERENDER');
|
||||
logger.debug(`Toggled favorite meme: ${memeKey}`);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class MemesPicker {
|
||||
} else {
|
||||
this.collapsedCategories.push(category);
|
||||
}
|
||||
ComponentDispatch.dispatch('MEMES_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('MEMES_PICKER_RERENDER');
|
||||
logger.debug(`Toggled category: ${category}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@app/features/emoji/state/UsageFrecency';
|
||||
import type {GuildSticker} from '@app/features/expressions/models/GuildSticker';
|
||||
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 {makeSyncedField} from '@app/features/user/state/SyncedField';
|
||||
import {StickerPickerStateSchema} from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/pickers_pb';
|
||||
import {makeAutoObservable} from 'mobx';
|
||||
@@ -82,7 +82,7 @@ class StickerPicker {
|
||||
} else {
|
||||
this.favoriteStickers.push(stickerKey);
|
||||
}
|
||||
ComponentDispatch.dispatch('STICKER_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('STICKER_PICKER_RERENDER');
|
||||
logger.debug(`Toggled favorite sticker: ${stickerKey}`);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class StickerPicker {
|
||||
} else {
|
||||
this.collapsedCategories.push(category);
|
||||
}
|
||||
ComponentDispatch.dispatch('STICKER_PICKER_RERENDER');
|
||||
ComponentBus.dispatch('STICKER_PICKER_RERENDER');
|
||||
logger.debug(`Toggled category: ${category}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
MEDIA_DESCRIPTOR,
|
||||
STICKERS_DESCRIPTOR,
|
||||
} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {BottomSheet} from '@app/features/ui/bottom_sheet/BottomSheet';
|
||||
import {type SegmentedTab, SegmentedTabs} from '@app/features/ui/segmented_tabs/SegmentedTabs';
|
||||
import type {MessageDescriptor} from '@lingui/core';
|
||||
@@ -81,7 +81,7 @@ const EXPRESSION_PICKER_CATEGORY_DESCRIPTORS: Array<ExpressionPickerCategoryDesc
|
||||
if (StickerSendUtils.shouldSetPendingSticker(channelId)) {
|
||||
StickerSendUtils.setPendingSticker(channelId, sticker);
|
||||
} else {
|
||||
ComponentDispatch.dispatch('STICKER_SELECT', {sticker});
|
||||
ComponentBus.dispatch('STICKER_SELECT', {sticker});
|
||||
}
|
||||
if (!shiftKey) {
|
||||
onClose?.();
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
MEDIA_DESCRIPTOR,
|
||||
STICKERS_DESCRIPTOR,
|
||||
} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
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 type {ResizeEdge} from '@app/features/ui/floating_pane/FloatingPaneMath';
|
||||
import {useResizablePane} from '@app/features/ui/hooks/useResizablePane';
|
||||
@@ -110,7 +110,7 @@ const createAllCategories = (i18n: I18n): Array<ExpressionPickerCategory> => [
|
||||
if (StickerSendUtils.shouldSetPendingSticker(channelId)) {
|
||||
StickerSendUtils.setPendingSticker(channelId, sticker);
|
||||
} else {
|
||||
ComponentDispatch.dispatch('STICKER_SELECT', {sticker});
|
||||
ComponentBus.dispatch('STICKER_SELECT', {sticker});
|
||||
}
|
||||
if (onClose && !shiftKey) {
|
||||
onClose();
|
||||
|
||||
@@ -6,7 +6,7 @@ import {CANCEL_DESCRIPTOR, MARK_AS_READ_DESCRIPTOR} from '@app/features/i18n/uti
|
||||
import type {InboxTab} from '@app/features/inbox/state/Inbox';
|
||||
import Inbox from '@app/features/inbox/state/Inbox';
|
||||
import {focusChannelTextareaAfterNavigation} from '@app/features/messaging/utils/ChannelTextareaFocusUtils';
|
||||
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 {Checkbox} from '@app/features/ui/checkbox/Checkbox';
|
||||
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
|
||||
@@ -46,13 +46,13 @@ export function revealBookmarksPopoutForFirstSave(): boolean {
|
||||
return false;
|
||||
}
|
||||
const isInboxOpen = Popout.isOpen('inbox');
|
||||
const canOpenInbox = isInboxOpen || ComponentDispatch.hasSubscribers('INBOX_OPEN');
|
||||
const canOpenInbox = isInboxOpen || ComponentBus.hasSubscribers('INBOX_OPEN');
|
||||
if (!canOpenInbox) {
|
||||
return false;
|
||||
}
|
||||
Inbox.setTab('bookmarks');
|
||||
if (!isInboxOpen) {
|
||||
ComponentDispatch.dispatch('INBOX_OPEN');
|
||||
ComponentBus.dispatch('INBOX_OPEN');
|
||||
}
|
||||
Inbox.markBookmarksPopoutAutoOpenedForFirstSave();
|
||||
return true;
|
||||
|
||||
@@ -78,7 +78,7 @@ import {
|
||||
import MentionFrecency from '@app/features/notification/state/MentionFrecency';
|
||||
import Permission from '@app/features/permissions/state/Permission';
|
||||
import * as PermissionUtils from '@app/features/permissions/utils/PermissionUtils';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import type {User} from '@app/features/user/models/User';
|
||||
import Users from '@app/features/user/state/Users';
|
||||
import {formatUserTagForStreamerMode} from '@app/features/user/utils/DisplayNameUtils';
|
||||
@@ -196,8 +196,8 @@ export function useLexicalAutocomplete({
|
||||
function handleExpressionDataUpdated(): void {
|
||||
setExpressionDataVersion((version) => version + 1);
|
||||
}
|
||||
const unsubscribeEmoji = ComponentDispatch.subscribe('EMOJI_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeSticker = ComponentDispatch.subscribe('STICKER_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeEmoji = ComponentBus.subscribe('EMOJI_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeSticker = ComponentBus.subscribe('STICKER_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
return () => {
|
||||
unsubscribeEmoji();
|
||||
unsubscribeSticker();
|
||||
@@ -652,17 +652,17 @@ export function useLexicalAutocomplete({
|
||||
return;
|
||||
}
|
||||
if (isMeme(option)) {
|
||||
ComponentDispatch.dispatch('FAVORITE_MEME_SELECT', {meme: option.meme, autoSend: true});
|
||||
ComponentBus.dispatch('FAVORITE_MEME_SELECT', {meme: option.meme, autoSend: true});
|
||||
handle.clear();
|
||||
return;
|
||||
}
|
||||
if (isGif(option)) {
|
||||
ComponentDispatch.dispatch('GIF_SELECT', {gif: option.gif, autoSend: true});
|
||||
ComponentBus.dispatch('GIF_SELECT', {gif: option.gif, autoSend: true});
|
||||
handle.clear();
|
||||
return;
|
||||
}
|
||||
if (isSticker(option)) {
|
||||
ComponentDispatch.dispatch('STICKER_SELECT', {sticker: option.sticker});
|
||||
ComponentBus.dispatch('STICKER_SELECT', {sticker: option.sticker});
|
||||
handle.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import {http} from '@app/features/platform/transport/RestTransport';
|
||||
import {HttpError} from '@app/features/platform/types/EndpointError';
|
||||
import type {RestResponse} from '@app/features/platform/types/TransportTypes';
|
||||
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 {failureCode} from '@app/features/platform/utils/ResponseInspection';
|
||||
import * as ReadStateCommands from '@app/features/read_state/commands/ReadStateCommands';
|
||||
import ReadStates from '@app/features/read_state/state/ReadStates';
|
||||
@@ -728,12 +728,12 @@ export function revealMessage(channelId: string, messageId: string | null): void
|
||||
export function startReply(channelId: string, messageId: string, mentioning: boolean): void {
|
||||
logger.debug(`Starting reply to message ${messageId} in channel ${channelId}, mentioning=${mentioning}`);
|
||||
MessageReply.startReply(channelId, messageId, mentioning);
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
window.requestAnimationFrame(() => {
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
});
|
||||
window.setTimeout(() => {
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
}, 300);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import Keybind, {
|
||||
type KeyCombo,
|
||||
} from '@app/features/input/state/InputKeybind';
|
||||
import {replaceTextRange, setTextSelectionSoon} from '@app/features/messaging/utils/TextInputEditUtils';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import type React from 'react';
|
||||
import {type KeyboardEvent, useCallback, useEffect} from 'react';
|
||||
|
||||
@@ -198,7 +198,7 @@ export const useMarkdownFormattingShortcut = ({
|
||||
if (doesEventMatchShortcut(event, inboxCombo) && selectionStart === selectionEnd && value.trim().length === 0) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
ComponentDispatch.dispatch('INBOX_OPEN');
|
||||
ComponentBus.dispatch('INBOX_OPEN');
|
||||
return;
|
||||
}
|
||||
for (const {combo: shortcutCombo, wrapper} of MARKDOWN_FORMATTING_SHORTCUTS) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {Message} from '@app/features/messaging/models/MessagingMessage';
|
||||
import * as MessageSubmitUtils from '@app/features/messaging/utils/MessageSubmitUtils';
|
||||
import {formatUploadingAttachmentSummary} from '@app/features/messaging/utils/UploadingAttachmentLabelUtils';
|
||||
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 SlowmodeCommands from '@app/features/slowmode/commands/SlowmodeCommands';
|
||||
import {SlowmodeRateLimitedModal} from '@app/features/slowmode/components/alerts/SlowmodeRateLimitedModal';
|
||||
import Slowmode from '@app/features/slowmode/state/Slowmode';
|
||||
@@ -153,7 +153,7 @@ export const useMessageSubmission = ({channel, referencedMessage, replyingMessag
|
||||
.catch(() => {
|
||||
SlowmodeCommands.discardPendingMessageSend(channel.id, pendingSend);
|
||||
});
|
||||
ComponentDispatch.dispatch('MESSAGE_SENT', {channelId: channel.id});
|
||||
ComponentBus.dispatch('MESSAGE_SENT', {channelId: channel.id});
|
||||
return true;
|
||||
},
|
||||
[channel?.id, i18n, referencedMessage, replyingMessage],
|
||||
@@ -226,7 +226,7 @@ export const useMessageSubmission = ({channel, referencedMessage, replyingMessag
|
||||
.catch(() => {
|
||||
SlowmodeCommands.discardPendingMessageSend(channel.id, pendingSend);
|
||||
});
|
||||
ComponentDispatch.dispatch('MESSAGE_SENT', {channelId: channel.id});
|
||||
ComponentBus.dispatch('MESSAGE_SENT', {channelId: channel.id});
|
||||
},
|
||||
[channel?.id, referencedMessage, replyingMessage],
|
||||
);
|
||||
|
||||
@@ -63,7 +63,7 @@ import MentionFrecency from '@app/features/notification/state/MentionFrecency';
|
||||
import Permission from '@app/features/permissions/state/Permission';
|
||||
import * as PermissionUtils from '@app/features/permissions/utils/PermissionUtils';
|
||||
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 Users from '@app/features/user/state/Users';
|
||||
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
|
||||
import {Permissions} from '@fluxer/constants/src/ChannelConstants';
|
||||
@@ -182,8 +182,8 @@ export function useTextareaAutocomplete({
|
||||
function handleExpressionDataUpdated(): void {
|
||||
setExpressionDataVersion((version) => version + 1);
|
||||
}
|
||||
const unsubscribeEmoji = ComponentDispatch.subscribe('EMOJI_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeSticker = ComponentDispatch.subscribe('STICKER_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeEmoji = ComponentBus.subscribe('EMOJI_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
const unsubscribeSticker = ComponentBus.subscribe('STICKER_PICKER_RERENDER', handleExpressionDataUpdated);
|
||||
return () => {
|
||||
unsubscribeEmoji();
|
||||
unsubscribeSticker();
|
||||
@@ -706,19 +706,19 @@ export function useTextareaAutocomplete({
|
||||
return;
|
||||
}
|
||||
if (isMeme(option)) {
|
||||
ComponentDispatch.dispatch('FAVORITE_MEME_SELECT', {meme: option.meme, autoSend: true});
|
||||
ComponentBus.dispatch('FAVORITE_MEME_SELECT', {meme: option.meme, autoSend: true});
|
||||
applyAutocompleteValue('', [], 0);
|
||||
setSelectedIndex(0);
|
||||
return;
|
||||
}
|
||||
if (isGif(option)) {
|
||||
ComponentDispatch.dispatch('GIF_SELECT', {gif: option.gif, autoSend: true});
|
||||
ComponentBus.dispatch('GIF_SELECT', {gif: option.gif, autoSend: true});
|
||||
applyAutocompleteValue('', [], 0);
|
||||
setSelectedIndex(0);
|
||||
return;
|
||||
}
|
||||
if (isSticker(option)) {
|
||||
ComponentDispatch.dispatch('STICKER_SELECT', {sticker: option.sticker});
|
||||
ComponentBus.dispatch('STICKER_SELECT', {sticker: option.sticker});
|
||||
applyAutocompleteValue('', [], 0);
|
||||
setSelectedIndex(0);
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
type PrepareTextareaTextChange,
|
||||
} from '@app/features/messaging/utils/TextareaNativeEditUtils';
|
||||
import {type MentionSegment, TextareaSegmentManager} from '@app/features/messaging/utils/TextareaSegmentManager';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import Users from '@app/features/user/state/Users';
|
||||
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
|
||||
import type {MessageAttachment, MessageStickerItem} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';
|
||||
@@ -93,7 +93,7 @@ export const useTextareaExpressionHandlers = ({
|
||||
appendText(gifUrl);
|
||||
}
|
||||
};
|
||||
return ComponentDispatch.subscribe('GIF_SELECT', handleGifSelect);
|
||||
return ComponentBus.subscribe('GIF_SELECT', handleGifSelect);
|
||||
}, [appendText, sendOptimisticMessage, enabled]);
|
||||
useEffect(() => {
|
||||
const handleStickerSelect = (payload?: unknown) => {
|
||||
@@ -104,7 +104,7 @@ export const useTextareaExpressionHandlers = ({
|
||||
if (!sticker) return;
|
||||
sendOptimisticMessage({content: '', stickers: [sticker.toJSON()]}, {hasAttachments: false});
|
||||
};
|
||||
return ComponentDispatch.subscribe('STICKER_SELECT', handleStickerSelect);
|
||||
return ComponentBus.subscribe('STICKER_SELECT', handleStickerSelect);
|
||||
}, [sendOptimisticMessage, enabled]);
|
||||
useEffect(() => {
|
||||
const handleFavoriteMemeSelect = (payload?: unknown) => {
|
||||
@@ -144,7 +144,7 @@ export const useTextareaExpressionHandlers = ({
|
||||
}
|
||||
}
|
||||
};
|
||||
return ComponentDispatch.subscribe('FAVORITE_MEME_SELECT', handleFavoriteMemeSelect);
|
||||
return ComponentBus.subscribe('FAVORITE_MEME_SELECT', handleFavoriteMemeSelect);
|
||||
}, [appendText, canSendFavoriteMemeId, sendOptimisticMessage, enabled]);
|
||||
useEffect(() => {
|
||||
const handleInsertMention = (payload?: unknown) => {
|
||||
@@ -184,6 +184,6 @@ export const useTextareaExpressionHandlers = ({
|
||||
selectionStart: newText.length,
|
||||
});
|
||||
};
|
||||
return ComponentDispatch.subscribe('INSERT_MENTION', handleInsertMention);
|
||||
return ComponentBus.subscribe('INSERT_MENTION', handleInsertMention);
|
||||
}, [insertSegment, previousValueRef, setValue, textareaRef, segmentManagerRef, prepareTextChange, enabled]);
|
||||
};
|
||||
@@ -5,7 +5,7 @@ import ExpressionPicker from '@app/features/emoji/state/ExpressionPicker';
|
||||
import type {FlatEmoji} from '@app/features/emoji/types/EmojiTypes';
|
||||
import type {ExpressionPickerTabType} from '@app/features/expressions/components/popouts/ExpressionPickerPopout';
|
||||
import {ExpressionPickerPopout} from '@app/features/expressions/components/popouts/ExpressionPickerPopout';
|
||||
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 {openPopout} from '@app/features/ui/popover/PopoverPopout';
|
||||
import MobileLayout from '@app/features/ui/state/MobileLayout';
|
||||
@@ -155,7 +155,7 @@ export const useTextareaExpressionPicker = ({
|
||||
enabled,
|
||||
]);
|
||||
useEffect(() => {
|
||||
const unsubscribe = ComponentDispatch.subscribe('EXPRESSION_PICKER_TAB_TOGGLE', (payload?: unknown) => {
|
||||
const unsubscribe = ComponentBus.subscribe('EXPRESSION_PICKER_TAB_TOGGLE', (payload?: unknown) => {
|
||||
const data = payload as {channelId?: string; tab?: ExpressionPickerTabType} | undefined;
|
||||
if (!enabled) return;
|
||||
if (!data || data.channelId !== channelId || !data.tab) return;
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {Message} from '@app/features/messaging/models/MessagingMessage';
|
||||
import MessageEdit from '@app/features/messaging/state/MessageEdit';
|
||||
import MessageFocus from '@app/features/messaging/state/MessageFocus';
|
||||
import {insertTextAtCursor} from '@app/features/messaging/utils/TextInputEditUtils';
|
||||
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';
|
||||
@@ -138,7 +138,7 @@ export const useTextareaKeyboard = ({
|
||||
MessageCommands.stopReply(channelId);
|
||||
} else {
|
||||
event.preventDefault();
|
||||
ComponentDispatch.dispatch('ESCAPE_PRESSED');
|
||||
ComponentBus.dispatch('ESCAPE_PRESSED');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -154,7 +154,7 @@ export const useTextareaKeyboard = ({
|
||||
}
|
||||
if (KeyboardMode.keyboardModeEnabled) {
|
||||
event.preventDefault();
|
||||
ComponentDispatch.dispatch('FOCUS_BOTTOMMOST_MESSAGE', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_BOTTOMMOST_MESSAGE', {channelId});
|
||||
return;
|
||||
}
|
||||
const message = getLastEditableMessage();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// 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 function focusChannelTextareaAfterNavigation(channelId: string): void {
|
||||
const requestFocus = () => {
|
||||
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
ComponentBus.dispatch('FOCUS_TEXTAREA', {channelId});
|
||||
};
|
||||
window.requestAnimationFrame(requestFocus);
|
||||
window.setTimeout(requestFocus, 300);
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as InviteCommands from '@app/features/invite/commands/InviteCommands';
|
||||
import {setPathQueryParams} from '@app/features/messaging/utils/MessagingUrlUtils';
|
||||
import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
|
||||
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 * as ModalCommands from '@app/features/ui/commands/ModalCommands';
|
||||
import {APP_PROTOCOL_SCHEME, isAppProtocolUrl} from '@app/features/ui/utils/AppProtocol';
|
||||
import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';
|
||||
@@ -128,7 +128,7 @@ function openUserSettingsDeepLink(target: UserSettingsDeepLinkTarget): void {
|
||||
}),
|
||||
),
|
||||
);
|
||||
ComponentDispatch.safeDispatch('USER_SETTINGS_TAB_SELECT', {tab: target.tab, section: target.section});
|
||||
ComponentBus.dispatchOrBuffer('USER_SETTINGS_TAB_SELECT', {tab: target.tab, section: target.section});
|
||||
}
|
||||
|
||||
const navigateForTarget = (target: DeepLinkTarget) => {
|
||||
|
||||
@@ -29,7 +29,7 @@ export type ComponentActionType =
|
||||
| 'MESSAGE_SENT'
|
||||
| 'OPEN_MEMES_TAB'
|
||||
| 'POPOUT_CLOSE'
|
||||
| 'SCROLLTO_PRESENT'
|
||||
| 'SCROLL_TO_PRESENT'
|
||||
| 'SCROLL_PAGE_DOWN'
|
||||
| 'SCROLL_PAGE_UP'
|
||||
| 'SOUNDBOARD_TOGGLE'
|
||||
@@ -39,20 +39,20 @@ export type ComponentActionType =
|
||||
| 'TEXTAREA_DISMISS_AFFORDANCE'
|
||||
| 'TEXTAREA_UPLOAD_FILE'
|
||||
| 'USER_SETTINGS_TAB_SELECT';
|
||||
type ComponentDispatchEvents = {
|
||||
type ComponentBusEvents = {
|
||||
[K in ComponentActionType]: (...args: Array<unknown>) => unknown;
|
||||
};
|
||||
|
||||
class Dispatch extends EventEmitter<ComponentDispatchEvents> {
|
||||
private _savedDispatches: Partial<Record<ComponentActionType, Array<unknown>>> = {};
|
||||
private logger = new Logger('ComponentDispatch');
|
||||
class Dispatch extends EventEmitter<ComponentBusEvents> {
|
||||
private bufferedDispatches: Partial<Record<ComponentActionType, Array<unknown>>> = {};
|
||||
private logger = new Logger('ComponentBus');
|
||||
|
||||
safeDispatch(type: ComponentActionType, args?: unknown) {
|
||||
dispatchOrBuffer(type: ComponentActionType, args?: unknown) {
|
||||
if (!this.hasSubscribers(type)) {
|
||||
if (!this._savedDispatches[type]) {
|
||||
this._savedDispatches[type] = [];
|
||||
if (!this.bufferedDispatches[type]) {
|
||||
this.bufferedDispatches[type] = [];
|
||||
}
|
||||
this._savedDispatches[type].push(args);
|
||||
this.bufferedDispatches[type].push(args);
|
||||
return;
|
||||
}
|
||||
this.dispatch(type, args);
|
||||
@@ -62,7 +62,7 @@ class Dispatch extends EventEmitter<ComponentDispatchEvents> {
|
||||
this.emit(type, args);
|
||||
}
|
||||
|
||||
dispatchToLastSubscribed(type: ComponentActionType, args?: unknown) {
|
||||
dispatchToNewestSubscriber(type: ComponentActionType, args?: unknown) {
|
||||
const listeners = this.listeners(type);
|
||||
if (listeners.length > 0) {
|
||||
listeners[listeners.length - 1](args);
|
||||
@@ -90,24 +90,24 @@ class Dispatch extends EventEmitter<ComponentDispatchEvents> {
|
||||
return this.listenerCount(type) > 0;
|
||||
}
|
||||
|
||||
private _checkSavedDispatches(type: ComponentActionType) {
|
||||
if (this._savedDispatches[type]) {
|
||||
for (const args of this._savedDispatches[type]) {
|
||||
private flushBufferedDispatches(type: ComponentActionType) {
|
||||
if (this.bufferedDispatches[type]) {
|
||||
for (const args of this.bufferedDispatches[type]) {
|
||||
this.dispatch(type, args);
|
||||
}
|
||||
delete this._savedDispatches[type];
|
||||
delete this.bufferedDispatches[type];
|
||||
}
|
||||
}
|
||||
|
||||
subscribe(type: ComponentActionType, callback: (...args: Array<unknown>) => void): () => void {
|
||||
if (this.listeners(type).includes(callback)) {
|
||||
this.logger.warn('ComponentDispatch.subscribe: Attempting to add a duplicate listener', type);
|
||||
this.logger.warn('Ignoring duplicate subscriber for component action', type);
|
||||
return () => {
|
||||
this.unsubscribe(type, callback);
|
||||
};
|
||||
}
|
||||
this.on(type, callback);
|
||||
this._checkSavedDispatches(type);
|
||||
this.flushBufferedDispatches(type);
|
||||
return () => {
|
||||
this.unsubscribe(type, callback);
|
||||
};
|
||||
@@ -115,7 +115,7 @@ class Dispatch extends EventEmitter<ComponentDispatchEvents> {
|
||||
|
||||
subscribeOnce(type: ComponentActionType, callback: (...args: Array<unknown>) => void): () => void {
|
||||
this.once(type, callback);
|
||||
this._checkSavedDispatches(type);
|
||||
this.flushBufferedDispatches(type);
|
||||
return () => {
|
||||
this.unsubscribe(type, callback);
|
||||
};
|
||||
@@ -130,4 +130,4 @@ class Dispatch extends EventEmitter<ComponentDispatchEvents> {
|
||||
}
|
||||
}
|
||||
|
||||
export const ComponentDispatch = new Dispatch();
|
||||
export const ComponentBus = new Dispatch();
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands';
|
||||
import {
|
||||
consumeCompletedPremiumCheckoutReturnIntent,
|
||||
@@ -53,7 +53,7 @@ export const PremiumCheckoutReturnWatcher = observer(() => {
|
||||
<UserSettingsModal initialTab="plutonium" data-flx="premium.checkout-return-watcher.user-settings-modal" />
|
||||
)),
|
||||
);
|
||||
ComponentDispatch.safeDispatch('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'});
|
||||
ComponentBus.dispatchOrBuffer('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'});
|
||||
}, [isPremium, currentUserId, showPremiumFeatures]);
|
||||
return null;
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import styles from '@app/features/streamer_mode/components/StreamerModeGate.module.css';
|
||||
import {Button} from '@app/features/ui/button/Button';
|
||||
import {msg} from '@lingui/core/macro';
|
||||
@@ -28,7 +28,7 @@ const GO_TO_STREAMER_MODE_SETTINGS_DESCRIPTOR = msg({
|
||||
export const StreamerModeGate: React.FC = () => {
|
||||
const {i18n} = useLingui();
|
||||
const goToStreamerModeSettings = () => {
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'appearance', section: 'streamer-mode'});
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'appearance', section: 'streamer-mode'});
|
||||
};
|
||||
return (
|
||||
<div className={styles.screen} data-flx="streamer-mode.gate.screen">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import {MentionUserIcon} from '@app/features/ui/action_menu/ContextMenuIcons';
|
||||
import {MenuItem} from '@app/features/ui/action_menu/MenuItem';
|
||||
import type {User} from '@app/features/user/models/User';
|
||||
@@ -24,7 +24,7 @@ export const MentionUserMenuItem: React.FC<MentionUserMenuItemProps> = observer(
|
||||
const {i18n} = useLingui();
|
||||
const handleMentionUser = useCallback(() => {
|
||||
onClose();
|
||||
ComponentDispatch.dispatch('INSERT_MENTION', {userId: user.id});
|
||||
ComponentBus.dispatch('INSERT_MENTION', {userId: user.id});
|
||||
}, [user.id, onClose]);
|
||||
return (
|
||||
<MenuItem
|
||||
|
||||
@@ -43,7 +43,7 @@ import {useRoleHierarchy} from '@app/features/permissions/hooks/useRoleHierarchy
|
||||
import Permission from '@app/features/permissions/state/Permission';
|
||||
import * as PermissionUtils from '@app/features/permissions/utils/PermissionUtils';
|
||||
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 {ChangeFriendNicknameModal} from '@app/features/relationship/components/modals/ChangeFriendNicknameModal';
|
||||
import Relationships from '@app/features/relationship/state/Relationships';
|
||||
import * as RelationshipActionUtils from '@app/features/relationship/utils/RelationshipActionUtils';
|
||||
@@ -601,7 +601,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt
|
||||
label: i18n._(MENTION_DESCRIPTOR),
|
||||
onClick: () => {
|
||||
onClose();
|
||||
ComponentDispatch.dispatch('INSERT_MENTION', {userId: user.id});
|
||||
ComponentBus.dispatch('INSERT_MENTION', {userId: user.id});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {useMergeRefs} from '@app/features/app/hooks/useMergeRefs';
|
||||
import {isKeyboardActivationKey} from '@app/features/input/utils/KeyboardUtils';
|
||||
import type {ComponentActionType} from '@app/features/platform/utils/ComponentBus';
|
||||
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 {
|
||||
type PopoutAnimationType,
|
||||
@@ -373,8 +373,8 @@ export const Popout = React.forwardRef<HTMLElement, PopoutProps>((props, ref) =>
|
||||
useEffect(() => {
|
||||
if (!props.subscribeTo) return;
|
||||
const handler = () => toggle();
|
||||
ComponentDispatch.subscribe(props.subscribeTo, handler);
|
||||
return () => ComponentDispatch.unsubscribe(props.subscribeTo!, handler);
|
||||
ComponentBus.subscribe(props.subscribeTo, handler);
|
||||
return () => ComponentBus.unsubscribe(props.subscribeTo!, handler);
|
||||
}, [props.subscribeTo, toggle]);
|
||||
const childToRender =
|
||||
(props.children as React.ReactNode) || (!props.closeOnChildrenUnmount ? state.lastValidChildren : null);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {MobileSettingsView} from '@app/features/app/components/dialogs/component
|
||||
import * as Modal from '@app/features/app/components/dialogs/Modal';
|
||||
import {SettingsModalContainer} from '@app/features/app/components/dialogs/shared/SettingsModalLayout';
|
||||
import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
|
||||
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 * as UnsavedChangesCommands from '@app/features/ui/commands/UnsavedChangesCommands';
|
||||
import MobileLayout from '@app/features/ui/state/MobileLayout';
|
||||
@@ -141,7 +141,7 @@ export const UserSettingsModal: React.FC<UserSettingsModalProps> = observer(
|
||||
}
|
||||
}, [resolveVisibleTab, selectedTab]);
|
||||
useEffect(() => {
|
||||
const unsubscribe = ComponentDispatch.subscribe('USER_SETTINGS_TAB_SELECT', (args?: unknown) => {
|
||||
const unsubscribe = ComponentBus.subscribe('USER_SETTINGS_TAB_SELECT', (args?: unknown) => {
|
||||
const {tab, section} = (args ?? {}) as {tab?: string; section?: string};
|
||||
if (tab && typeof tab === 'string') {
|
||||
const accountSection =
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {SettingsSearch} from '@app/features/app/components/dialogs/components/SettingsSearch';
|
||||
import {SettingsHeadingLinkButton} from '@app/features/app/components/dialogs/shared/SettingsHeadingLinkButton';
|
||||
import {SettingsTabContainer, SettingsTabContent} from '@app/features/app/components/dialogs/shared/SettingsTabLayout';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import styles from '@app/features/user/components/modals/tabs/AdvancedSettingsTab.module.css';
|
||||
import {AdvancedSettingRow} from '@app/features/user/components/modals/tabs/advanced_settings_tab/AdvancedSettingRow';
|
||||
import {
|
||||
@@ -80,7 +80,7 @@ export const AdvancedSettingsTab = observer(() => {
|
||||
const groups = useMemo(() => groupAdvancedItemsByCategory(remainingItems, tagLabels), [remainingItems, tagLabels]);
|
||||
const showGroupLinks = groups.length > 1;
|
||||
const handleOpenSource = useCallback((item: SearchableSettingItem) => {
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {
|
||||
tab: getAdvancedSettingSourceTab(item),
|
||||
section: getAdvancedSettingSourceSection(item),
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import {EditPackModal} from '@app/features/expressions/components/modals/EditPac
|
||||
import {PackInviteModal} from '@app/features/expressions/components/modals/PackInviteModal';
|
||||
import Packs from '@app/features/expressions/state/ExpressionsPacks';
|
||||
import {NO_DESCRIPTION_PROVIDED_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
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 * as ModalCommands from '@app/features/ui/commands/ModalCommands';
|
||||
import {modal} from '@app/features/ui/commands/ModalCommands';
|
||||
@@ -189,7 +189,7 @@ const ExpressionPacksTab: React.FC = observer(() => {
|
||||
actions={[
|
||||
{
|
||||
text: i18n._(LEARN_ABOUT_PREMIUM_DESCRIPTOR, {premiumProductName: PREMIUM_PRODUCT_NAME}),
|
||||
onClick: () => ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'}),
|
||||
onClick: () => ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'}),
|
||||
variant: 'primary',
|
||||
fitContent: true,
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
TRY_AGAIN_IN_A_MOMENT_DESCRIPTOR,
|
||||
} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
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 {remFromPx} from '@app/features/theme/layout/RemFromPx';
|
||||
import {Button} from '@app/features/ui/button/Button';
|
||||
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
|
||||
@@ -445,7 +445,7 @@ const GiftInventoryTab: React.FC = observer(() => {
|
||||
actions={[
|
||||
{
|
||||
text: i18n._(GO_TO_PREMIUM_DESCRIPTOR, {premiumProductName: PREMIUM_PRODUCT_NAME}),
|
||||
onClick: () => ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'}),
|
||||
onClick: () => ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'plutonium'}),
|
||||
variant: 'primary',
|
||||
fitContent: true,
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
|
||||
import {LimitResolver} from '@app/features/app/utils/LimitResolverAdapter';
|
||||
import {isLimitToggleEnabled} from '@app/features/app/utils/LimitUtils';
|
||||
import {GET_PREMIUM_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import * as PremiumModalCommands from '@app/features/premium/commands/PremiumModalCommands';
|
||||
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
|
||||
import {Button} from '@app/features/ui/button/Button';
|
||||
@@ -198,7 +198,7 @@ export const VideoTab: React.FC<VideoTabProps> = observer(
|
||||
VoiceSettingsCommands.update({videoFrameRate: value, streamingMode: 'custom'});
|
||||
}, []);
|
||||
const handleOpenAdvancedVideoSettings = useCallback(() => {
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {
|
||||
tab: 'advanced_settings',
|
||||
section: getAdvancedSettingsCategorySectionId('media'),
|
||||
});
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import {
|
||||
getCachedDesktopTroubleshootingSettings,
|
||||
getDesktopTroubleshootingSettings,
|
||||
} from '@app/features/devtools/utils/DesktopTroubleshootingUtils';
|
||||
import {ComponentDispatch} from '@app/features/platform/utils/ComponentBus';
|
||||
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
|
||||
import type {RadioOption} from '@app/features/ui/radio_group/RadioGroup';
|
||||
import {RadioGroup} from '@app/features/ui/radio_group/RadioGroup';
|
||||
import {isDesktop} from '@app/features/ui/utils/NativeUtils';
|
||||
@@ -114,7 +114,7 @@ export const CodecSelectorSection = observer(() => {
|
||||
}, []);
|
||||
const openAdvancedSettingsTab = useCallback((event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
event.preventDefault();
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'advanced_settings'});
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'advanced_settings'});
|
||||
}, []);
|
||||
const hardwareAccelOff = isDesktopClient && hardwareAccelDisabled === true;
|
||||
return (
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as AccessibilityCommands from '@app/features/accessibility/commands/AccessibilityCommands';
|
||||
import Accessibility from '@app/features/accessibility/state/Accessibility';
|
||||
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 {Switch} from '@app/features/ui/components/form/FormSwitch';
|
||||
import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
|
||||
@@ -64,7 +64,7 @@ export const TextToSpeech = observer(() => {
|
||||
AccessibilityCommands.update({enableTTSCommand: value});
|
||||
}, []);
|
||||
const handleAccessibilityLinkClick = useCallback(() => {
|
||||
ComponentDispatch.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'accessibility', section: 'tts'});
|
||||
ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'accessibility', section: 'tts'});
|
||||
}, []);
|
||||
const ttsNotificationMode = Notification.getTTSNotificationMode();
|
||||
const ttsNotificationOptions: Array<RadioOption<TTSNotificationMode>> = [
|
||||
|
||||
Reference in new issue
Block a user