Skip to content

Commit 03d15b4

Browse files
Introduce default data interfaces
1 parent fbbb461 commit 03d15b4

File tree

5 files changed

+36
-54
lines changed

5 files changed

+36
-54
lines changed

src/@types/stream-chat-common-custom-data.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'stream-chat';
2+
3+
import { DefaultChannelData } from '../types/defaultDataInterfaces';
4+
5+
declare module 'stream-chat' {
6+
interface CustomChannelData extends DefaultChannelData {}
7+
}

src/types/defaultDataInterfaces.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable @typescript-eslint/no-empty-object-type */
2+
export interface DefaultChannelData {
3+
image?: string;
4+
name?: string;
5+
subtitle?: string;
6+
}
7+
8+
export interface DefaultAttachmentData {}
9+
10+
export interface DefaultCommandData {}
11+
12+
export interface DefaultEventData {}
13+
14+
export interface DefaultMemberData {}
15+
16+
export interface DefaultMessageData {}
17+
18+
export interface DefaultPollOptionData {}
19+
20+
export interface DefaultPollData {}
21+
22+
export interface DefaultReactionData {}
23+
24+
export interface DefaultUserData {}
25+
26+
export interface DefaultThreadData {}

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export type { ChannelUnreadUiState } from './types';
2+
export type * from './defaultDataInterfaces';

src/types/types.ts

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import type { PropsWithChildren } from 'react';
22
import type { LoadingIndicatorProps } from '../components/Loading/LoadingIndicator';
3-
import type {
4-
APIErrorResponse,
5-
Attachment,
6-
ErrorFromResponse,
7-
Event,
8-
Mute,
9-
ChannelState as StreamChannelState,
10-
} from 'stream-chat';
3+
import type { Attachment, ChannelState as StreamChannelState } from 'stream-chat';
114

125
export type UnknownType = Record<string, unknown>;
136
export type PropsWithChildrenOnly = PropsWithChildren<Record<never, never>>;
@@ -21,42 +14,6 @@ export type CustomTrigger = {
2114

2215
export type CustomMessageType = 'channel.intro' | 'message.date';
2316

24-
export type DefaultAttachmentType = UnknownType & {
25-
asset_url?: string;
26-
file_size?: number;
27-
id?: string;
28-
images?: Array<{
29-
image_url?: string;
30-
thumb_url?: string;
31-
}>;
32-
};
33-
34-
export type DefaultChannelType = UnknownType & {
35-
frozen?: boolean;
36-
image?: string;
37-
member_count?: number;
38-
subtitle?: string;
39-
};
40-
41-
export type DefaultMessageType = UnknownType & {
42-
customType?: CustomMessageType;
43-
date?: string | Date;
44-
error?: ErrorFromResponse<APIErrorResponse>;
45-
errorStatusCode?: number;
46-
event?: Event;
47-
unread?: boolean;
48-
};
49-
50-
export type DefaultUserTypeInternal = {
51-
image?: string;
52-
status?: string;
53-
};
54-
55-
export type DefaultUserType = UnknownType &
56-
DefaultUserTypeInternal & {
57-
mutes?: Array<Mute>;
58-
};
59-
6017
export type GiphyVersions =
6118
| 'original'
6219
| 'fixed_height'
@@ -117,7 +74,7 @@ export type VideoAttachmentSizeHandler = (
11774

11875
export type ChannelUnreadUiState = Omit<ValuesType<StreamChannelState['read']>, 'user'>;
11976

120-
// todo: fix export from stream-chat - for some reason not exported
77+
// TODO: fix export from stream-chat - for some reason not exported
12178
export type SendMessageOptions = {
12279
force_moderation?: boolean;
12380
is_pending_message?: boolean;

0 commit comments

Comments
 (0)