stories: fix module cycle

This commit is contained in:
Jamie Kyle 2022-10-26 18:47:45 -07:00 committed by GitHub
parent 42362a2772
commit 32a8a0161d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 23 deletions

View file

@ -11,6 +11,13 @@ import type { ConversationType } from '../state/ducks/conversations';
import type { LocalizerType } from '../types/Util'; import type { LocalizerType } from '../types/Util';
import type { PreferredBadgeSelectorType } from '../state/selectors/badges'; import type { PreferredBadgeSelectorType } from '../state/selectors/badges';
import type { PropsType as StoriesSettingsModalPropsType } from './StoriesSettingsModal'; import type { PropsType as StoriesSettingsModalPropsType } from './StoriesSettingsModal';
import {
getListViewers,
DistributionListSettingsModal,
EditDistributionListModal,
EditMyStoriesPrivacy,
Page as StoriesSettingsPage,
} from './StoriesSettingsModal';
import type { StoryDistributionListWithMembersDataType } from '../types/Stories'; import type { StoryDistributionListWithMembersDataType } from '../types/Stories';
import type { UUIDStringType } from '../types/UUID'; import type { UUIDStringType } from '../types/UUID';
import { Alert } from './Alert'; import { Alert } from './Alert';
@ -19,12 +26,7 @@ import { Button, ButtonSize, ButtonVariant } from './Button';
import { Checkbox } from './Checkbox'; import { Checkbox } from './Checkbox';
import { ConfirmationDialog } from './ConfirmationDialog'; import { ConfirmationDialog } from './ConfirmationDialog';
import { ContextMenu } from './ContextMenu'; import { ContextMenu } from './ContextMenu';
import {
DistributionListSettingsModal,
EditDistributionListModal,
EditMyStoriesPrivacy,
Page as StoriesSettingsPage,
} from './StoriesSettingsModal';
import { MY_STORIES_ID, getStoryDistributionListName } from '../types/Stories'; import { MY_STORIES_ID, getStoryDistributionListName } from '../types/Stories';
import type { RenderModalPage, ModalPropsType } from './Modal'; import type { RenderModalPage, ModalPropsType } from './Modal';
import { PagedModal, ModalPage } from './Modal'; import { PagedModal, ModalPage } from './Modal';
@ -113,22 +115,6 @@ function getKeyForMyStoryType(list: StoryDistributionListWithMembersDataType) {
return 'StoriesSettings__mine__all--label'; return 'StoriesSettings__mine__all--label';
} }
export function getListViewers(
list: StoryDistributionListWithMembersDataType,
i18n: LocalizerType,
signalConnections: Array<ConversationType>
): string {
let memberCount = list.members.length;
if (list.id === MY_STORIES_ID && list.isBlockList) {
memberCount = list.isBlockList
? signalConnections.length - list.members.length
: signalConnections.length;
}
return i18n('icu:StoriesSettings__viewers', { count: memberCount });
}
export const SendStoryModal = ({ export const SendStoryModal = ({
draftAttachment, draftAttachment,
candidateConversations, candidateConversations,

View file

@ -37,7 +37,6 @@ import {
asyncShouldNeverBeCalled, asyncShouldNeverBeCalled,
} from '../util/shouldNeverBeCalled'; } from '../util/shouldNeverBeCalled';
import { useConfirmDiscard } from '../hooks/useConfirmDiscard'; import { useConfirmDiscard } from '../hooks/useConfirmDiscard';
import { getListViewers } from './SendStoryModal';
export type PropsType = { export type PropsType = {
candidateConversations: Array<ConversationType>; candidateConversations: Array<ConversationType>;
@ -94,6 +93,22 @@ const modalCommonProps: Pick<ModalPropsType, 'hasXButton' | 'moduleClassName'> =
moduleClassName: 'StoriesSettingsModal__modal', moduleClassName: 'StoriesSettingsModal__modal',
}; };
export function getListViewers(
list: StoryDistributionListWithMembersDataType,
i18n: LocalizerType,
signalConnections: Array<ConversationType>
): string {
let memberCount = list.members.length;
if (list.id === MY_STORIES_ID && list.isBlockList) {
memberCount = list.isBlockList
? signalConnections.length - list.members.length
: signalConnections.length;
}
return i18n('icu:StoriesSettings__viewers', { count: memberCount });
}
type DistributionListItemProps = { type DistributionListItemProps = {
i18n: LocalizerType; i18n: LocalizerType;
distributionList: StoryDistributionListWithMembersDataType; distributionList: StoryDistributionListWithMembersDataType;