stream-chat-react-native-core 4.7.0-beta.5 → 4.7.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/Attachment.js +23 -13
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Card.js +63 -30
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/Attachment/FileAttachment.js +10 -17
- package/lib/commonjs/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +22 -10
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/utils/openUrlSafely.js +54 -0
- package/lib/commonjs/components/Attachment/utils/openUrlSafely.js.map +1 -0
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +90 -56
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +23 -22
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +8 -8
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +10 -7
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js +2 -2
- package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +12 -12
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +2 -2
- package/lib/commonjs/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js.map +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js +14 -4
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js +14 -4
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js +14 -4
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js +15 -9
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js +14 -4
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js +14 -4
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/commonjs/contexts/keyboardContext/KeyboardContext.js +2 -2
- package/lib/commonjs/contexts/keyboardContext/KeyboardContext.js.map +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js +14 -4
- package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +14 -4
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +14 -4
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/hooks/useResettableState.test.js +4 -4
- package/lib/commonjs/contexts/messageOverlayContext/hooks/useResettableState.test.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +14 -4
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js +13 -3
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +12 -12
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +13 -3
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +14 -4
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js +14 -4
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/ThemeContext.js +13 -7
- package/lib/commonjs/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +9 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/contexts/threadContext/ThreadContext.js +14 -4
- package/lib/commonjs/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/commonjs/contexts/translationContext/TranslationContext.js +15 -6
- package/lib/commonjs/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/commonjs/contexts/typingContext/TypingContext.js +14 -4
- package/lib/commonjs/contexts/typingContext/TypingContext.js.map +1 -1
- package/lib/commonjs/contexts/utils/defaultBaseContextValue.js +7 -0
- package/lib/commonjs/contexts/utils/defaultBaseContextValue.js.map +1 -0
- package/lib/commonjs/contexts/utils/isTestEnvironment.js +11 -0
- package/lib/commonjs/contexts/utils/isTestEnvironment.js.map +1 -0
- package/lib/commonjs/mock-builders/mock.js +30 -5
- package/lib/commonjs/mock-builders/mock.js.map +1 -1
- package/lib/commonjs/native.js +8 -2
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +23 -13
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Card.js +63 -30
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/Attachment/FileAttachment.js +10 -17
- package/lib/module/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +22 -10
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/utils/openUrlSafely.js +54 -0
- package/lib/module/components/Attachment/utils/openUrlSafely.js.map +1 -0
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +90 -56
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +23 -22
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +8 -8
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/module/components/Message/Message.js +10 -7
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js +2 -2
- package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +12 -12
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +2 -2
- package/lib/module/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js.map +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js +14 -4
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js +14 -4
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/contexts/channelsContext/ChannelsContext.js +14 -4
- package/lib/module/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js +15 -9
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js +14 -4
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js +14 -4
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/module/contexts/keyboardContext/KeyboardContext.js +2 -2
- package/lib/module/contexts/keyboardContext/KeyboardContext.js.map +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js +14 -4
- package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +14 -4
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +14 -4
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/hooks/useResettableState.test.js +4 -4
- package/lib/module/contexts/messageOverlayContext/hooks/useResettableState.test.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +14 -4
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js +13 -3
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +12 -12
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +13 -3
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +14 -4
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js +14 -4
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/module/contexts/themeContext/ThemeContext.js +13 -7
- package/lib/module/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +9 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/contexts/threadContext/ThreadContext.js +14 -4
- package/lib/module/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/module/contexts/translationContext/TranslationContext.js +15 -6
- package/lib/module/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/module/contexts/typingContext/TypingContext.js +14 -4
- package/lib/module/contexts/typingContext/TypingContext.js.map +1 -1
- package/lib/module/contexts/utils/defaultBaseContextValue.js +7 -0
- package/lib/module/contexts/utils/defaultBaseContextValue.js.map +1 -0
- package/lib/module/contexts/utils/isTestEnvironment.js +11 -0
- package/lib/module/contexts/utils/isTestEnvironment.js.map +1 -0
- package/lib/module/mock-builders/mock.js +30 -5
- package/lib/module/mock-builders/mock.js.map +1 -1
- package/lib/module/native.js +8 -2
- package/lib/module/native.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/__tests__/openUrlSafely.test.d.ts +1 -0
- package/lib/typescript/components/Attachment/utils/openUrlSafely.d.ts +1 -0
- package/lib/typescript/contexts/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/contexts/keyboardContext/KeyboardContext.d.ts +6 -2
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts +5 -2
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +6 -0
- package/lib/typescript/contexts/utils/defaultBaseContextValue.d.ts +1 -0
- package/lib/typescript/contexts/utils/isTestEnvironment.d.ts +1 -0
- package/lib/typescript/mock-builders/mock.d.ts +2 -2
- package/lib/typescript/native.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Attachment/Attachment.tsx +4 -1
- package/src/components/Attachment/Card.tsx +30 -9
- package/src/components/Attachment/FileAttachment.tsx +2 -4
- package/src/components/Attachment/Gallery.tsx +17 -4
- package/src/components/Attachment/__tests__/Attachment.test.js +0 -53
- package/src/components/Attachment/__tests__/Giphy.test.js +9 -5
- package/src/components/Attachment/__tests__/openUrlSafely.test.ts +48 -0
- package/src/components/Attachment/utils/openUrlSafely.ts +17 -0
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +5 -3
- package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx +1 -0
- package/src/components/ImageGallery/ImageGallery.tsx +7 -3
- package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +16 -13
- package/src/components/ImageGallery/components/__tests__/ImageGalleryHeader.test.tsx +5 -3
- package/src/components/Message/Message.tsx +5 -2
- package/src/components/MessageInput/SendMessageDisallowedIndicator.tsx +1 -0
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +1 -1
- package/src/components/Reply/Reply.tsx +6 -3
- package/src/contexts/__tests__/index.test.tsx +103 -0
- package/src/contexts/activeChannelsRefContext/ActiveChannelsRefContext.tsx +1 -0
- package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +18 -4
- package/src/contexts/channelContext/ChannelContext.tsx +18 -2
- package/src/contexts/channelsContext/ChannelsContext.tsx +18 -2
- package/src/contexts/channelsStateContext/ChannelsStateContext.tsx +19 -10
- package/src/contexts/chatContext/ChatContext.tsx +15 -2
- package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx +18 -3
- package/src/contexts/keyboardContext/KeyboardContext.tsx +2 -1
- package/src/contexts/messageContext/MessageContext.tsx +19 -2
- package/src/contexts/messageInputContext/MessageInputContext.tsx +20 -2
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +19 -3
- package/src/contexts/messageOverlayContext/hooks/useResettableState.test.tsx +1 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +19 -2
- package/src/contexts/overlayContext/OverlayContext.tsx +17 -2
- package/src/contexts/overlayContext/OverlayProvider.tsx +1 -0
- package/src/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.tsx +18 -3
- package/src/contexts/paginatedMessageListContext/PaginatedMessageListContext.tsx +15 -3
- package/src/contexts/suggestionsContext/SuggestionsContext.tsx +19 -2
- package/src/contexts/suggestionsContext/__tests__/Suggestions.test.js +1 -0
- package/src/contexts/themeContext/ThemeContext.tsx +19 -5
- package/src/contexts/themeContext/utils/theme.ts +15 -0
- package/src/contexts/threadContext/ThreadContext.tsx +16 -2
- package/src/contexts/translationContext/TranslationContext.tsx +18 -4
- package/src/contexts/typingContext/TypingContext.tsx +17 -2
- package/src/contexts/utils/defaultBaseContextValue.ts +1 -0
- package/src/contexts/utils/isTestEnvironment.ts +1 -0
- package/src/mock-builders/mock.js +16 -3
- package/src/native.ts +3 -1
- package/src/version.json +1 -1
- package/lib/commonjs/components/Attachment/hooks/useGoToURL.js +0 -42
- package/lib/commonjs/components/Attachment/hooks/useGoToURL.js.map +0 -1
- package/lib/module/components/Attachment/hooks/useGoToURL.js +0 -42
- package/lib/module/components/Attachment/hooks/useGoToURL.js.map +0 -1
- package/lib/typescript/components/Attachment/hooks/useGoToURL.d.ts +0 -2
- package/src/components/Attachment/hooks/useGoToURL.ts +0 -27
|
@@ -4,7 +4,10 @@ import type { ChannelState } from 'stream-chat';
|
|
|
4
4
|
|
|
5
5
|
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
|
|
6
6
|
import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
|
|
7
|
+
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
|
|
8
|
+
|
|
7
9
|
import { getDisplayName } from '../utils/getDisplayName';
|
|
10
|
+
import { isTestEnvironment } from '../utils/isTestEnvironment';
|
|
8
11
|
|
|
9
12
|
export type ThreadContextValue<
|
|
10
13
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -21,7 +24,7 @@ export type ThreadContextValue<
|
|
|
21
24
|
threadMessages: ChannelState<StreamChatGenerics>['threads'][string];
|
|
22
25
|
};
|
|
23
26
|
|
|
24
|
-
export const ThreadContext = React.createContext(
|
|
27
|
+
export const ThreadContext = React.createContext(DEFAULT_BASE_CONTEXT_VALUE as ThreadContextValue);
|
|
25
28
|
|
|
26
29
|
export const ThreadProvider = <
|
|
27
30
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -38,8 +41,19 @@ export const ThreadProvider = <
|
|
|
38
41
|
|
|
39
42
|
export const useThreadContext = <
|
|
40
43
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
41
|
-
>() =>
|
|
44
|
+
>() => {
|
|
45
|
+
const contextValue = useContext(
|
|
46
|
+
ThreadContext,
|
|
47
|
+
) as unknown as ThreadContextValue<StreamChatGenerics>;
|
|
48
|
+
|
|
49
|
+
if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`The useThreadContext hook was called outside of the ThreadContext provider. Make sure you have configured Channel component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
42
54
|
|
|
55
|
+
return contextValue;
|
|
56
|
+
};
|
|
43
57
|
/**
|
|
44
58
|
* Typescript currently does not support partial inference so if ThreadContext
|
|
45
59
|
* typing is desired while using the HOC withThreadContextContext the Props for the
|
|
@@ -6,8 +6,8 @@ import type { TFunction } from 'i18next';
|
|
|
6
6
|
import type { Moment } from 'moment';
|
|
7
7
|
|
|
8
8
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
9
|
-
|
|
10
9
|
import { getDisplayName } from '../utils/getDisplayName';
|
|
10
|
+
import { isTestEnvironment } from '../utils/isTestEnvironment';
|
|
11
11
|
|
|
12
12
|
export const isDayOrMoment = (output: TDateTimeParserOutput): output is Dayjs.Dayjs | Moment =>
|
|
13
13
|
(output as Dayjs.Dayjs | Moment).isSame != null;
|
|
@@ -23,10 +23,14 @@ export type TranslationContextValue = {
|
|
|
23
23
|
tDateTimeParser: TDateTimeParser;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const defaultTranslationContextValue: TranslationContextValue = {
|
|
27
27
|
t: (key: string) => key,
|
|
28
28
|
tDateTimeParser: (input) => Dayjs(input),
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const TranslationContext = React.createContext<TranslationContextValue>(
|
|
32
|
+
defaultTranslationContextValue,
|
|
33
|
+
);
|
|
30
34
|
|
|
31
35
|
export const TranslationProvider: React.FC<{
|
|
32
36
|
value: TranslationContextValue;
|
|
@@ -34,7 +38,17 @@ export const TranslationProvider: React.FC<{
|
|
|
34
38
|
<TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>
|
|
35
39
|
);
|
|
36
40
|
|
|
37
|
-
export const useTranslationContext = () =>
|
|
41
|
+
export const useTranslationContext = () => {
|
|
42
|
+
const contextValue = useContext(TranslationContext);
|
|
43
|
+
|
|
44
|
+
if (contextValue === defaultTranslationContextValue && !isTestEnvironment()) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`The useTranslationContext hook was called outside the TranslationContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider)(https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return contextValue;
|
|
51
|
+
};
|
|
38
52
|
|
|
39
53
|
export const withTranslationContext = <
|
|
40
54
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -3,7 +3,10 @@ import React, { PropsWithChildren, useContext } from 'react';
|
|
|
3
3
|
import type { ChannelState } from 'stream-chat';
|
|
4
4
|
|
|
5
5
|
import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
|
|
6
|
+
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
|
|
7
|
+
|
|
6
8
|
import { getDisplayName } from '../utils/getDisplayName';
|
|
9
|
+
import { isTestEnvironment } from '../utils/isTestEnvironment';
|
|
7
10
|
|
|
8
11
|
export type TypingContextValue<
|
|
9
12
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -11,7 +14,7 @@ export type TypingContextValue<
|
|
|
11
14
|
typing: ChannelState<StreamChatGenerics>['typing'];
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
export const TypingContext = React.createContext(
|
|
17
|
+
export const TypingContext = React.createContext(DEFAULT_BASE_CONTEXT_VALUE as TypingContextValue);
|
|
15
18
|
|
|
16
19
|
export const TypingProvider = <
|
|
17
20
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -28,7 +31,19 @@ export const TypingProvider = <
|
|
|
28
31
|
|
|
29
32
|
export const useTypingContext = <
|
|
30
33
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
31
|
-
>() =>
|
|
34
|
+
>() => {
|
|
35
|
+
const contextValue = useContext(
|
|
36
|
+
TypingContext,
|
|
37
|
+
) as unknown as TypingContextValue<StreamChatGenerics>;
|
|
38
|
+
|
|
39
|
+
if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`The useTypingContext hook was called outside of the TypingContext provider. Make sure you have configured Channel component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return contextValue;
|
|
46
|
+
};
|
|
32
47
|
|
|
33
48
|
/**
|
|
34
49
|
* Typescript currently does not support partial inference so if TypingContext
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_BASE_CONTEXT_VALUE = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isTestEnvironment = () => process.env.NODE_ENV === 'test';
|
|
@@ -17,7 +17,9 @@ const setUser = (client, user) =>
|
|
|
17
17
|
resolve();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
function mockClient(client) {
|
|
20
|
+
function mockClient(client, options = {}) {
|
|
21
|
+
const { disableAppSettings = true } = options;
|
|
22
|
+
|
|
21
23
|
jest.spyOn(client, '_setToken').mockImplementation();
|
|
22
24
|
jest.spyOn(client, '_setupConnection').mockImplementation();
|
|
23
25
|
client.tokenManager = {
|
|
@@ -25,15 +27,26 @@ function mockClient(client) {
|
|
|
25
27
|
tokenReady: jest.fn(() => true),
|
|
26
28
|
};
|
|
27
29
|
client.setUser = setUser.bind(null, client);
|
|
30
|
+
|
|
31
|
+
if (disableAppSettings) {
|
|
32
|
+
client.getAppSettings = jest.fn(() => ({}));
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
return client;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
export const getTestClient = () => mockClient(new StreamChat(apiKey));
|
|
38
|
+
export const getTestClient = (options = {}) => mockClient(new StreamChat(apiKey), options);
|
|
32
39
|
|
|
33
|
-
export const getTestClientWithUser = async (user) => {
|
|
40
|
+
export const getTestClientWithUser = async (user, options = {}) => {
|
|
41
|
+
const { disableAppSettings = true } = options;
|
|
34
42
|
const client = mockClient(new StreamChat(apiKey));
|
|
35
43
|
await setUser(client, user);
|
|
36
44
|
client.wsPromise = Promise.resolve();
|
|
45
|
+
|
|
46
|
+
if (disableAppSettings) {
|
|
47
|
+
client.getAppSettings = jest.fn(() => ({}));
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
return client;
|
|
38
51
|
};
|
|
39
52
|
|
package/src/native.ts
CHANGED
|
@@ -145,7 +145,7 @@ export type VideoType = {
|
|
|
145
145
|
style?: StyleProp<ViewStyle>;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
export let Video: React.ComponentType<VideoType
|
|
148
|
+
export let Video: React.ComponentType<VideoType>;
|
|
149
149
|
|
|
150
150
|
type Handlers = {
|
|
151
151
|
compressImage?: CompressImage;
|
|
@@ -219,3 +219,5 @@ export const registerNativeHandlers = (handlers: Handlers) => {
|
|
|
219
219
|
Video = handlers.Video;
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
|
+
|
|
223
|
+
export const isVideoPackageAvailable = () => !!Video;
|
package/src/version.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useGoToURL = void 0;
|
|
7
|
-
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
|
|
12
|
-
var _reactNative = require("react-native");
|
|
13
|
-
|
|
14
|
-
var useGoToURL = function useGoToURL(url) {
|
|
15
|
-
var _useState = (0, _react.useState)(false),
|
|
16
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
17
|
-
error = _useState2[0],
|
|
18
|
-
setError = _useState2[1];
|
|
19
|
-
|
|
20
|
-
var finalUrl = url;
|
|
21
|
-
var pattern = new RegExp(/^\S+:\/\//);
|
|
22
|
-
|
|
23
|
-
if (!pattern.test(finalUrl)) {
|
|
24
|
-
finalUrl = 'http://' + url;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var openURL = function openURL() {
|
|
28
|
-
return _reactNative.Linking.canOpenURL(finalUrl).then(function (supported) {
|
|
29
|
-
if (supported) {
|
|
30
|
-
_reactNative.Linking.openURL(finalUrl);
|
|
31
|
-
} else {
|
|
32
|
-
setError(true);
|
|
33
|
-
console.warn("Don't know how to open URI: " + finalUrl);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return [error, openURL];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.useGoToURL = useGoToURL;
|
|
42
|
-
//# sourceMappingURL=useGoToURL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["useGoToURL.ts"],"names":["useGoToURL","url","error","setError","finalUrl","pattern","RegExp","test","openURL","Linking","canOpenURL","then","supported","console","warn"],"mappings":";;;;;;;;;AAAA;;AACA;;AAIO,IAAMA,UAA0B,GAAG,SAA7BA,UAA6B,CAACC,GAAD,EAAkB;AAC1D,kBAA0B,qBAAkB,KAAlB,CAA1B;AAAA;AAAA,MAAOC,KAAP;AAAA,MAAcC,QAAd;;AAEA,MAAIC,QAAQ,GAAGH,GAAf;AACA,MAAMI,OAAO,GAAG,IAAIC,MAAJ,CAAW,WAAX,CAAhB;;AAEA,MAAI,CAACD,OAAO,CAACE,IAAR,CAAaH,QAAb,CAAL,EAA6B;AAC3BA,IAAAA,QAAQ,GAAG,YAAYH,GAAvB;AACD;;AAED,MAAMO,OAAO,GAAG,SAAVA,OAAU;AAAA,WACdC,qBAAQC,UAAR,CAAmBN,QAAnB,EAA6BO,IAA7B,CAAkC,UAACC,SAAD,EAAe;AAC/C,UAAIA,SAAJ,EAAe;AACbH,6BAAQD,OAAR,CAAgBJ,QAAhB;AACD,OAFD,MAEO;AACLD,QAAAA,QAAQ,CAAC,IAAD,CAAR;AACAU,QAAAA,OAAO,CAACC,IAAR,kCAA4CV,QAA5C;AACD;AACF,KAPD,CADc;AAAA,GAAhB;;AAUA,SAAO,CAACF,KAAD,EAAQM,OAAR,CAAP;AACD,CArBM","sourcesContent":["import { useState } from 'react';\nimport { Linking } from 'react-native';\n\nexport type UseGoToURLType = (url?: string) => [boolean, () => Promise<void>];\n\nexport const useGoToURL: UseGoToURLType = (url?: string) => {\n const [error, setError] = useState<boolean>(false);\n\n let finalUrl = url as string;\n const pattern = new RegExp(/^\\S+:\\/\\//);\n\n if (!pattern.test(finalUrl)) {\n finalUrl = 'http://' + url;\n }\n\n const openURL = () =>\n Linking.canOpenURL(finalUrl).then((supported) => {\n if (supported) {\n Linking.openURL(finalUrl);\n } else {\n setError(true);\n console.warn(`Don't know how to open URI: ${finalUrl}`);\n }\n });\n\n return [error, openURL];\n};\n"]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useGoToURL = void 0;
|
|
7
|
-
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
|
|
12
|
-
var _reactNative = require("react-native");
|
|
13
|
-
|
|
14
|
-
var useGoToURL = function useGoToURL(url) {
|
|
15
|
-
var _useState = (0, _react.useState)(false),
|
|
16
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
17
|
-
error = _useState2[0],
|
|
18
|
-
setError = _useState2[1];
|
|
19
|
-
|
|
20
|
-
var finalUrl = url;
|
|
21
|
-
var pattern = new RegExp(/^\S+:\/\//);
|
|
22
|
-
|
|
23
|
-
if (!pattern.test(finalUrl)) {
|
|
24
|
-
finalUrl = 'http://' + url;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var openURL = function openURL() {
|
|
28
|
-
return _reactNative.Linking.canOpenURL(finalUrl).then(function (supported) {
|
|
29
|
-
if (supported) {
|
|
30
|
-
_reactNative.Linking.openURL(finalUrl);
|
|
31
|
-
} else {
|
|
32
|
-
setError(true);
|
|
33
|
-
console.warn("Don't know how to open URI: " + finalUrl);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return [error, openURL];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.useGoToURL = useGoToURL;
|
|
42
|
-
//# sourceMappingURL=useGoToURL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["useGoToURL.ts"],"names":["useGoToURL","url","error","setError","finalUrl","pattern","RegExp","test","openURL","Linking","canOpenURL","then","supported","console","warn"],"mappings":";;;;;;;;;AAAA;;AACA;;AAIO,IAAMA,UAA0B,GAAG,SAA7BA,UAA6B,CAACC,GAAD,EAAkB;AAC1D,kBAA0B,qBAAkB,KAAlB,CAA1B;AAAA;AAAA,MAAOC,KAAP;AAAA,MAAcC,QAAd;;AAEA,MAAIC,QAAQ,GAAGH,GAAf;AACA,MAAMI,OAAO,GAAG,IAAIC,MAAJ,CAAW,WAAX,CAAhB;;AAEA,MAAI,CAACD,OAAO,CAACE,IAAR,CAAaH,QAAb,CAAL,EAA6B;AAC3BA,IAAAA,QAAQ,GAAG,YAAYH,GAAvB;AACD;;AAED,MAAMO,OAAO,GAAG,SAAVA,OAAU;AAAA,WACdC,qBAAQC,UAAR,CAAmBN,QAAnB,EAA6BO,IAA7B,CAAkC,UAACC,SAAD,EAAe;AAC/C,UAAIA,SAAJ,EAAe;AACbH,6BAAQD,OAAR,CAAgBJ,QAAhB;AACD,OAFD,MAEO;AACLD,QAAAA,QAAQ,CAAC,IAAD,CAAR;AACAU,QAAAA,OAAO,CAACC,IAAR,kCAA4CV,QAA5C;AACD;AACF,KAPD,CADc;AAAA,GAAhB;;AAUA,SAAO,CAACF,KAAD,EAAQM,OAAR,CAAP;AACD,CArBM","sourcesContent":["import { useState } from 'react';\nimport { Linking } from 'react-native';\n\nexport type UseGoToURLType = (url?: string) => [boolean, () => Promise<void>];\n\nexport const useGoToURL: UseGoToURLType = (url?: string) => {\n const [error, setError] = useState<boolean>(false);\n\n let finalUrl = url as string;\n const pattern = new RegExp(/^\\S+:\\/\\//);\n\n if (!pattern.test(finalUrl)) {\n finalUrl = 'http://' + url;\n }\n\n const openURL = () =>\n Linking.canOpenURL(finalUrl).then((supported) => {\n if (supported) {\n Linking.openURL(finalUrl);\n } else {\n setError(true);\n console.warn(`Don't know how to open URI: ${finalUrl}`);\n }\n });\n\n return [error, openURL];\n};\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Linking } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export type UseGoToURLType = (url?: string) => [boolean, () => Promise<void>];
|
|
5
|
-
|
|
6
|
-
export const useGoToURL: UseGoToURLType = (url?: string) => {
|
|
7
|
-
const [error, setError] = useState<boolean>(false);
|
|
8
|
-
|
|
9
|
-
let finalUrl = url as string;
|
|
10
|
-
const pattern = new RegExp(/^\S+:\/\//);
|
|
11
|
-
|
|
12
|
-
if (!pattern.test(finalUrl)) {
|
|
13
|
-
finalUrl = 'http://' + url;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const openURL = () =>
|
|
17
|
-
Linking.canOpenURL(finalUrl).then((supported) => {
|
|
18
|
-
if (supported) {
|
|
19
|
-
Linking.openURL(finalUrl);
|
|
20
|
-
} else {
|
|
21
|
-
setError(true);
|
|
22
|
-
console.warn(`Don't know how to open URI: ${finalUrl}`);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return [error, openURL];
|
|
27
|
-
};
|