Skip to content

Commit fbdb896

Browse files
CRNS-49 and CRNS-50: Exporting types of all prop types
1 parent 276d5b7 commit fbdb896

File tree

6 files changed

+59
-53
lines changed

6 files changed

+59
-53
lines changed

src/components/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const Card = withMessageContentContext(
4747
static themePath = 'card';
4848
static propTypes = {
4949
/** Title retured by the OG scraper */
50-
title: PropTypes.string.isRequired,
50+
title: PropTypes.string,
5151
/** Link retured by the OG scraper */
5252
title_link: PropTypes.string,
5353
/** The scraped url, used as a fallback if the OG-data doesnt include a link */

src/components/ChannelListMessenger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const ChannelListMessenger = withChatContext(
2525
}),
2626
PropTypes.object,
2727
]).isRequired,
28+
setActiveChannel: PropTypes.func,
2829
/** UI Component to display individual channel item in list.
2930
* Defaults to [ChannelPreviewMessenger](https://getstream.github.io/stream-chat-react-native/#channelpreviewmessenger) */
3031
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),

src/components/ChannelPreview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ChannelPreview extends PureComponent {
1717
static propTypes = {
1818
channel: PropTypes.object.isRequired,
1919
client: PropTypes.object.isRequired,
20-
setActiveChannel: PropTypes.func.isRequired,
20+
setActiveChannel: PropTypes.func,
2121
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
2222
};
2323

src/components/ChannelPreviewMessenger.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export const ChannelPreviewMessenger = themed(
120120
</Title>
121121
<Date>{this.props.latestMessage.created_at}</Date>
122122
</DetailsTop>
123-
<Message unread={this.props.unread > 0}>
123+
<Message
124+
unread={this.props.unread > 0 ? this.props.unread : undefined}
125+
>
124126
{!this.props.latestMessage
125127
? 'Nothing yet...'
126128
: truncate(

src/components/Chat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const Chat = themed(
9393
this.props.client.off('connection.recovered');
9494
this.props.client.off('connection.changed');
9595
this.props.client.off(this.handleEvent);
96-
this.unsubscribeNetInfo();
96+
this.unsubscribeNetInfo && this.unsubscribeNetInfo();
9797
}
9898

9999
notifyChatClient = (isConnected) => {

types/index.d.ts

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import * as SeamlessImmutable from 'seamless-immutable';
77

88
declare function withChatContext(): React.FC;
99

10-
interface ChatContext extends React.Context<ChatContextValue> {}
11-
interface ChatContextValue {
10+
export interface ChatContext extends React.Context<ChatContextValue> {}
11+
export interface ChatContextValue {
1212
client?: Client.StreamChat;
1313
channel?: Client.Channel;
1414
setActiveChannel?(
@@ -20,8 +20,9 @@ interface ChatContextValue {
2020
}
2121

2222
declare function withSuggestionsContext(): React.FC;
23-
interface SuggestionsContext extends React.Context<SuggestionsContextValue> {}
24-
interface SuggestionsContextValue {
23+
export interface SuggestionsContext
24+
extends React.Context<SuggestionsContextValue> {}
25+
export interface SuggestionsContextValue {
2526
setInputBoxContainerRef?(ref: any): void;
2627
openSuggestions?(title: string, component: React.ElementType): void;
2728
closeSuggestions?(): void;
@@ -41,8 +42,8 @@ interface SuggestionsContextValue {
4142
}
4243

4344
declare function withChannelContext(): React.FC;
44-
interface ChannelContext extends React.Context<ChannelContextValue> {}
45-
interface ChannelContextValue {
45+
export interface ChannelContext extends React.Context<ChannelContextValue> {}
46+
export interface ChannelContextValue {
4647
Message?: React.ElementType<MessageUIComponentProps>;
4748
Attachment?: React.ElementType<AttachmentProps>;
4849
EmptyStateIndicator?: React.ElementType<EmptyStateIndicatorProps>;
@@ -98,8 +99,8 @@ interface ChannelContextValue {
9899
clearEditingState?(): void;
99100
}
100101

101-
interface KeyboardContext extends React.Context<KeyboardContextValue> {}
102-
interface KeyboardContextValue {
102+
export interface KeyboardContext extends React.Context<KeyboardContextValue> {}
103+
export interface KeyboardContextValue {
103104
dismissKeyboard?(): void;
104105
}
105106

@@ -108,7 +109,7 @@ export interface ChatProps {
108109
style?: object;
109110
}
110111

111-
interface ChannelProps extends ChatContextValue {
112+
export interface ChannelProps extends ChatContextValue {
112113
/** The loading indicator to use */
113114
LoadingIndicator?: React.ElementType;
114115
LoadingErrorIndicator?: React.ElementType<LoadingErrorIndicatorProps>;
@@ -139,7 +140,7 @@ export interface EventIndicatorProps {
139140
| Client.Event<Client.MemberRemovedEvent>;
140141
}
141142

142-
interface AvatarProps {
143+
export interface AvatarProps {
143144
/** image url */
144145
image?: string;
145146
/** name of the picture, used for title tag fallback */
@@ -148,16 +149,16 @@ interface AvatarProps {
148149
size?: Number;
149150
}
150151

151-
interface File {
152+
export interface File {
152153
uri: string;
153154
name?: string;
154155
}
155156

156-
interface FileUploadResponse {
157+
export interface FileUploadResponse {
157158
file: string;
158159
[name: string]: any;
159160
}
160-
interface MessageInputProps
161+
export interface MessageInputProps
161162
extends KeyboardContextValue,
162163
ChannelContextValue,
163164
SuggestionsContextValue {
@@ -181,7 +182,7 @@ interface MessageInputProps
181182
AttachmentFileIcon?: React.ElementType<FileIconUIComponentProps>;
182183
}
183184

184-
interface AttachmentProps {
185+
export interface AttachmentProps {
185186
/** The attachment to render */
186187
attachment: Client.Attachment;
187188
/**
@@ -192,7 +193,7 @@ interface AttachmentProps {
192193
groupStyle: 'single' | 'top' | 'middle' | 'bottom';
193194
}
194195

195-
interface ChannelListProps extends ChatContextValue {
196+
export interface ChannelListProps extends ChatContextValue {
196197
/** The Preview to use, defaults to ChannelPreviewLastMessage */
197198
Preview?: React.ElementType<ChannelPreviewUIComponentProps>;
198199

@@ -248,7 +249,7 @@ interface ChannelListProps extends ChatContextValue {
248249
additionalFlatListProps?: object;
249250
}
250251

251-
interface ChannelListState {
252+
export interface ChannelListState {
252253
// Error in querying channels
253254
error: boolean | object;
254255
// List of channel objects.
@@ -263,24 +264,24 @@ interface ChannelListState {
263264
offset: number;
264265
}
265266

266-
interface ChannelListUIComponentProps
267+
export interface ChannelListUIComponentProps
267268
extends ChannelListProps,
268269
ChannelListState {
269270
loadNextPage(): void;
270271
}
271272

272-
interface ChannelPreviewProps extends ChannelListUIComponentProps {
273+
export interface ChannelPreviewProps extends ChannelListUIComponentProps {
273274
Preview: React.ElementType<ChannelPreviewUIComponentProps>;
274275
key: string;
275276
}
276277

277-
interface ChannelPreviewState {
278+
export interface ChannelPreviewState {
278279
unread: number;
279280
lastMessage: Client.MessageResponse;
280281
lastRead: Date;
281282
}
282283

283-
interface ChannelPreviewUIComponentProps
284+
export interface ChannelPreviewUIComponentProps
284285
extends ChannelPreviewProps,
285286
ChannelPreviewState {
286287
latestMessage: {
@@ -289,7 +290,7 @@ interface ChannelPreviewUIComponentProps
289290
};
290291
}
291292

292-
interface MessageListProps extends ChannelContextValue {
293+
export interface MessageListProps extends ChannelContextValue {
293294
/** Turn off grouping of messages by user */
294295
messageActions: Array<MessageAction>;
295296
noGroupByUser?: boolean;
@@ -334,7 +335,7 @@ interface MessageListProps extends ChannelContextValue {
334335
}
335336

336337
declare type MessageAction = 'edit' | 'delete' | 'reactions' | 'reply';
337-
interface MessageProps extends KeyboardContextValue {
338+
export interface MessageProps extends KeyboardContextValue {
338339
client: Client.StreamChat;
339340
onThreadSelect?(message: Client.MessageResponse): void;
340341
/** The message object */
@@ -376,7 +377,9 @@ interface MessageProps extends KeyboardContextValue {
376377
dismissKeyboardOnMessageTouch: boolean;
377378
}
378379

379-
interface MessageUIComponentProps extends MessageProps, KeyboardContextValue {
380+
export interface MessageUIComponentProps
381+
extends MessageProps,
382+
KeyboardContextValue {
380383
reactionsEnabled: boolean;
381384
repliesEnabled: boolean;
382385
onMessageTouch?(
@@ -409,10 +412,10 @@ interface MessageUIComponentProps extends MessageProps, KeyboardContextValue {
409412
AttachmentFileIcon?: React.ElementType<FileIconUIComponentProps>;
410413
}
411414

412-
interface MessageTextProps {
415+
export interface MessageTextProps {
413416
message: Client.MessageResponse;
414417
}
415-
interface ThreadProps extends ChannelContextValue {
418+
export interface ThreadProps extends ChannelContextValue {
416419
/** the thread (the parent message object) */
417420
thread: SeamlessImmutable.Immutable<Client.MessageResponse>;
418421
/** The list of messages to render, state is handled by the parent channel component */
@@ -424,17 +427,17 @@ interface ThreadProps extends ChannelContextValue {
424427
additionalMessageInputProps?: object;
425428
}
426429

427-
interface TypingIndicatorProps {
430+
export interface TypingIndicatorProps {
428431
typing: [];
429432
client: Client.StreamChat;
430433
}
431434

432-
interface FileIconUIComponentProps {
435+
export interface FileIconUIComponentProps {
433436
size: number;
434437
mimeType?: string;
435438
}
436439

437-
interface AutoCompleteInputProps {
440+
export interface AutoCompleteInputProps {
438441
value: string;
439442
openSuggestions?(title: string, component: React.ElementType<any, any>): void;
440443
closeSuggestions?(): void;
@@ -445,7 +448,7 @@ interface AutoCompleteInputProps {
445448
additionalTextInputProps: object;
446449
}
447450

448-
interface CardProps {
451+
export interface CardProps {
449452
title: string;
450453
title_link: string;
451454
og_scrape_url: string;
@@ -457,45 +460,45 @@ interface CardProps {
457460
onLongPress?: (event: GestureResponderEvent) => void;
458461
}
459462

460-
interface CommandsItemProps {
463+
export interface CommandsItemProps {
461464
name: string;
462465
args: string;
463466
description: string;
464467
}
465468

466-
interface DateSeparatorProps {
469+
export interface DateSeparatorProps {
467470
message: Client.MessageResponse;
468471
formatDate?(date: Date): string;
469472
}
470-
interface EmptyStateIndicatorProps {
473+
export interface EmptyStateIndicatorProps {
471474
listType: 'string';
472475
}
473-
interface EventIndicatorProps {
476+
export interface EventIndicatorProps {
474477
event: Client.Event;
475478
}
476-
interface FileAttachmentGroupProps {
479+
export interface FileAttachmentGroupProps {
477480
messageId: string;
478481
files: [];
479482
handleAction?(): void;
480483
alignment: 'right' | 'left';
481484
AttachmentFileIcon: React.ElementType<any, any>;
482485
}
483-
interface FileUploadPreviewProps {
486+
export interface FileUploadPreviewProps {
484487
fileUploads: [];
485488
removeFile?(id: string): void;
486489
retryUpload?(id: string): Promise<any>;
487490
AttachmentFileIcon: React.ElementType<any, any>;
488491
}
489-
interface GalleryProps {
492+
export interface GalleryProps {
490493
images: Client.Attachment[];
491494
onLongPress: (event: GestureResponderEvent) => void;
492495
alignment: 'right' | 'left';
493496
}
494-
interface IconSquareProps {
497+
export interface IconSquareProps {
495498
icon: string;
496499
onPress?(event: GestureResponderEvent): void;
497500
}
498-
interface ImageUploadPreviewProps {
501+
export interface ImageUploadPreviewProps {
499502
imageUploads: Array<{
500503
[id: string]: {
501504
id: string;
@@ -506,41 +509,41 @@ interface ImageUploadPreviewProps {
506509
removeImage?(id: string): void;
507510
retryUpload?(id: string): Promise<any>;
508511
}
509-
interface KeyboardCompatibleViewProps {}
510-
interface LoadingErrorIndicatorProps {
512+
export interface KeyboardCompatibleViewProps {}
513+
export interface LoadingErrorIndicatorProps {
511514
listType: string;
512515
}
513-
interface LoadingIndicatorProps {
516+
export interface LoadingIndicatorProps {
514517
listType: 'channel' | 'message' | 'default';
515518
}
516-
interface MentionsItemProps {
519+
export interface MentionsItemProps {
517520
item: {
518521
name?: string;
519522
icon: string;
520523
id?: string;
521524
};
522525
}
523526

524-
interface MessageNotificationProps {
527+
export interface MessageNotificationProps {
525528
showNotification: boolean;
526529
onPress?(event: GestureResponderEvent): void;
527530
}
528531

529-
interface MessageSystemProps {
532+
export interface MessageSystemProps {
530533
message: Client.MessageResponse;
531534
}
532535

533-
interface ReactionListProps {
536+
export interface ReactionListProps {
534537
latestReactions: any;
535538
openReactionSelector?(event: GestureResponderEvent): void;
536539
getTotalReactionCount?(): string | number;
537540
visible: boolean;
538541
position: string;
539542
}
540543

541-
interface SpinnerProps {}
544+
export interface SpinnerProps {}
542545

543-
interface SuggestionsProviderProps {
546+
export interface SuggestionsProviderProps {
544547
active: boolean;
545548
marginLeft: string | number;
546549
width: string | number;
@@ -549,13 +552,13 @@ interface SuggestionsProviderProps {
549552
handleDismiss?(event: GestureResponderEvent): void;
550553
suggestionsTitle: string;
551554
}
552-
interface UploadProgressIndicatorProps {
555+
export interface UploadProgressIndicatorProps {
553556
active: boolean;
554557
type: 'in_progress' | 'retry';
555558
action?(event: GestureResponderEvent): void;
556559
}
557560

558-
interface AttachmentActionsProps {
561+
export interface AttachmentActionsProps {
559562
text: string;
560563
actions: Client.Action[];
561564
actionHandler?(name: string, value: string): any;

0 commit comments

Comments
 (0)