Skip to content

Commit 4777891

Browse files
Some more type renames
1 parent 8bd2f18 commit 4777891

11 files changed

Lines changed: 30 additions & 31 deletions

File tree

src/components/Channel/Channel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type {
1818
ChannelStateResponseFields,
1919
DeleteMessageOptions,
2020
Event,
21-
EventAPIResponse,
2221
GiphyVersions,
2322
LocalMessage,
2423
MessageRequest,
@@ -112,7 +111,7 @@ export type ChannelProps = {
112111
doMarkReadRequest?: (
113112
channel: StreamChannel,
114113
setChannelUnreadUiState?: (state: ChannelUnreadUiState) => void,
115-
) => Promise<EventAPIResponse> | void;
114+
) => ReturnType<StreamChannel['markRead']> | void;
116115
/** Custom action handler to override the default `channel.sendMessage` request function (advanced usage only) */
117116
doSendMessageRequest?: (
118117
channel: StreamChannel,

src/components/Channel/__tests__/Channel.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fromPartial } from '@total-typescript/shoehorn';
22
import { nanoid } from 'nanoid';
33
import React, { useEffect } from 'react';
4-
import { ErrorFromResponse, SearchController } from 'stream-chat';
4+
import { SearchController, StreamAPIError } from 'stream-chat';
55
import type {
66
Channel as ChannelType,
77
LocalMessage,
@@ -2053,7 +2053,7 @@ describe('Channel', () => {
20532053
expect(msg.status).toBe('received');
20542054
});
20552055

2056-
it('should convert axios network errors to ErrorFromResponse when sending fails', async () => {
2056+
it('should convert axios network errors to StreamAPIError when sending fails', async () => {
20572057
const messageText = nanoid();
20582058
const messageId = nanoid();
20592059
const axiosNetworkError = Object.assign(new Error('Network Error'), {
@@ -2087,7 +2087,7 @@ describe('Channel', () => {
20872087
const failedMessage = channel.state.findMessage(messageId);
20882088
expect(failedMessage).toBeDefined();
20892089
expect(failedMessage.status).toBe('failed');
2090-
expect(failedMessage.error).toBeInstanceOf(ErrorFromResponse);
2090+
expect(failedMessage.error).toBeInstanceOf(StreamAPIError);
20912091
expect(failedMessage.error.message).toBe('Network Error');
20922092
expect(failedMessage.error.status).toBe(0);
20932093
expect(failedMessage.error.code).toBeNull();

src/components/ChannelList/hooks/useChannelMembersState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Channel, ChannelMemberResponse, EventTypes } from 'stream-chat';
1+
import type { Channel, ChannelMemberResponse, EventType } from 'stream-chat';
22
import { useSelectedChannelState } from './useSelectedChannelState';
33

44
const selector = (c: Channel) => c.state.members;
5-
const keys: EventTypes[] = [
5+
const keys: EventType[] = [
66
'member.updated',
77
'member.added',
88
'member.removed',

src/components/ChannelList/hooks/useChannelMembershipState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Channel, ChannelMemberResponse, EventTypes } from 'stream-chat';
1+
import type { Channel, ChannelMemberResponse, EventType } from 'stream-chat';
22
import { useSelectedChannelState } from './useSelectedChannelState';
33

44
const selector = (c: Channel) => c.state.membership;
5-
const keys: EventTypes[] = ['member.updated'];
5+
const keys: EventType[] = ['member.updated'];
66

77
export function useChannelMembershipState(channel: Channel): ChannelMemberResponse;
88
export function useChannelMembershipState(

src/components/ChannelList/hooks/useSelectedChannelState.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { useCallback } from 'react';
22
import { useSyncExternalStore } from 'use-sync-external-store/shim';
3-
import type { Channel, EventTypes } from 'stream-chat';
3+
import type { Channel, EventType } from 'stream-chat';
44

55
// eslint-disable-next-line @typescript-eslint/no-empty-function
66
const noop = () => {};
77

88
export function useSelectedChannelState<O>(_: {
99
channel: Channel;
1010
selector: (channel: Channel) => O;
11-
stateChangeEventKeys?: EventTypes[];
11+
stateChangeEventKeys?: EventType[];
1212
}): O;
1313
export function useSelectedChannelState<O>(_: {
1414
selector: (channel: Channel) => O;
1515
channel?: Channel | undefined;
16-
stateChangeEventKeys?: EventTypes[];
16+
stateChangeEventKeys?: EventType[];
1717
}): O | undefined;
1818
export function useSelectedChannelState<O>({
1919
channel,
@@ -22,7 +22,7 @@ export function useSelectedChannelState<O>({
2222
}: {
2323
selector: (channel: Channel) => O;
2424
channel?: Channel;
25-
stateChangeEventKeys?: EventTypes[];
25+
stateChangeEventKeys?: EventType[];
2626
}): O | undefined {
2727
const subscribe = useCallback(
2828
(onStoreChange: (value: O) => void) => {

src/components/MessageComposer/QuotedMessagePreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
type MessageResponse,
3030
type PollResponseData,
3131
type SharedLocationResponseData,
32-
type TranslationLanguages,
32+
type TranslationLanguage,
3333
type VoiceRecordingAttachment,
3434
} from 'stream-chat';
3535
import { useChannelStateContext } from '../../context/ChannelStateContext';
@@ -338,7 +338,7 @@ export const QuotedMessagePreviewUI = ({
338338

339339
const quotedMessageText = useMemo(
340340
() =>
341-
quotedMessage?.i18n?.[`${userLanguage}_text` as `${TranslationLanguages}_text`] ||
341+
quotedMessage?.i18n?.[`${userLanguage}_text` as `${TranslationLanguage}_text`] ||
342342
quotedMessage?.text,
343343
[quotedMessage?.i18n, quotedMessage?.text, userLanguage],
344344
);

src/components/Poll/PollActions/AddCommentPrompt.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useCallback, useEffect, useMemo, useState } from 'react';
22
import { useStateStore } from '../../../store';
33
import { useModalContext, usePollContext, useTranslationContext } from '../../../context';
4-
import type { PollAnswer, PollState } from 'stream-chat';
4+
import type { PollState, PollVoteResponseData } from 'stream-chat';
55
import { Prompt } from '../../Dialog';
66
import { TextInput } from '../../Form';
77
import { useFormState } from '../../Form/hooks';
88

9-
type PollStateSelectorReturnValue = { ownAnswer: PollAnswer | undefined };
9+
type PollStateSelectorReturnValue = { ownAnswer: PollVoteResponseData | undefined };
1010
const pollStateSelector = (nextValue: PollState): PollStateSelectorReturnValue => ({
1111
ownAnswer: nextValue.ownAnswer,
1212
});

src/components/Poll/PollActions/PollAnswerList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
useTranslationContext,
1414
} from '../../../context';
1515

16-
import type { PollAnswer, PollState } from 'stream-chat';
16+
import type { PollState, PollVoteResponseData } from 'stream-chat';
1717

1818
type PollStateSelectorReturnValue = {
1919
is_closed: boolean | undefined;
20-
ownAnswer: PollAnswer | undefined;
20+
ownAnswer: PollVoteResponseData | undefined;
2121
};
2222
const pollStateSelector = (nextValue: PollState): PollStateSelectorReturnValue => ({
2323
is_closed: nextValue.is_closed,

src/context/MessageTranslationViewContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939

4040
import React, { createContext, useCallback, useContext, useState } from 'react';
41-
import type { LocalMessage, TranslationLanguages } from 'stream-chat';
41+
import type { LocalMessage, TranslationLanguage } from 'stream-chat';
4242

4343
/**
4444
* Returns the translated message text for a given language from `message.i18n`, or
@@ -51,7 +51,7 @@ export const getTranslatedMessageText = ({
5151
language: string;
5252
message?: LocalMessage;
5353
}): string | undefined =>
54-
message?.i18n?.[`${language}_text` as `${TranslationLanguages}_text`];
54+
message?.i18n?.[`${language}_text` as `${TranslationLanguage}_text`];
5555

5656
/**
5757
* Which message text to show.

src/context/TranslationContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import calendar from 'dayjs/plugin/calendar.js';
44
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
55
import type { PropsWithChildren } from 'react';
66
import type { TFunction } from 'i18next';
7-
import type { TranslationLanguages } from 'stream-chat';
7+
import type { TranslationLanguage } from 'stream-chat';
88

99
import { defaultDateTimeParser, defaultTranslatorFunction } from '../i18n/utils';
1010
import type { TDateTimeParser } from '../i18n/types';
@@ -15,7 +15,7 @@ Dayjs.extend(localizedFormat);
1515
export type TranslationContextValue = {
1616
t: TFunction;
1717
tDateTimeParser: TDateTimeParser;
18-
userLanguage: TranslationLanguages;
18+
userLanguage: TranslationLanguage;
1919
};
2020

2121
export const TranslationContext = React.createContext<TranslationContextValue>({

0 commit comments

Comments
 (0)