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
|
@@ -15,6 +15,8 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
15
15
|
|
|
16
16
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
17
17
|
|
|
18
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
19
|
+
|
|
18
20
|
var _this = this,
|
|
19
21
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/translationContext/TranslationContext.tsx";
|
|
20
22
|
|
|
@@ -27,15 +29,16 @@ var isDayOrMoment = function isDayOrMoment(output) {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
exports.isDayOrMoment = isDayOrMoment;
|
|
30
|
-
|
|
31
|
-
var TranslationContext = _react["default"].createContext({
|
|
32
|
+
var defaultTranslationContextValue = {
|
|
32
33
|
t: function t(key) {
|
|
33
34
|
return key;
|
|
34
35
|
},
|
|
35
36
|
tDateTimeParser: function tDateTimeParser(input) {
|
|
36
37
|
return (0, _dayjs["default"])(input);
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var TranslationContext = _react["default"].createContext(defaultTranslationContextValue);
|
|
39
42
|
|
|
40
43
|
exports.TranslationContext = TranslationContext;
|
|
41
44
|
|
|
@@ -47,7 +50,7 @@ var TranslationProvider = function TranslationProvider(_ref) {
|
|
|
47
50
|
__self: _this,
|
|
48
51
|
__source: {
|
|
49
52
|
fileName: _jsxFileName,
|
|
50
|
-
lineNumber:
|
|
53
|
+
lineNumber: 38,
|
|
51
54
|
columnNumber: 3
|
|
52
55
|
}
|
|
53
56
|
}, children);
|
|
@@ -56,7 +59,13 @@ var TranslationProvider = function TranslationProvider(_ref) {
|
|
|
56
59
|
exports.TranslationProvider = TranslationProvider;
|
|
57
60
|
|
|
58
61
|
var useTranslationContext = function useTranslationContext() {
|
|
59
|
-
|
|
62
|
+
var contextValue = (0, _react.useContext)(TranslationContext);
|
|
63
|
+
|
|
64
|
+
if (contextValue === defaultTranslationContextValue && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
65
|
+
throw new Error("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");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return contextValue;
|
|
60
69
|
};
|
|
61
70
|
|
|
62
71
|
exports.useTranslationContext = useTranslationContext;
|
|
@@ -68,7 +77,7 @@ var withTranslationContext = function withTranslationContext(Component) {
|
|
|
68
77
|
__self: _this,
|
|
69
78
|
__source: {
|
|
70
79
|
fileName: _jsxFileName,
|
|
71
|
-
lineNumber:
|
|
80
|
+
lineNumber: 63,
|
|
72
81
|
columnNumber: 12
|
|
73
82
|
}
|
|
74
83
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TranslationContext.tsx"],"names":["isDayOrMoment","output","isSame","
|
|
1
|
+
{"version":3,"sources":["TranslationContext.tsx"],"names":["isDayOrMoment","output","isSame","defaultTranslationContextValue","t","key","tDateTimeParser","input","TranslationContext","React","createContext","TranslationProvider","children","value","useTranslationContext","contextValue","Error","withTranslationContext","Component","WithTranslationContextComponent","props","translationContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AAMA;;AACA;;;;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,MAAD;AAAA,SAC1BA,MAAD,CAAiCC,MAAjC,IAA2C,IADhB;AAAA,CAAtB;;;AAcP,IAAMC,8BAAuD,GAAG;AAC9DC,EAAAA,CAAC,EAAE,WAACC,GAAD;AAAA,WAAiBA,GAAjB;AAAA,GAD2D;AAE9DC,EAAAA,eAAe,EAAE,yBAACC,KAAD;AAAA,WAAW,uBAAMA,KAAN,CAAX;AAAA;AAF6C,CAAhE;;AAKO,IAAMC,kBAAkB,GAAGC,kBAAMC,aAAN,CAChCP,8BADgC,CAA3B;;;;AAIA,IAAMQ,mBAEX,GAAG,SAFQA,mBAER;AAAA,MAAGC,QAAH,QAAGA,QAAH;AAAA,MAAaC,KAAb,QAAaA,KAAb;AAAA,SACH,gCAAC,kBAAD,CAAoB,QAApB;AAA6B,IAAA,KAAK,EAAEA,KAApC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAA4CD,QAA5C,CADG;AAAA,CAFE;;;;AAMA,IAAME,qBAAqB,GAAG,SAAxBA,qBAAwB,GAAM;AACzC,MAAMC,YAAY,GAAG,uBAAWP,kBAAX,CAArB;;AAEA,MAAIO,YAAY,KAAKZ,8BAAjB,IAAmD,CAAC,2CAAxD,EAA6E;AAC3E,UAAM,IAAIa,KAAJ,+UAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAVM;;;;AAYA,IAAME,sBAAsB,GAAG,SAAzBA,sBAAyB,CAGpCC,SAHoC,EAIkC;AACtE,MAAMC,+BAA+B,GAAG,SAAlCA,+BAAkC,CACtCC,KADsC,EAEnC;AACH,QAAMC,kBAAkB,GAAGP,qBAAqB,EAAhD;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,KAAhB,EAAkDC,kBAAlD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,+BAA+B,CAACG,WAAhC,8BAAuE,oCACrEJ,SADqE,CAAvE;AAGA,SAAOC,+BAAP;AACD,CAhBM","sourcesContent":["import React, { useContext } from 'react';\n\nimport Dayjs from 'dayjs';\n\nimport type { TFunction } from 'i18next';\nimport type { Moment } from 'moment';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport const isDayOrMoment = (output: TDateTimeParserOutput): output is Dayjs.Dayjs | Moment =>\n (output as Dayjs.Dayjs | Moment).isSame != null;\n\nexport type TDateTimeParserInput = string | number | Date;\n\nexport type TDateTimeParserOutput = string | number | Date | Dayjs.Dayjs | Moment;\n\nexport type TDateTimeParser = (input?: TDateTimeParserInput) => TDateTimeParserOutput;\n\nexport type TranslationContextValue = {\n t: TFunction | ((key: string) => string);\n tDateTimeParser: TDateTimeParser;\n};\n\nconst defaultTranslationContextValue: TranslationContextValue = {\n t: (key: string) => key,\n tDateTimeParser: (input) => Dayjs(input),\n};\n\nexport const TranslationContext = React.createContext<TranslationContextValue>(\n defaultTranslationContextValue,\n);\n\nexport const TranslationProvider: React.FC<{\n value: TranslationContextValue;\n}> = ({ children, value }) => (\n <TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>\n);\n\nexport const useTranslationContext = () => {\n const contextValue = useContext(TranslationContext);\n\n if (contextValue === defaultTranslationContextValue && !isTestEnvironment()) {\n throw new Error(\n `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`,\n );\n }\n\n return contextValue;\n};\n\nexport const withTranslationContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<StreamChatGenerics>,\n): React.FC<Omit<StreamChatGenerics, keyof TranslationContextValue>> => {\n const WithTranslationContextComponent = (\n props: Omit<StreamChatGenerics, keyof TranslationContextValue>,\n ) => {\n const translationContext = useTranslationContext();\n\n return <Component {...(props as StreamChatGenerics)} {...translationContext} />;\n };\n WithTranslationContextComponent.displayName = `WithTranslationContext${getDisplayName(\n Component as React.ComponentType,\n )}`;\n return WithTranslationContextComponent;\n};\n"]}
|
|
@@ -11,8 +11,12 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
15
|
+
|
|
14
16
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
15
17
|
|
|
18
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
19
|
+
|
|
16
20
|
var _this = this,
|
|
17
21
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/typingContext/TypingContext.tsx";
|
|
18
22
|
|
|
@@ -20,7 +24,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
24
|
|
|
21
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
26
|
|
|
23
|
-
var TypingContext = _react["default"].createContext(
|
|
27
|
+
var TypingContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
24
28
|
|
|
25
29
|
exports.TypingContext = TypingContext;
|
|
26
30
|
|
|
@@ -32,7 +36,7 @@ var TypingProvider = function TypingProvider(_ref) {
|
|
|
32
36
|
__self: _this,
|
|
33
37
|
__source: {
|
|
34
38
|
fileName: _jsxFileName,
|
|
35
|
-
lineNumber:
|
|
39
|
+
lineNumber: 27,
|
|
36
40
|
columnNumber: 3
|
|
37
41
|
}
|
|
38
42
|
}, children);
|
|
@@ -41,7 +45,13 @@ var TypingProvider = function TypingProvider(_ref) {
|
|
|
41
45
|
exports.TypingProvider = TypingProvider;
|
|
42
46
|
|
|
43
47
|
var useTypingContext = function useTypingContext() {
|
|
44
|
-
|
|
48
|
+
var contextValue = (0, _react.useContext)(TypingContext);
|
|
49
|
+
|
|
50
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
51
|
+
throw new Error("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");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return contextValue;
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
exports.useTypingContext = useTypingContext;
|
|
@@ -53,7 +63,7 @@ var withTypingContext = function withTypingContext(Component) {
|
|
|
53
63
|
__self: _this,
|
|
54
64
|
__source: {
|
|
55
65
|
fileName: _jsxFileName,
|
|
56
|
-
lineNumber:
|
|
66
|
+
lineNumber: 64,
|
|
57
67
|
columnNumber: 12
|
|
58
68
|
}
|
|
59
69
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TypingContext.tsx"],"names":["TypingContext","React","createContext","TypingProvider","children","value","useTypingContext","withTypingContext","Component","WithTypingContextComponent","props","typingContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAQO,IAAMA,aAAa,GAAGC,kBAAMC,aAAN,
|
|
1
|
+
{"version":3,"sources":["TypingContext.tsx"],"names":["TypingContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","TypingProvider","children","value","useTypingContext","contextValue","Error","withTypingContext","Component","WithTypingContextComponent","props","typingContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;AAEA;;AACA;;;;;;;;;AAQO,IAAMA,aAAa,GAAGC,kBAAMC,aAAN,CAAoBC,mDAApB,CAAtB;;;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;AAAA,MAG5BC,QAH4B,QAG5BA,QAH4B;AAAA,MAI5BC,KAJ4B,QAI5BA,KAJ4B;AAAA,SAQ5B,gCAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAEA,KAA/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR4B;AAAA,CAAvB;;;;AAaA,IAAME,gBAAgB,GAAG,SAAnBA,gBAAmB,GAEzB;AACL,MAAMC,YAAY,GAAG,uBACnBR,aADmB,CAArB;;AAIA,MAAIQ,YAAY,KAAKL,mDAAjB,IAA+C,CAAC,2CAApD,EAAyE;AACvE,UAAM,IAAIM,KAAJ,4NAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAdM;;;;AAqBA,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,CAI/BC,SAJ+B,EAKqC;AACpE,MAAMC,0BAA0B,GAAG,SAA7BA,0BAA6B,CACjCC,KADiC,EAE9B;AACH,QAAMC,aAAa,GAAGP,gBAAgB,EAAtC;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,KAAhB,EAAiCC,aAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,0BAA0B,CAACG,WAA3B,yBAA6D,oCAAeJ,SAAf,CAA7D;AACA,SAAOC,0BAAP;AACD,CAfM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { ChannelState } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type TypingContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n typing: ChannelState<StreamChatGenerics>['typing'];\n};\n\nexport const TypingContext = React.createContext(DEFAULT_BASE_CONTEXT_VALUE as TypingContextValue);\n\nexport const TypingProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: TypingContextValue<StreamChatGenerics>;\n}>) => (\n <TypingContext.Provider value={value as unknown as TypingContextValue}>\n {children}\n </TypingContext.Provider>\n);\n\nexport const useTypingContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n TypingContext,\n ) as unknown as TypingContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `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`,\n );\n }\n\n return contextValue;\n};\n\n/**\n * Typescript currently does not support partial inference so if TypingContext\n * typing is desired while using the HOC withTypingContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withTypingContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof TypingContextValue<StreamChatGenerics>>> => {\n const WithTypingContextComponent = (\n props: Omit<P, keyof TypingContextValue<StreamChatGenerics>>,\n ) => {\n const typingContext = useTypingContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...typingContext} />;\n };\n WithTypingContextComponent.displayName = `WithTypingContext${getDisplayName(Component)}`;\n return WithTypingContextComponent;\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.DEFAULT_BASE_CONTEXT_VALUE = void 0;
|
|
5
|
+
var DEFAULT_BASE_CONTEXT_VALUE = {};
|
|
6
|
+
exports.DEFAULT_BASE_CONTEXT_VALUE = DEFAULT_BASE_CONTEXT_VALUE;
|
|
7
|
+
//# sourceMappingURL=defaultBaseContextValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["defaultBaseContextValue.ts"],"names":["DEFAULT_BASE_CONTEXT_VALUE"],"mappings":";;;;AAAO,IAAMA,0BAA0B,GAAG,EAAnC","sourcesContent":["export const DEFAULT_BASE_CONTEXT_VALUE = {};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.isTestEnvironment = void 0;
|
|
5
|
+
|
|
6
|
+
var isTestEnvironment = function isTestEnvironment() {
|
|
7
|
+
return process.env.NODE_ENV === 'test';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.isTestEnvironment = isTestEnvironment;
|
|
11
|
+
//# sourceMappingURL=isTestEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isTestEnvironment.ts"],"names":["isTestEnvironment","process","env","NODE_ENV"],"mappings":";;;;;AAAO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,SAAMC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAA/B;AAAA,CAA1B","sourcesContent":["export const isTestEnvironment = () => process.env.NODE_ENV === 'test';\n"]}
|
|
@@ -29,6 +29,9 @@ var setUser = function setUser(client, user) {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
function mockClient(client) {
|
|
32
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
+
var _options$disableAppSe = options.disableAppSettings,
|
|
34
|
+
disableAppSettings = _options$disableAppSe === void 0 ? true : _options$disableAppSe;
|
|
32
35
|
jest.spyOn(client, '_setToken').mockImplementation();
|
|
33
36
|
jest.spyOn(client, '_setupConnection').mockImplementation();
|
|
34
37
|
client.tokenManager = {
|
|
@@ -40,31 +43,53 @@ function mockClient(client) {
|
|
|
40
43
|
})
|
|
41
44
|
};
|
|
42
45
|
client.setUser = setUser.bind(null, client);
|
|
46
|
+
|
|
47
|
+
if (disableAppSettings) {
|
|
48
|
+
client.getAppSettings = jest.fn(function () {
|
|
49
|
+
return {};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
return client;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
var getTestClient = function getTestClient() {
|
|
47
|
-
|
|
57
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
58
|
+
return mockClient(new _streamChat.StreamChat(apiKey), options);
|
|
48
59
|
};
|
|
49
60
|
|
|
50
61
|
exports.getTestClient = getTestClient;
|
|
51
62
|
|
|
52
63
|
var getTestClientWithUser = function () {
|
|
53
64
|
var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(user) {
|
|
54
|
-
var
|
|
65
|
+
var options,
|
|
66
|
+
_options$disableAppSe2,
|
|
67
|
+
disableAppSettings,
|
|
68
|
+
client,
|
|
69
|
+
_args = arguments;
|
|
70
|
+
|
|
55
71
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
56
72
|
while (1) {
|
|
57
73
|
switch (_context.prev = _context.next) {
|
|
58
74
|
case 0:
|
|
75
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
76
|
+
_options$disableAppSe2 = options.disableAppSettings, disableAppSettings = _options$disableAppSe2 === void 0 ? true : _options$disableAppSe2;
|
|
59
77
|
client = mockClient(new _streamChat.StreamChat(apiKey));
|
|
60
|
-
_context.next =
|
|
78
|
+
_context.next = 5;
|
|
61
79
|
return setUser(client, user);
|
|
62
80
|
|
|
63
|
-
case
|
|
81
|
+
case 5:
|
|
64
82
|
client.wsPromise = Promise.resolve();
|
|
83
|
+
|
|
84
|
+
if (disableAppSettings) {
|
|
85
|
+
client.getAppSettings = jest.fn(function () {
|
|
86
|
+
return {};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
65
90
|
return _context.abrupt("return", client);
|
|
66
91
|
|
|
67
|
-
case
|
|
92
|
+
case 8:
|
|
68
93
|
case "end":
|
|
69
94
|
return _context.stop();
|
|
70
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["mock.js"],"names":["apiKey","token","setUser","client","user","Promise","resolve","connectionId","mutes","_user","userID","id","userToken","mockClient","jest","spyOn","mockImplementation","tokenManager","getToken","fn","tokenReady","bind","getTestClient","StreamChat","getTestClientWithUser","wsPromise","getRandomInt","min","max","Math","ceil","floor","random"],"mappings":";;;;;;;;;;;;;AAGA;;AAEA,IAAMA,MAAM,GAAG,SAAf;AACA,IAAMC,KAAK,GAAG,aAAd;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,MAAD,EAASC,IAAT;AAAA,SACd,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AACvBH,IAAAA,MAAM,CAACI,YAAP,GAAsB,oBAAtB;AACAJ,IAAAA,MAAM,CAACC,IAAP,GAAcA,IAAd;AACAD,IAAAA,MAAM,CAACC,IAAP,CAAYI,KAAZ,GAAoB,EAApB;AACAL,IAAAA,MAAM,CAACM,KAAP,iCAAoBL,IAApB;AACAD,IAAAA,MAAM,CAACO,MAAP,GAAgBN,IAAI,CAACO,EAArB;AACAR,IAAAA,MAAM,CAACS,SAAP,GAAmBX,KAAnB;AACAK,IAAAA,OAAO;AACR,GARD,CADc;AAAA,CAAhB;;AAWA,SAASO,UAAT,CAAoBV,MAApB,
|
|
1
|
+
{"version":3,"sources":["mock.js"],"names":["apiKey","token","setUser","client","user","Promise","resolve","connectionId","mutes","_user","userID","id","userToken","mockClient","options","disableAppSettings","jest","spyOn","mockImplementation","tokenManager","getToken","fn","tokenReady","bind","getAppSettings","getTestClient","StreamChat","getTestClientWithUser","wsPromise","getRandomInt","min","max","Math","ceil","floor","random"],"mappings":";;;;;;;;;;;;;AAGA;;AAEA,IAAMA,MAAM,GAAG,SAAf;AACA,IAAMC,KAAK,GAAG,aAAd;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,MAAD,EAASC,IAAT;AAAA,SACd,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AACvBH,IAAAA,MAAM,CAACI,YAAP,GAAsB,oBAAtB;AACAJ,IAAAA,MAAM,CAACC,IAAP,GAAcA,IAAd;AACAD,IAAAA,MAAM,CAACC,IAAP,CAAYI,KAAZ,GAAoB,EAApB;AACAL,IAAAA,MAAM,CAACM,KAAP,iCAAoBL,IAApB;AACAD,IAAAA,MAAM,CAACO,MAAP,GAAgBN,IAAI,CAACO,EAArB;AACAR,IAAAA,MAAM,CAACS,SAAP,GAAmBX,KAAnB;AACAK,IAAAA,OAAO;AACR,GARD,CADc;AAAA,CAAhB;;AAWA,SAASO,UAAT,CAAoBV,MAApB,EAA0C;AAAA,MAAdW,OAAc,uEAAJ,EAAI;AACxC,8BAAsCA,OAAtC,CAAQC,kBAAR;AAAA,MAAQA,kBAAR,sCAA6B,IAA7B;AAEAC,EAAAA,IAAI,CAACC,KAAL,CAAWd,MAAX,EAAmB,WAAnB,EAAgCe,kBAAhC;AACAF,EAAAA,IAAI,CAACC,KAAL,CAAWd,MAAX,EAAmB,kBAAnB,EAAuCe,kBAAvC;AACAf,EAAAA,MAAM,CAACgB,YAAP,GAAsB;AACpBC,IAAAA,QAAQ,EAAEJ,IAAI,CAACK,EAAL,CAAQ;AAAA,aAAMpB,KAAN;AAAA,KAAR,CADU;AAEpBqB,IAAAA,UAAU,EAAEN,IAAI,CAACK,EAAL,CAAQ;AAAA,aAAM,IAAN;AAAA,KAAR;AAFQ,GAAtB;AAIAlB,EAAAA,MAAM,CAACD,OAAP,GAAiBA,OAAO,CAACqB,IAAR,CAAa,IAAb,EAAmBpB,MAAnB,CAAjB;;AAEA,MAAIY,kBAAJ,EAAwB;AACtBZ,IAAAA,MAAM,CAACqB,cAAP,GAAwBR,IAAI,CAACK,EAAL,CAAQ;AAAA,aAAO,EAAP;AAAA,KAAR,CAAxB;AACD;;AAED,SAAOlB,MAAP;AACD;;AAEM,IAAMsB,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAACX,OAAD,uEAAW,EAAX;AAAA,SAAkBD,UAAU,CAAC,IAAIa,sBAAJ,CAAe1B,MAAf,CAAD,EAAyBc,OAAzB,CAA5B;AAAA,CAAtB;;;;AAEA,IAAMa,qBAAqB;AAAA,6EAAG,iBAAOvB,IAAP;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAaU,YAAAA,OAAb,2DAAuB,EAAvB;AAAA,qCACGA,OADH,CAC3BC,kBAD2B,EAC3BA,kBAD2B,uCACN,IADM;AAE7BZ,YAAAA,MAF6B,GAEpBU,UAAU,CAAC,IAAIa,sBAAJ,CAAe1B,MAAf,CAAD,CAFU;AAAA;AAAA,mBAG7BE,OAAO,CAACC,MAAD,EAASC,IAAT,CAHsB;;AAAA;AAInCD,YAAAA,MAAM,CAACyB,SAAP,GAAmBvB,OAAO,CAACC,OAAR,EAAnB;;AAEA,gBAAIS,kBAAJ,EAAwB;AACtBZ,cAAAA,MAAM,CAACqB,cAAP,GAAwBR,IAAI,CAACK,EAAL,CAAQ;AAAA,uBAAO,EAAP;AAAA,eAAR,CAAxB;AACD;;AARkC,6CAU5BlB,MAV4B;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAH;;AAAA,kBAArBwB,qBAAqB;AAAA;AAAA;AAAA,GAA3B;;;;AAaA,IAAME,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAMC,GAAN,EAAc;AACxCD,EAAAA,GAAG,GAAGE,IAAI,CAACC,IAAL,CAAUH,GAAV,CAAN;AACAC,EAAAA,GAAG,GAAGC,IAAI,CAACE,KAAL,CAAWH,GAAX,CAAN;AACA,SAAOC,IAAI,CAACE,KAAL,CAAWF,IAAI,CAACG,MAAL,MAAiBJ,GAAG,GAAGD,GAAvB,CAAX,IAA0CA,GAAjD;AACD,CAJM","sourcesContent":["/* eslint no-underscore-dangle: 0 */\n/* eslint no-param-reassign: 0 */\n\nimport { StreamChat } from 'stream-chat';\n\nconst apiKey = 'API_KEY';\nconst token = 'dummy_token';\n\nconst setUser = (client, user) =>\n new Promise((resolve) => {\n client.connectionId = 'dumm_connection_id';\n client.user = user;\n client.user.mutes = [];\n client._user = { ...user };\n client.userID = user.id;\n client.userToken = token;\n resolve();\n });\n\nfunction mockClient(client, options = {}) {\n const { disableAppSettings = true } = options;\n\n jest.spyOn(client, '_setToken').mockImplementation();\n jest.spyOn(client, '_setupConnection').mockImplementation();\n client.tokenManager = {\n getToken: jest.fn(() => token),\n tokenReady: jest.fn(() => true),\n };\n client.setUser = setUser.bind(null, client);\n\n if (disableAppSettings) {\n client.getAppSettings = jest.fn(() => ({}));\n }\n\n return client;\n}\n\nexport const getTestClient = (options = {}) => mockClient(new StreamChat(apiKey), options);\n\nexport const getTestClientWithUser = async (user, options = {}) => {\n const { disableAppSettings = true } = options;\n const client = mockClient(new StreamChat(apiKey));\n await setUser(client, user);\n client.wsPromise = Promise.resolve();\n\n if (disableAppSettings) {\n client.getAppSettings = jest.fn(() => ({}));\n }\n\n return client;\n};\n\nexport const getRandomInt = (min, max) => {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(Math.random() * (max - min)) + min; // The maximum is exclusive and the minimum is inclusive\n};\n"]}
|
package/lib/module/native.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", {
|
|
2
2
|
value: true
|
|
3
3
|
});
|
|
4
|
-
exports.triggerHaptic = exports.takePhoto = exports.shareImage = exports.saveFile = exports.registerNativeHandlers = exports.pickDocument = exports.getPhotos = exports.getLocalAssetUri = exports.deleteFile = exports.compressImage = exports.Video = exports.SDK = exports.NetInfo = exports.FlatList = void 0;
|
|
4
|
+
exports.triggerHaptic = exports.takePhoto = exports.shareImage = exports.saveFile = exports.registerNativeHandlers = exports.pickDocument = exports.isVideoPackageAvailable = exports.getPhotos = exports.getLocalAssetUri = exports.deleteFile = exports.compressImage = exports.Video = exports.SDK = exports.NetInfo = exports.FlatList = void 0;
|
|
5
5
|
|
|
6
6
|
var _reactNative = require("react-native");
|
|
7
7
|
|
|
@@ -36,7 +36,7 @@ var triggerHaptic = fail;
|
|
|
36
36
|
exports.triggerHaptic = triggerHaptic;
|
|
37
37
|
var SDK;
|
|
38
38
|
exports.SDK = SDK;
|
|
39
|
-
var Video
|
|
39
|
+
var Video;
|
|
40
40
|
exports.Video = Video;
|
|
41
41
|
|
|
42
42
|
var registerNativeHandlers = function registerNativeHandlers(handlers) {
|
|
@@ -98,4 +98,10 @@ var registerNativeHandlers = function registerNativeHandlers(handlers) {
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
exports.registerNativeHandlers = registerNativeHandlers;
|
|
101
|
+
|
|
102
|
+
var isVideoPackageAvailable = function isVideoPackageAvailable() {
|
|
103
|
+
return !!Video;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.isVideoPackageAvailable = isVideoPackageAvailable;
|
|
101
107
|
//# sourceMappingURL=native.js.map
|
package/lib/module/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["native.ts"],"names":["fail","Error","compressImage","deleteFile","getLocalAssetUri","getPhotos","FlatList","DefaultFlatList","NetInfo","addEventListener","fetch","pickDocument","saveFile","shareImage","takePhoto","triggerHaptic","SDK","Video","registerNativeHandlers","handlers"],"mappings":";;;;;AACA;;AAMA,IAAMA,IAAI,GAAG,SAAPA,IAAO,GAAM;AACjB,QAAMC,KAAK,CACT,mGADS,CAAX;AAGD,CAJD;;AAiBO,IAAIC,aAA4B,GAAGF,IAAnC;;AAGA,IAAIG,UAAsB,GAAGH,IAA7B;;AAGA,IAAII,gBAAkC,GAAGJ,IAAzC;;AASA,IAAIK,SAAoB,GAAGL,IAA3B;;AAOA,IAAIM,QAAQ,GAAGC,qBAAf;;AAEA,IAAIC,OAAgB,GAAG;AAC5BC,EAAAA,gBAAgB,EAAET,IADU;AAE5BU,EAAAA,KAAK,EAAEV;AAFqB,CAAvB;;AAWA,IAAIW,YAA0B,GAAGX,IAAjC;;AAOA,IAAIY,QAAkB,GAAGZ,IAAzB;;AAOA,IAAIa,UAAsB,GAAGb,IAA7B;;AASA,IAAIc,SAAoB,GAAGd,IAA3B;;AAWA,IAAIe,aAA4B,GAAGf,IAAnC;;AAEA,IAAIgB,GAAJ;;AAoDA,IAAIC,
|
|
1
|
+
{"version":3,"sources":["native.ts"],"names":["fail","Error","compressImage","deleteFile","getLocalAssetUri","getPhotos","FlatList","DefaultFlatList","NetInfo","addEventListener","fetch","pickDocument","saveFile","shareImage","takePhoto","triggerHaptic","SDK","Video","registerNativeHandlers","handlers","isVideoPackageAvailable"],"mappings":";;;;;AACA;;AAMA,IAAMA,IAAI,GAAG,SAAPA,IAAO,GAAM;AACjB,QAAMC,KAAK,CACT,mGADS,CAAX;AAGD,CAJD;;AAiBO,IAAIC,aAA4B,GAAGF,IAAnC;;AAGA,IAAIG,UAAsB,GAAGH,IAA7B;;AAGA,IAAII,gBAAkC,GAAGJ,IAAzC;;AASA,IAAIK,SAAoB,GAAGL,IAA3B;;AAOA,IAAIM,QAAQ,GAAGC,qBAAf;;AAEA,IAAIC,OAAgB,GAAG;AAC5BC,EAAAA,gBAAgB,EAAET,IADU;AAE5BU,EAAAA,KAAK,EAAEV;AAFqB,CAAvB;;AAWA,IAAIW,YAA0B,GAAGX,IAAjC;;AAOA,IAAIY,QAAkB,GAAGZ,IAAzB;;AAOA,IAAIa,UAAsB,GAAGb,IAA7B;;AASA,IAAIc,SAAoB,GAAGd,IAA3B;;AAWA,IAAIe,aAA4B,GAAGf,IAAnC;;AAEA,IAAIgB,GAAJ;;AAoDA,IAAIC,KAAJ;;;AAkBA,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAyB,CAACC,QAAD,EAAwB;AAC5D,MAAIA,QAAQ,CAACjB,aAAb,EAA4B;AAC1B,4BAAAA,aAAa,GAAGiB,QAAQ,CAACjB,aAAzB;AACD;;AAED,MAAIiB,QAAQ,CAAChB,UAAb,EAAyB;AACvB,yBAAAA,UAAU,GAAGgB,QAAQ,CAAChB,UAAtB;AACD;;AAED,MAAIgB,QAAQ,CAACb,QAAb,EAAuB;AACrB,uBAAAA,QAAQ,GAAGa,QAAQ,CAACb,QAApB;AACD;;AACD,MAAIa,QAAQ,CAACX,OAAb,EAAsB;AACpB,sBAAAA,OAAO,GAAGW,QAAQ,CAACX,OAAnB;AACD;;AAED,MAAIW,QAAQ,CAACf,gBAAb,EAA+B;AAC7B,+BAAAA,gBAAgB,GAAGe,QAAQ,CAACf,gBAA5B;AACD;;AAED,MAAIe,QAAQ,CAACd,SAAb,EAAwB;AACtB,wBAAAA,SAAS,GAAGc,QAAQ,CAACd,SAArB;AACD;;AAED,MAAIc,QAAQ,CAACX,OAAb,EAAsB;AACpB,sBAAAA,OAAO,GAAGW,QAAQ,CAACX,OAAnB;AACD;;AAED,MAAIW,QAAQ,CAACR,YAAb,EAA2B;AACzB,2BAAAA,YAAY,GAAGQ,QAAQ,CAACR,YAAxB;AACD;;AAED,MAAIQ,QAAQ,CAACP,QAAb,EAAuB;AACrB,uBAAAA,QAAQ,GAAGO,QAAQ,CAACP,QAApB;AACD;;AAED,MAAIO,QAAQ,CAACH,GAAb,EAAkB;AAChB,kBAAAA,GAAG,GAAGG,QAAQ,CAACH,GAAf;AACD;;AAED,MAAIG,QAAQ,CAACN,UAAb,EAAyB;AACvB,yBAAAA,UAAU,GAAGM,QAAQ,CAACN,UAAtB;AACD;;AAED,MAAIM,QAAQ,CAACL,SAAb,EAAwB;AACtB,wBAAAA,SAAS,GAAGK,QAAQ,CAACL,SAArB;AACD;;AAED,MAAIK,QAAQ,CAACJ,aAAb,EAA4B;AAC1B,4BAAAA,aAAa,GAAGI,QAAQ,CAACJ,aAAzB;AACD;;AAED,MAAII,QAAQ,CAACF,KAAb,EAAoB;AAClB,oBAAAA,KAAK,GAAGE,QAAQ,CAACF,KAAjB;AACD;AACF,CAvDM;;;;AAyDA,IAAMG,uBAAuB,GAAG,SAA1BA,uBAA0B;AAAA,SAAM,CAAC,CAACH,KAAR;AAAA,CAAhC","sourcesContent":["import type React from 'react';\nimport { FlatList as DefaultFlatList, StyleProp, ViewStyle } from 'react-native';\n\nimport type { NetInfoSubscription } from '@react-native-community/netinfo';\n\nimport type { Asset, File } from './types/types';\n\nconst fail = () => {\n throw Error(\n 'Native handler was not registered, you should import stream-chat-expo or stream-chat-react-native',\n );\n};\n\ntype CompressImage = ({\n compressImageQuality,\n height,\n uri,\n width,\n}: {\n compressImageQuality: number;\n height: number;\n uri: string;\n width: number;\n}) => Promise<string> | never;\nexport let compressImage: CompressImage = fail;\n\ntype DeleteFile = ({ uri }: { uri: string }) => Promise<boolean> | never;\nexport let deleteFile: DeleteFile = fail;\n\ntype GetLocalAssetUri = (uriOrAssetId: string) => never;\nexport let getLocalAssetUri: GetLocalAssetUri = fail;\n\ntype GetPhotos = ({ after, first }: { first: number; after?: string }) =>\n | Promise<{\n assets: Array<Omit<Asset, 'source'> & { source: 'picker' }>;\n endCursor: string;\n hasNextPage: boolean;\n }>\n | never;\nexport let getPhotos: GetPhotos = fail;\n\ntype NetInfo = {\n addEventListener: (listener: (isConnected: boolean) => void) => NetInfoSubscription | never;\n fetch: (requestedInterface?: string | undefined) => Promise<boolean> | never;\n};\n\nexport let FlatList = DefaultFlatList;\n\nexport let NetInfo: NetInfo = {\n addEventListener: fail,\n fetch: fail,\n};\n\ntype PickDocument = ({ maxNumberOfFiles }: { maxNumberOfFiles?: number }) =>\n | Promise<{\n cancelled: boolean;\n docs?: File[];\n }>\n | never;\nexport let pickDocument: PickDocument = fail;\n\ntype SaveFileOptions = {\n fileName: string;\n fromUrl: string;\n};\ntype SaveFile = (options: SaveFileOptions) => Promise<string> | never;\nexport let saveFile: SaveFile = fail;\n\ntype ShareOptions = {\n type?: string;\n url?: string;\n};\ntype ShareImage = (options: ShareOptions) => Promise<boolean> | never;\nexport let shareImage: ShareImage = fail;\n\ntype Photo =\n | (Omit<Asset, 'source'> & {\n cancelled: false;\n source: 'camera';\n })\n | { cancelled: true };\ntype TakePhoto = (options: { compressImageQuality?: number }) => Promise<Photo> | never;\nexport let takePhoto: TakePhoto = fail;\n\ntype HapticFeedbackMethod =\n | 'impactHeavy'\n | 'impactLight'\n | 'impactMedium'\n | 'notificationError'\n | 'notificationSuccess'\n | 'notificationWarning'\n | 'selection';\ntype TriggerHaptic = (method: HapticFeedbackMethod) => void | never;\nexport let triggerHaptic: TriggerHaptic = fail;\n\nexport let SDK: string;\n\nexport type PlaybackStatus = {\n didJustFinish: boolean;\n durationMillis: number;\n error: string;\n isBuffering: boolean;\n isLoaded: boolean;\n isLooping: boolean;\n isPlaying: boolean;\n positionMillis: number;\n};\n\nexport type VideoProgressData = {\n currentTime?: number;\n playableDuration?: number;\n seekableDuration?: number;\n};\n\nexport type VideoPayloadData = {\n audioTracks?: { index: number; language: string; title: string; type: string }[];\n currentPosition?: number;\n duration?: number;\n naturalSize?: { height: number; orientation: 'portrait' | 'landscape'; width: number };\n textTracks?: { index: number; language: string; title: string; type: string }[];\n videoTracks?: {\n bitrate: number;\n codecs: string;\n height: number;\n trackId: number;\n width: number;\n }[];\n};\n\nexport type VideoType = {\n paused: boolean;\n uri: string;\n videoRef: React.RefObject<VideoType>;\n onBuffer?: (props: { isBuffering: boolean }) => void;\n onEnd?: () => void;\n onLoad?: (payload: VideoPayloadData) => void;\n onLoadStart?: () => void;\n onPlaybackStatusUpdate?: (playbackStatus: PlaybackStatus) => void;\n onProgress?: (data: VideoProgressData) => void;\n onReadyForDisplay?: () => void;\n replayAsync?: () => void;\n resizeMode?: string;\n seek?: (progress: number) => void;\n setPositionAsync?: (position: number) => void;\n style?: StyleProp<ViewStyle>;\n};\n\nexport let Video: React.ComponentType<VideoType>;\n\ntype Handlers = {\n compressImage?: CompressImage;\n deleteFile?: DeleteFile;\n FlatList?: typeof DefaultFlatList;\n getLocalAssetUri?: GetLocalAssetUri;\n getPhotos?: GetPhotos;\n NetInfo?: NetInfo;\n pickDocument?: PickDocument;\n saveFile?: SaveFile;\n SDK?: string;\n shareImage?: ShareImage;\n takePhoto?: TakePhoto;\n triggerHaptic?: TriggerHaptic;\n Video?: React.ComponentType<VideoType>;\n};\n\nexport const registerNativeHandlers = (handlers: Handlers) => {\n if (handlers.compressImage) {\n compressImage = handlers.compressImage;\n }\n\n if (handlers.deleteFile) {\n deleteFile = handlers.deleteFile;\n }\n\n if (handlers.FlatList) {\n FlatList = handlers.FlatList;\n }\n if (handlers.NetInfo) {\n NetInfo = handlers.NetInfo;\n }\n\n if (handlers.getLocalAssetUri) {\n getLocalAssetUri = handlers.getLocalAssetUri;\n }\n\n if (handlers.getPhotos) {\n getPhotos = handlers.getPhotos;\n }\n\n if (handlers.NetInfo) {\n NetInfo = handlers.NetInfo;\n }\n\n if (handlers.pickDocument) {\n pickDocument = handlers.pickDocument;\n }\n\n if (handlers.saveFile) {\n saveFile = handlers.saveFile;\n }\n\n if (handlers.SDK) {\n SDK = handlers.SDK;\n }\n\n if (handlers.shareImage) {\n shareImage = handlers.shareImage;\n }\n\n if (handlers.takePhoto) {\n takePhoto = handlers.takePhoto;\n }\n\n if (handlers.triggerHaptic) {\n triggerHaptic = handlers.triggerHaptic;\n }\n\n if (handlers.Video) {\n Video = handlers.Video;\n }\n};\n\nexport const isVideoPackageAvailable = () => !!Video;\n"]}
|
package/lib/module/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const openUrlSafely: (url?: string | undefined) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,9 +3,13 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
|
3
3
|
export declare type KeyboardContextValue = {
|
|
4
4
|
dismissKeyboard: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare const KeyboardContext: React.Context<
|
|
6
|
+
export declare const KeyboardContext: React.Context<{
|
|
7
|
+
dismissKeyboard: () => void;
|
|
8
|
+
}>;
|
|
7
9
|
export declare const KeyboardProvider: React.FC<{
|
|
8
10
|
value: KeyboardContextValue;
|
|
9
11
|
}>;
|
|
10
|
-
export declare const useKeyboardContext: () =>
|
|
12
|
+
export declare const useKeyboardContext: () => {
|
|
13
|
+
dismissKeyboard: () => void;
|
|
14
|
+
};
|
|
11
15
|
export declare const withKeyboardContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(Component: React.ComponentType<StreamChatGenerics>) => React.FC<Omit<StreamChatGenerics, "dismissKeyboard">>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { Theme } from './utils/theme';
|
|
3
3
|
export declare type DeepPartial<T> = {
|
|
4
4
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
@@ -11,9 +11,12 @@ export declare type MergedThemesParams = {
|
|
|
11
11
|
style?: DeepPartial<Theme>;
|
|
12
12
|
theme?: Theme;
|
|
13
13
|
};
|
|
14
|
+
export declare type ThemeContextValue = {
|
|
15
|
+
theme: Theme;
|
|
16
|
+
};
|
|
14
17
|
export declare const mergeThemes: (params: MergedThemesParams) => Theme;
|
|
15
18
|
export declare const ThemeContext: React.Context<Theme>;
|
|
16
|
-
export declare const ThemeProvider: React.FC<ThemeProviderInputValue
|
|
19
|
+
export declare const ThemeProvider: React.FC<PropsWithChildren<ThemeProviderInputValue & Partial<ThemeContextValue>>>;
|
|
17
20
|
export declare const useTheme: () => {
|
|
18
21
|
theme: Theme;
|
|
19
22
|
};
|
|
@@ -373,6 +373,12 @@ export declare type Theme = {
|
|
|
373
373
|
title: TextStyle;
|
|
374
374
|
};
|
|
375
375
|
noURI: ViewStyle;
|
|
376
|
+
playButtonStyle: {
|
|
377
|
+
durationTextStyle: TextStyle;
|
|
378
|
+
roundedView: ViewStyle;
|
|
379
|
+
videoContainer: ViewStyle;
|
|
380
|
+
};
|
|
381
|
+
playIcon: IconProps;
|
|
376
382
|
};
|
|
377
383
|
container: ViewStyle;
|
|
378
384
|
content: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_BASE_CONTEXT_VALUE: {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isTestEnvironment: () => boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function getTestClient(): any;
|
|
2
|
-
export function getTestClientWithUser(user: any): Promise<any>;
|
|
1
|
+
export function getTestClient(options?: {}): any;
|
|
2
|
+
export function getTestClientWithUser(user: any, options?: {}): Promise<any>;
|
|
3
3
|
export function getRandomInt(min: any, max: any): any;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "4.7.
|
|
4
|
+
"version": "4.7.1-beta.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
MessagesContextValue,
|
|
12
12
|
useMessagesContext,
|
|
13
13
|
} from '../../contexts/messagesContext/MessagesContext';
|
|
14
|
+
import { isVideoPackageAvailable } from '../../native';
|
|
14
15
|
|
|
15
16
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
16
17
|
|
|
@@ -76,13 +77,15 @@ const AttachmentWithContext = <
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
if (attachment.type === 'video' && !attachment.og_scrape_url) {
|
|
79
|
-
return (
|
|
80
|
+
return isVideoPackageAvailable() ? (
|
|
80
81
|
<>
|
|
81
82
|
<Gallery videos={[attachment]} />
|
|
82
83
|
{hasAttachmentActions && (
|
|
83
84
|
<AttachmentActions key={`key-actions-${attachment.id}`} {...attachment} />
|
|
84
85
|
)}
|
|
85
86
|
</>
|
|
87
|
+
) : (
|
|
88
|
+
<FileAttachment attachment={attachment} />
|
|
86
89
|
);
|
|
87
90
|
}
|
|
88
91
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
ImageBackground,
|
|
4
4
|
ImageStyle,
|
|
5
5
|
StyleProp,
|
|
6
6
|
StyleSheet,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import type { Attachment } from 'stream-chat';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { openUrlSafely } from './utils/openUrlSafely';
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
MessageContextValue,
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
useMessagesContext,
|
|
25
25
|
} from '../../contexts/messagesContext/MessagesContext';
|
|
26
26
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
27
|
+
import { Play } from '../../icons/Play';
|
|
27
28
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
28
29
|
import { makeImageCompatibleUrl } from '../../utils/utils';
|
|
29
30
|
|
|
@@ -41,13 +42,15 @@ const styles = StyleSheet.create({
|
|
|
41
42
|
},
|
|
42
43
|
authorNameMask: {
|
|
43
44
|
bottom: 0,
|
|
44
|
-
left:
|
|
45
|
+
left: 2,
|
|
45
46
|
position: 'absolute',
|
|
46
47
|
},
|
|
47
48
|
cardCover: {
|
|
49
|
+
alignItems: 'center',
|
|
48
50
|
borderRadius: 8,
|
|
49
51
|
height: 140,
|
|
50
|
-
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
marginHorizontal: 2,
|
|
51
54
|
},
|
|
52
55
|
cardFooter: {
|
|
53
56
|
flexDirection: 'row',
|
|
@@ -62,6 +65,14 @@ const styles = StyleSheet.create({
|
|
|
62
65
|
fontSize: 12,
|
|
63
66
|
marginHorizontal: 8,
|
|
64
67
|
},
|
|
68
|
+
playButtonStyle: {
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
borderRadius: 50,
|
|
71
|
+
elevation: 2,
|
|
72
|
+
height: 36,
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
width: 36,
|
|
75
|
+
},
|
|
65
76
|
title: {
|
|
66
77
|
fontSize: 12,
|
|
67
78
|
marginHorizontal: 8,
|
|
@@ -116,11 +127,12 @@ const CardWithContext = <
|
|
|
116
127
|
text,
|
|
117
128
|
thumb_url,
|
|
118
129
|
title,
|
|
130
|
+
type,
|
|
119
131
|
} = props;
|
|
120
132
|
|
|
121
133
|
const {
|
|
122
134
|
theme: {
|
|
123
|
-
colors: { accent_blue, black, blue_alice, transparent },
|
|
135
|
+
colors: { accent_blue, black, blue_alice, transparent, white },
|
|
124
136
|
messageSimple: {
|
|
125
137
|
card: {
|
|
126
138
|
authorName,
|
|
@@ -132,6 +144,8 @@ const CardWithContext = <
|
|
|
132
144
|
cover,
|
|
133
145
|
footer: { description, title: titleStyle, ...footerStyle },
|
|
134
146
|
noURI,
|
|
147
|
+
playButtonStyle: { roundedView },
|
|
148
|
+
playIcon: { height, width },
|
|
135
149
|
},
|
|
136
150
|
},
|
|
137
151
|
},
|
|
@@ -139,9 +153,9 @@ const CardWithContext = <
|
|
|
139
153
|
|
|
140
154
|
const uri = image_url || thumb_url;
|
|
141
155
|
|
|
142
|
-
const
|
|
156
|
+
const defaultOnPress = () => openUrlSafely(og_scrape_url || uri);
|
|
143
157
|
|
|
144
|
-
const
|
|
158
|
+
const isVideoCard = type === 'video' && og_scrape_url;
|
|
145
159
|
|
|
146
160
|
return (
|
|
147
161
|
<TouchableOpacity
|
|
@@ -183,11 +197,18 @@ const CardWithContext = <
|
|
|
183
197
|
{CardCover && <CardCover {...props} />}
|
|
184
198
|
{uri && !CardCover && (
|
|
185
199
|
<View>
|
|
186
|
-
<
|
|
200
|
+
<ImageBackground
|
|
201
|
+
imageStyle={styles.cardCover}
|
|
187
202
|
resizeMode='cover'
|
|
188
203
|
source={{ uri: makeImageCompatibleUrl(uri) }}
|
|
189
204
|
style={[styles.cardCover, cover, stylesProp.cardCover]}
|
|
190
|
-
|
|
205
|
+
>
|
|
206
|
+
{isVideoCard ? (
|
|
207
|
+
<View style={[styles.playButtonStyle, roundedView, { backgroundColor: white }]}>
|
|
208
|
+
<Play height={height} pathFill={black} width={width} />
|
|
209
|
+
</View>
|
|
210
|
+
) : null}
|
|
211
|
+
</ImageBackground>
|
|
191
212
|
{author_name && (
|
|
192
213
|
<View style={[styles.authorNameMask, authorNameMask, stylesProp.authorNameMask]}>
|
|
193
214
|
<View
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import type { Attachment } from 'stream-chat';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { openUrlSafely } from './utils/openUrlSafely';
|
|
15
15
|
|
|
16
16
|
import { AttachmentActions as AttachmentActionsDefault } from '../../components/Attachment/AttachmentActions';
|
|
17
17
|
import { FileIcon as FileIconDefault } from '../../components/Attachment/FileIcon';
|
|
@@ -95,9 +95,7 @@ const FileAttachmentWithContext = <
|
|
|
95
95
|
},
|
|
96
96
|
} = useTheme();
|
|
97
97
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const defaultOnPress = () => !error && openURL && openURL();
|
|
98
|
+
const defaultOnPress = () => openUrlSafely(attachment.asset_url);
|
|
101
99
|
|
|
102
100
|
return (
|
|
103
101
|
<TouchableOpacity
|