Skip to content

Commit a7a0dc6

Browse files
committed
fix: import cycles issue for polls and translations
1 parent 17378ca commit a7a0dc6

File tree

13 files changed

+63
-56
lines changed

13 files changed

+63
-56
lines changed

package/src/components/Poll/CreatePollContent.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ import {
2222
} from '../../contexts';
2323
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
2424
import { useStateStore } from '../../hooks/useStateStore';
25+
import { POLL_OPTION_HEIGHT } from '../../utils/constants';
2526

2627
const pollComposerStateSelector = (state: PollComposerState) => ({
2728
options: state.data.options,
2829
});
2930

30-
export const POLL_OPTION_HEIGHT = 71;
31-
3231
export const CreatePollContent = () => {
3332
const [isAnonymousPoll, setIsAnonymousPoll] = useState<boolean>(false);
3433
const [allowUserSuggestedOptions, setAllowUserSuggestedOptions] = useState<boolean>(false);

package/src/components/Poll/components/CreatePollOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { useCreatePollContentContext, useTheme, useTranslationContext } from '..
2020
import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer';
2121
import { useStateStore } from '../../../hooks/useStateStore';
2222
import { DragHandle } from '../../../icons';
23-
import { POLL_OPTION_HEIGHT } from '../CreatePollContent';
23+
import { POLL_OPTION_HEIGHT } from '../../../utils/constants';
2424

2525
export type CurrentOptionPositionsCache = {
2626
inverseIndexCache: {

package/src/contexts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export * from './themeContext/utils/theme';
2222
export * from './threadContext/ThreadContext';
2323
export * from './threadsContext/ThreadsContext';
2424
export * from './threadsContext/ThreadListItemContext';
25-
export * from './translationContext/TranslationContext';
25+
export * from './translationContext';
2626
export * from './typingContext/TypingContext';
2727
export * from './utils/getDisplayName';
2828
export * from './pollContext';

package/src/contexts/translationContext/TranslationContext.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,15 @@ import React, { useContext } from 'react';
22

33
import Dayjs from 'dayjs';
44

5-
import type { TFunction } from 'i18next';
6-
import type { Moment } from 'moment-timezone';
7-
85
import type { TranslationLanguages } from 'stream-chat';
96

7+
import { TranslatorFunctions } from './types';
8+
109
import { defaultTranslatorFunction } from '../../utils/i18n/Streami18n';
1110
import { isTestEnvironment } from '../utils/isTestEnvironment';
1211

1312
export const DEFAULT_USER_LANGUAGE: TranslationLanguages = 'en';
1413

15-
export const isDayOrMoment = (output: TDateTimeParserOutput): output is Dayjs.Dayjs | Moment =>
16-
(output as Dayjs.Dayjs | Moment).isSame != null;
17-
18-
export type TDateTimeParserInput = string | number | Date;
19-
20-
export type TDateTimeParserOutput = string | number | Date | Dayjs.Dayjs | Moment;
21-
22-
export type TDateTimeParser = (input?: TDateTimeParserInput) => TDateTimeParserOutput;
23-
24-
export type TranslatorFunctions = {
25-
t: TFunction;
26-
tDateTimeParser: TDateTimeParser;
27-
};
28-
2914
export type TranslationContextValue = TranslatorFunctions & {
3015
userLanguage: TranslationLanguages;
3116
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './TranslationContext';
2+
export * from './types';
3+
export * from './isDayOrMoment';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Dayjs from 'dayjs';
2+
3+
import type { Moment } from 'moment-timezone';
4+
5+
import { TDateTimeParserOutput } from './types';
6+
7+
export const isDayOrMoment = (output: TDateTimeParserOutput): output is Dayjs.Dayjs | Moment =>
8+
(output as Dayjs.Dayjs | Moment).isSame != null;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Dayjs from 'dayjs';
2+
3+
import type { TFunction } from 'i18next';
4+
import type { Moment } from 'moment-timezone';
5+
6+
export type TDateTimeParserInput = string | number | Date;
7+
8+
export type TDateTimeParserOutput = string | number | Date | Dayjs.Dayjs | Moment;
9+
10+
export type TDateTimeParser = (input?: TDateTimeParserInput) => TDateTimeParserOutput;
11+
12+
export type TranslatorFunctions = {
13+
t: TFunction;
14+
tDateTimeParser: TDateTimeParser;
15+
};

package/src/hooks/useStreami18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Dayjs from 'dayjs';
44

55
import { useIsMountedRef } from './useIsMountedRef';
66

7-
import type { TranslatorFunctions } from '../contexts/translationContext/TranslationContext';
7+
import type { TranslatorFunctions } from '../contexts/translationContext/types';
88
import { defaultTranslatorFunction, Streami18n } from '../utils/i18n/Streami18n';
99

1010
export const useStreami18n = (i18nInstance?: Streami18n) => {

package/src/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const defaultMentionAllAppUsersQuery = {
44
options: {},
55
sort: {},
66
};
7+
export const POLL_OPTION_HEIGHT = 71;

package/src/utils/i18n/Streami18n.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import i18n, { FallbackLng, TFunction } from 'i18next';
1010
import type momentTimezone from 'moment-timezone';
1111

1212
import { calendarFormats } from './calendarFormats';
13-
import {
14-
CustomFormatters,
15-
PredefinedFormatters,
16-
predefinedFormatters,
17-
} from './predefinedFormatters';
13+
import { predefinedFormatters } from './predefinedFormatters';
14+
import { CustomFormatters, PredefinedFormatters } from './types';
1815

19-
import type { TDateTimeParser } from '../../contexts/translationContext/TranslationContext';
16+
import type { TDateTimeParser } from '../../contexts/translationContext/types';
2017
import enTranslations from '../../i18n/en.json';
2118
import esTranslations from '../../i18n/es.json';
2219
import frTranslations from '../../i18n/fr.json';

0 commit comments

Comments
 (0)