refactor(imports): replace relative imports with path aliases (#2741)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-13 20:18:22 +02:00
1 parent a59b80ce11
commit 84dcf6b8a8
1834 files changed
+11601 -10725

No files matched your search

@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {getUnreadDividerBeforeMessageId} from '@app/features/channel/components/ChannelMessageStreamUtils';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import type {ChannelStreamItem} from '@app/features/messaging/utils/MessageGroupingUtils';
import {bench, describe} from 'vitest';
import {getUnreadDividerBeforeMessageId} from './ChannelMessageStreamUtils';
const GROUP_ITEMS = Array.from(
{length: 100},
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {getUnreadDividerBeforeMessageId} from '@app/features/channel/components/ChannelMessageStreamUtils';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import type {ChannelStreamItem} from '@app/features/messaging/utils/MessageGroupingUtils';
import {describe, expect, it} from 'vitest';
import {getUnreadDividerBeforeMessageId} from './ChannelMessageStreamUtils';
function item(messageId: string, showUnreadDividerBefore = false): ChannelStreamItem {
return {
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {splitMediaAndFileAttachments} from '@app/features/channel/components/MessageAttachmentUtils';
import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';
import {bench, describe} from 'vitest';
import {splitMediaAndFileAttachments} from './MessageAttachmentUtils';
const CONTENT_TYPES = [
'image/png',
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {splitMediaAndFileAttachments} from '@app/features/channel/components/MessageAttachmentUtils';
import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';
import {describe, expect, it} from 'vitest';
import {splitMediaAndFileAttachments} from './MessageAttachmentUtils';
const baseAttachment = {
id: 'attachment-1',
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import {describe, expect, it} from 'vitest';
import {
buildSearchResultGroups,
buildSearchResultGroupsByMessageId,
countSearchResultChannels,
} from './SearchResultGrouping';
} from '@app/features/channel/components/SearchResultGrouping';
import type {Message} from '@app/features/messaging/models/MessagingMessage';
import {describe, expect, it} from 'vitest';
const message = (id: string, channelId: string): Message => ({id, channelId}) as Message;
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type {SearchMachineState} from '@app/features/channel/components/SearchStateMachine';
import {Channel} from '@app/features/channel/models/Channel';
import {Message} from '@app/features/messaging/models/MessagingMessage';
import type {SearchSegment} from '@app/features/search/utils/SearchSegmentManager';
import type {SearchMachineState} from './SearchStateMachine';
export type {
SearchMachineEvent,
@@ -14,7 +14,7 @@ export type {
SearchMachineStateIndexing,
SearchMachineStateLoading,
SearchMachineStateSuccess,
} from './SearchStateMachine';
} from '@app/features/channel/components/SearchStateMachine';
export const cloneMessageRecord = (message: Message): Message => {
return new Message(message.toJSON(), {skipUserCache: true});
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {resolveSearchScope} from '@app/features/channel/components/SearchScopeResolution';
import type {MessageSearchScope} from '@app/features/search/utils/SearchUtils';
import {describe, expect, it} from 'vitest';
import {resolveSearchScope} from './SearchScopeResolution';
const GUILD_SCOPE_OPTIONS = new Set<MessageSearchScope>([
'current',
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {describe, expect, it} from 'vitest';
import {
createSearchMachineSnapshot,
selectSearchMachineState,
transitionSearchMachineSnapshot,
} from './SearchStateMachine';
} from '@app/features/channel/components/SearchStateMachine';
import {describe, expect, it} from 'vitest';
describe('SearchStateMachine', () => {
it('starts idle and transitions through loading to success', () => {
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {showChannelErrorModal} from '@app/features/channel/components/alerts/ChannelErrorModalUtils';
import {
PREMIUM_TYPE_DESCRIPTOR,
UNREAD_GIFT_COUNT_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels';
import {
DeveloperOptionCheckbox,
DeveloperOptionRadioItems,
@@ -9,6 +13,8 @@ import {
translateDescriptor,
USE_ACTUAL_VALUE_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {getPremiumTypeOptions} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets';
import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import {
applyPremiumScenarioOption,
PREMIUM_SCENARIO_OPTIONS,
@@ -28,9 +34,6 @@ import {msg, plural} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {PREMIUM_TYPE_DESCRIPTOR, UNREAD_GIFT_COUNT_DESCRIPTOR} from './DeveloperOptionLabels';
import {getPremiumTypeOptions} from './OptionPresets';
import {updateOption} from './ResetOptions';
const logger = new Logger('DeveloperToolsContextMenu/AccountPremiumMenu');
const ACCOUNT_STATE_DESCRIPTOR = msg({
@@ -13,13 +13,20 @@ import {
USE_ACTUAL_VALUE_DESCRIPTOR,
USE_DEFAULT_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {formatDurationMs} from '@app/features/channel/components/channel_header_components/developer_tools/FormatHelpers';
import {
getPremiumTypeLabel,
LIFETIME_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets';
import {
DEVELOPER_OPTION_KEYS,
isDeveloperOptionAtDefault,
resetDeveloperOption,
} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions';
import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
import type {I18n, MessageDescriptor} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {formatDurationMs} from './FormatHelpers';
import {getPremiumTypeLabel, LIFETIME_DESCRIPTOR} from './OptionPresets';
import {DEVELOPER_OPTION_KEYS, isDeveloperOptionAtDefault, resetDeveloperOption} from './ResetOptions';
const ACTIVE_DEVELOPER_OPTION_KEYS = DEVELOPER_OPTION_KEYS.filter((key) => key !== 'premiumScenarioOverride');
export const ATTACHMENT_MOCKS_DESCRIPTOR = msg({
@@ -7,6 +7,7 @@ import {
type RadioMenuOption,
translateDescriptor,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions';
import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands';
@@ -22,7 +23,6 @@ import {useLingui} from '@lingui/react/macro';
import {CrownIcon} from '@phosphor-icons/react';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {updateOption} from './ResetOptions';
interface DeveloperOptionCheckboxProps<K extends keyof DeveloperOptionsState> {
optionKey: K;
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {translateDescriptor} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import {getToggleGroups, type ToggleGroup} from '@app/features/devtools/components/DeveloperOptionsToggleGroups';
import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions';
import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
@@ -13,7 +14,6 @@ import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {updateOption} from './ResetOptions';
const MENTION_CONTROLS_DESCRIPTOR = msg({
message: 'Mention controls',
@@ -7,6 +7,18 @@ import {
DeveloperOptionRadioItems,
DeveloperOptionRadioSubmenu,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents';
import {
getCountdownTimerOptions,
getGiftDurationOptions,
getMatureContentChannelGateOptions,
getMatureContentMediaGateOptions,
getRequiredActionModeOptions,
getRequiredActionPhoneStepOptions,
getRequiredActionResendOutcomeOptions,
getRequiredActionTabOptions,
getVerificationBarrierOptions,
} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets';
import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import * as DeveloperOptionsCommands from '@app/features/devtools/commands/DeveloperOptionsCommands';
import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
@@ -20,18 +32,6 @@ import {Trans, useLingui} from '@lingui/react/macro';
import {PhoneIcon, TrashIcon, UsersIcon} from '@phosphor-icons/react';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {
getCountdownTimerOptions,
getGiftDurationOptions,
getMatureContentChannelGateOptions,
getMatureContentMediaGateOptions,
getRequiredActionModeOptions,
getRequiredActionPhoneStepOptions,
getRequiredActionResendOutcomeOptions,
getRequiredActionTabOptions,
getVerificationBarrierOptions,
} from './OptionPresets';
import {updateOption} from './ResetOptions';
const VERIFICATION_MEMBERSHIP_BARRIERS_DESCRIPTOR = msg({
message: 'Verification & membership barriers',
@@ -1,5 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {
getNagbarActionItems,
NAGBAR_OVERRIDES_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/NagbarControls';
import {getNagbarControls, type NagbarControlDefinition} from '@app/features/devtools/components/NagbarControls';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
import {MenuItem} from '@app/features/ui/action_menu/MenuItem';
@@ -10,7 +14,6 @@ import {Trans, useLingui} from '@lingui/react/macro';
import {TrashIcon} from '@phosphor-icons/react';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {getNagbarActionItems, NAGBAR_OVERRIDES_DESCRIPTOR} from './NagbarControls';
const NagbarOverrideSubmenu: React.FC<{control: NagbarControlDefinition}> = observer(({control}) => {
const {i18n} = useLingui();
@@ -5,12 +5,15 @@ import {
type RadioMenuOption,
USE_ACTUAL_VALUE_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {
formatDurationMs,
NO_TIMER_DESCRIPTOR,
} from '@app/features/channel/components/channel_header_components/developer_tools/FormatHelpers';
import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions';
import {EMAIL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants';
import type {I18n} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {formatDurationMs, NO_TIMER_DESCRIPTOR} from './FormatHelpers';
export const SUBSCRIPTION_DESCRIPTOR = msg({
message: 'Subscription',
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {getActiveDeveloperOptionEntries} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels';
import {
ActiveOverrideMenuGroup,
BackendPremiumOverrideMenuGroup,
@@ -10,6 +11,8 @@ import {
humanizeDeveloperStateKey,
nonEmptyText,
} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared';
import {setNagbarUseActual} from '@app/features/channel/components/channel_header_components/developer_tools/NagbarControls';
import {resetAllDeveloperOptions} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions';
import {getNagbarControls} from '@app/features/devtools/components/NagbarControls';
import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
@@ -24,9 +27,6 @@ import {Trans, useLingui} from '@lingui/react/macro';
import {BellRingingIcon, TrashIcon, WarningCircleIcon} from '@phosphor-icons/react';
import {observer} from 'mobx-react-lite';
import type React from 'react';
import {getActiveDeveloperOptionEntries} from './DeveloperOptionLabels';
import {setNagbarUseActual} from './NagbarControls';
import {resetAllDeveloperOptions} from './ResetOptions';
const NO_ACTIVE_OVERRIDES_DESCRIPTOR = msg({
message: 'No active overrides',
@@ -1,9 +1,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {
buildCsvTableNode,
isCsvAttachment,
parseCsvRows,
} from '@app/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils';
import {TableAlignment} from '@app/features/messaging/utils/markdown/parser/Enums';
import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';
import {describe, expect, it} from 'vitest';
import {buildCsvTableNode, isCsvAttachment, parseCsvRows} from './CsvAttachmentPreviewUtils';
function attachmentFixture(fields: Partial<MessageAttachment>): MessageAttachment {
return fields as MessageAttachment;
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {describe, expect, it} from 'vitest';
import {
getEffectiveVideoLayoutDimensions,
hasDifferentAspectRatio,
isInlinePlayableVideoSize,
resolveVideoLayout,
} from './VideoDimensionUtils';
} from '@app/features/channel/components/embeds/media/VideoDimensionUtils';
import {describe, expect, it} from 'vitest';
describe('getEffectiveVideoLayoutDimensions', () => {
it('prefers decoded dimensions over declared upload dimensions', () => {
@@ -1,7 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {
type FavoriteGifEntry,
slimFavoriteGifEntry,
} from '@app/features/channel/components/pickers/gif/FavoriteGifTypes';
import {describe, expect, it} from 'vitest';
import {type FavoriteGifEntry, slimFavoriteGifEntry} from './FavoriteGifTypes';
function format(src: string, width: number) {
return {src, proxy_src: `https://media.test/external/sig/${src}`, width, height: Math.round(width * 0.84)};
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {buildGifPickerGridData} from '@app/features/channel/components/pickers/gif/GifPickerGridData';
import {bench, describe} from 'vitest';
import {buildGifPickerGridData} from './GifPickerGridData';
function gif(index: number, width = 200 + (index % 80), height = 120 + (index % 160)) {
return {
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type {FavoriteGifEntry} from '@app/features/channel/components/pickers/gif/FavoriteGifTypes';
import {buildGifPickerGridData} from '@app/features/channel/components/pickers/gif/GifPickerGridData';
import type {FavoriteAwareGif} from '@app/features/channel/components/pickers/gif/GifPickerTypes';
import {describe, expect, it} from 'vitest';
import type {FavoriteGifEntry} from './FavoriteGifTypes';
import {buildGifPickerGridData} from './GifPickerGridData';
import type {FavoriteAwareGif} from './GifPickerTypes';
function gif(id: string, width = 200, height = 120): FavoriteAwareGif {
return {
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import styles from '@app/features/channel/components/GifPicker.module.css';
import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout';
import {motion, useReducedMotion} from 'framer-motion';
import {useLayoutEffect, useMemo, useRef, useState} from 'react';
import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout';
interface SkeletonViewportSize {
width: number;
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout';
import {bench, describe} from 'vitest';
import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout';
const VIEWPORTS = [
{viewportWidth: 360, viewportHeight: 480},
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout';
import {describe, expect, it} from 'vitest';
import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout';
describe('buildGifPickerLoadingSkeletonLayout', () => {
it('lays out GIF-like placeholders with the same masonry constraints as the real grid', () => {
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {resolvesToVideo} from '@app/features/channel/components/pickers/gif/GifPickerMediaKind';
import {describe, expect, it} from 'vitest';
import {resolvesToVideo} from './GifPickerMediaKind';
const OPAQUE_PROXY_SRC =
'https://media.test/external/sig/v2/aHR0cHM6Ly9zdGF0aWMua2xpcHkuY29tL2lpLzhjLzZhL2E4LzVsU2U1SFBCLndlYm0';
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {bench, describe} from 'vitest';
import {
createGifPickerRequestId,
createGifPickerSnapshot,
selectGifPickerModel,
transitionGifPickerSnapshot,
} from './GifPickerStateMachine';
} from '@app/features/channel/components/pickers/gif/GifPickerStateMachine';
import {bench, describe} from 'vitest';
const SEARCH_TERMS = Array.from({length: 1_000}, (_, index) => `query-${index}`);
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {describe, expect, it} from 'vitest';
import {
createGifPickerRequestId,
createGifPickerSnapshot,
selectGifPickerModel,
transitionGifPickerSnapshot,
} from './GifPickerStateMachine';
} from '@app/features/channel/components/pickers/gif/GifPickerStateMachine';
import {describe, expect, it} from 'vitest';
describe('GifPickerStateMachine', () => {
it('starts on the featured surface without showing a loading state', () => {
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {describe, expect, it} from 'vitest';
import {
CHANNEL_SEARCH_INDEXING_INITIAL_POLL_INTERVAL_MS,
CHANNEL_SEARCH_INDEXING_MAX_POLL_INTERVAL_MS,
getChannelSearchIndexingPollInterval,
} from './ChannelSearchPolling';
} from '@app/features/channel/utils/ChannelSearchPolling';
import {describe, expect, it} from 'vitest';
describe('getChannelSearchIndexingPollInterval', () => {
it('starts with a short retry interval for newly indexing channels', () => {