File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,7 @@ struct PhotoBackupSettingsView: View {
131131 else {
132132 Text ( " Synctrain cannot access your photo library right now " )
133133 Button ( " Allow Synctrain to access photos " ) {
134- PHPhotoLibrary . requestAuthorization { status in
135- DispatchQueue . main. async {
136- authorizationStatus = status
137- }
138- }
134+ self . requestAuthorization ( )
139135 }
140136 }
141137
@@ -337,6 +333,14 @@ struct PhotoBackupSettingsView: View {
337333 }
338334 }
339335
336+ private func requestAuthorization( ) {
337+ PHPhotoLibrary . requestAuthorization ( for: . readWrite) { status in
338+ Task { @MainActor in
339+ authorizationStatus = status
340+ }
341+ }
342+ }
343+
340344 private func update( ) async {
341345 authorizationStatus = PHPhotoLibrary . authorizationStatus ( )
342346 self . folders = await appState. folders ( ) . filter ( { $0. isSuitablePhotoBackupDestination } ) . sorted ( )
Original file line number Diff line number Diff line change @@ -211,11 +211,7 @@ private struct PhotoFolderAlbumSettingsView: View {
211211 else {
212212 Text ( " Synctrain cannot access your photo library right now " )
213213 Button ( " Allow Synctrain to access photos " ) {
214- PHPhotoLibrary . requestAuthorization { status in
215- DispatchQueue . main. async {
216- authorizationStatus = status
217- }
218- }
214+ self . requestAuthorization ( )
219215 }
220216 }
221217 }
@@ -279,6 +275,14 @@ private struct PhotoFolderAlbumSettingsView: View {
279275 . navigationTitle ( dirName. isEmpty ? " Add album " : " Settings for ' \( dirName) ' " )
280276 }
281277
278+ private func requestAuthorization( ) {
279+ PHPhotoLibrary . requestAuthorization ( for: . readWrite) { status in
280+ Task { @MainActor in
281+ authorizationStatus = status
282+ }
283+ }
284+ }
285+
282286 func loadAlbums( ) -> [ PHAssetCollection ] {
283287 var albums : [ PHAssetCollection ] = [ ]
284288 let options = PHFetchOptions ( )
You can’t perform that action at this time.
0 commit comments