mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +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;
|
||||
|
||||
Reference in new issue
Block a user