File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
Sources/StreamChatSwiftUI/ChatChannel/Composer Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,17 @@ public struct AttachmentPickerView<Factory: ViewFactory>: View {
38
38
if selectedPickerState == . photos {
39
39
if let assets = photoLibraryAssets,
40
40
let collection = PHFetchResultCollection ( fetchResult: assets) {
41
- viewFactory. makePhotoAttachmentPickerView (
42
- assets: collection,
43
- onAssetTap: onAssetTap,
44
- isAssetSelected: isAssetSelected
45
- )
41
+ if !collection. isEmpty {
42
+ viewFactory. makePhotoAttachmentPickerView (
43
+ assets: collection,
44
+ onAssetTap: onAssetTap,
45
+ isAssetSelected: isAssetSelected
46
+ )
47
+ } else {
48
+ viewFactory. makeAssetsAccessPermissionView ( )
49
+ }
46
50
} else {
47
- viewFactory . makeAssetsAccessPermissionView ( )
51
+ LoadingView ( )
48
52
}
49
53
50
54
} else if selectedPickerState == . files {
Original file line number Diff line number Diff line change @@ -383,12 +383,15 @@ open class MessageComposerViewModel: ObservableObject {
383
383
log. debug ( " Access to photos granted. " )
384
384
let fetchOptions = PHFetchOptions ( )
385
385
fetchOptions. sortDescriptors = [ NSSortDescriptor ( key: " creationDate " , ascending: false ) ]
386
- DispatchQueue . main. async { [ unowned self] in
387
- self . imageAssets = PHAsset . fetchAssets ( with: fetchOptions)
386
+ let assets = PHAsset . fetchAssets ( with: fetchOptions)
387
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.25 ) { [ weak self] in
388
+ self ? . imageAssets = assets
388
389
}
389
390
case . denied, . restricted:
391
+ self . imageAssets = PHFetchResult < PHAsset > ( )
390
392
log. debug ( " Access to photos is denied, showing the no permissions screen. " )
391
393
case . notDetermined:
394
+ self . imageAssets = PHFetchResult < PHAsset > ( )
392
395
log. debug ( " Access to photos is still not determined. " )
393
396
@unknown default :
394
397
log. debug ( " Unknown authorization status. " )
You can’t perform that action at this time.
0 commit comments