@supportworks/multi-imagepicker 8.0.17 → 8.0.18

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/changes.md CHANGED
@@ -1,4 +1,7 @@
1
1
 
2
+ # v8.0.18 2026-03-25
3
+ * refactored attaching
4
+
2
5
  # v8.0.17 2026-03-25
3
6
  * removed CRM modal to see if that fixes it
4
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "8.0.17",
3
+ "version": "8.0.18",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -33,6 +33,7 @@ const AddImages = forwardRef((
33
33
  }, ref) => {
34
34
  const [showAttaching, setShowAttaching] = useState(false)
35
35
  const [showAdd, setShowAdd] = useState(false)
36
+ const [pendingAttach, setPendingAttach] = useState(false)
36
37
  const [showInfoDialog, setShowInfoDialog] = useState(false)
37
38
  const [allImageDataValid, setAllImageDataValid] = useState(true)
38
39
  const [showToCust, setShowToCust] = useState(false)
@@ -135,31 +136,59 @@ const AddImages = forwardRef((
135
136
  }
136
137
  }, [addPicture, prospectInst, hasAndroidWritePermission, showToCust, saveToDevice, allowSaveToDevice])
137
138
 
138
- const onAttach = useCallback(async () => {
139
+ const performAttach = useCallback(async () => {
139
140
  if (!isMountedRef.current) {
140
141
  return
141
142
  }
142
143
 
143
- setShowAttaching(false)
144
- setShowAdd(false)
144
+ setShowAttaching(true)
145
145
 
146
- await addPicturesToProject()
147
- if (allowEdit && allowSaveToDevice) {
148
- await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
146
+ try {
147
+ await addPicturesToProject()
148
+ if (allowEdit && allowSaveToDevice) {
149
+ await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
150
+ }
151
+ if (allowEdit && showToCustomerAllowed) {
152
+ await Api.getApi().setDefaultShowToCustomer(showToCust)
153
+ }
154
+ Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
155
+ if (callback) {
156
+ callback()
157
+ }
158
+ } finally {
159
+ if (isMountedRef.current) {
160
+ setShowAttaching(false)
161
+ setPendingAttach(false)
162
+ }
149
163
  }
150
- if (allowEdit && showToCustomerAllowed) {
151
- await Api.getApi().setDefaultShowToCustomer(showToCust)
164
+ }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
165
+
166
+ const onAttach = useCallback(() => {
167
+ if (!isMountedRef.current) {
168
+ return
152
169
  }
153
- Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
154
- if (callback) {
155
- callback()
170
+
171
+ if (Platform.OS === 'ios' && showAdd) {
172
+ setPendingAttach(true)
173
+ setShowAdd(false)
174
+ return
156
175
  }
157
- }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
176
+
177
+ void performAttach()
178
+ }, [performAttach, showAdd])
179
+
180
+ const onAddModalDismiss = useCallback(() => {
181
+ if (!pendingAttach) {
182
+ return
183
+ }
184
+ void performAttach()
185
+ }, [pendingAttach, performAttach])
158
186
 
159
187
  const onClose = useCallback(() => {
160
188
  if (!isMountedRef.current) {
161
189
  return
162
190
  }
191
+ setPendingAttach(false)
163
192
  setShowAttaching(false)
164
193
  setShowAdd(false)
165
194
  }, [])
@@ -413,9 +442,15 @@ const AddImages = forwardRef((
413
442
  )
414
443
  }
415
444
 
416
- if (showAdd) {
417
- return (
418
- <Modal presentationStyle='fullScreen' animationType='slide'>
445
+ return (
446
+ <>
447
+ {!showAdd && (
448
+ <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
449
+ {children}
450
+ </MultiImagePicker>
451
+ )}
452
+
453
+ <Modal visible={showAdd} presentationStyle='fullScreen' animationType='slide' onDismiss={onAddModalDismiss}>
419
454
  <ScreenSafeAreaView style={styles.Page} edges={['top','bottom']} includeProvider>
420
455
  <AppBarH8
421
456
  variant='regular'
@@ -460,13 +495,7 @@ const AddImages = forwardRef((
460
495
  />
461
496
  )}
462
497
  </Modal>
463
- )
464
- }
465
-
466
- return (
467
- <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
468
- {children}
469
- </MultiImagePicker>
498
+ </>
470
499
  )
471
500
  })
472
501