@@ -341,15 +341,17 @@ struct PhotoBackupSettingsView: View {
341341 authorizationStatus = PHPhotoLibrary . authorizationStatus ( )
342342 self . folders = await appState. folders ( ) . filter ( { $0. isSuitablePhotoBackupDestination } ) . sorted ( )
343343 if self . authorizationStatus == . authorized {
344- self . loadAlbums ( )
344+ await self . loadAlbums ( )
345345 }
346346 else {
347347 self . albums = [ ]
348348 self . smartAlbums = [ ]
349349 }
350350 }
351351
352- private func loadAlbums( ) {
352+ @concurrent private func loadAlbums( ) async {
353+ dispatchPrecondition ( condition: . notOnQueue( . main) )
354+
353355 var albums : [ PHAssetCollection ] = [ ]
354356 let options = PHFetchOptions ( )
355357 options. sortDescriptors = [ NSSortDescriptor ( key: " localizedTitle " , ascending: true ) ]
@@ -358,7 +360,10 @@ struct PhotoBackupSettingsView: View {
358360 userAlbums. enumerateObjects { ( collection, _, _) in
359361 albums. append ( collection)
360362 }
361- self . albums = albums
363+
364+ DispatchQueue . main. async {
365+ self . albums = albums
366+ }
362367
363368 // Fetch system albums, including 'Recents'
364369 var smartAlbums : [ PHAssetCollection ] = [ ]
@@ -368,7 +373,10 @@ struct PhotoBackupSettingsView: View {
368373 systemAlbums. enumerateObjects { ( collection, _, _) in
369374 smartAlbums. append ( collection)
370375 }
371- self . smartAlbums = smartAlbums
376+
377+ DispatchQueue . main. async {
378+ self . smartAlbums = smartAlbums
379+ }
372380 }
373381
374382 #if os(iOS)
0 commit comments