@kontextso/sdk-react-native 2.2.0-rc.1 → 2.2.0-rc.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontextso/sdk-react-native",
3
- "version": "2.2.0-rc.1",
3
+ "version": "2.2.0-rc.2",
4
4
  "description": "Kontext SDK for React Native",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -59,6 +59,7 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
59
59
  const webViewRef = useRef<WebView>(null)
60
60
  const modalWebViewRef = useRef<WebView>(null)
61
61
  const modalInitTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
62
+ const isModalInitRef = useRef<boolean>(false)
62
63
 
63
64
  const { height: windowHeight, width: windowWidth } = useWindowDimensions()
64
65
 
@@ -79,6 +80,7 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
79
80
  modalInitTimeoutRef.current = null
80
81
  }
81
82
 
83
+ isModalInitRef.current = false
82
84
  setModalOpen(false)
83
85
  setModalLoaded(false)
84
86
  setModalShown(false)
@@ -175,7 +177,11 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
175
177
  case 'open-component-iframe':
176
178
  setModalOpen(true)
177
179
 
178
- modalInitTimeoutRef.current = setTimeout(resetModal, message.data.timeout ?? 5000)
180
+ modalInitTimeoutRef.current = setTimeout(() => {
181
+ if (!isModalInitRef.current) {
182
+ resetModal()
183
+ }
184
+ }, message.data.timeout ?? 5000)
179
185
  break
180
186
  }
181
187
  },
@@ -209,6 +215,9 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
209
215
  break
210
216
 
211
217
  case 'init-component-iframe':
218
+ // Just clearing the timeoutRef didn't work in Android, so we need to set a flag and check it in the timeout callback
219
+ isModalInitRef.current = true
220
+
212
221
  if (modalInitTimeoutRef.current) {
213
222
  clearTimeout(modalInitTimeoutRef.current)
214
223
  modalInitTimeoutRef.current = null
@@ -220,6 +229,7 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
220
229
  case 'error-component-iframe':
221
230
  case 'error-iframe':
222
231
  resetModal()
232
+ context?.captureError(new Error('Processing modal iframe error'))
223
233
  break
224
234
 
225
235
  case 'click-iframe':
@@ -304,7 +314,13 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
304
314
 
305
315
  const content = (
306
316
  <>
307
- <Modal visible={modalOpen} transparent={true} onRequestClose={resetModal}>
317
+ <Modal
318
+ visible={modalOpen}
319
+ transparent={true}
320
+ onRequestClose={resetModal}
321
+ animationType="slide"
322
+ statusBarTranslucent={true}
323
+ >
308
324
  <View
309
325
  style={{
310
326
  flex: 1,
@@ -342,7 +358,7 @@ const Format = ({ code, messageId, wrapper, ...otherParams }: FormatProps) => {
342
358
  style={{
343
359
  height: getHeight(),
344
360
  width: getWidth(),
345
- background: 'transparent',
361
+ backgroundColor: 'transparent',
346
362
  borderWidth: 0,
347
363
  ...iframeStyles,
348
364
  }}