@@ -254,6 +254,34 @@ final class ProgressSyncManager: NSObject, ObservableObject {
254254 Logger . shared. log ( " AniList login successful " , type: " Sync " )
255255 }
256256
257+ private func runAuthSession( url: URL ) async throws -> URL {
258+ try await withCheckedThrowingContinuation { continuation in
259+ authSession = ASWebAuthenticationSession ( url: url, callbackURLScheme: callbackScheme) { callbackURL, error in
260+ if let callbackURL {
261+ continuation. resume ( returning: callbackURL)
262+ return
263+ }
264+
265+ if let error {
266+ continuation. resume ( throwing: error)
267+ return
268+ }
269+
270+ continuation. resume ( throwing: SyncError . authorizationFailed ( " Authentication was cancelled " ) )
271+ }
272+
273+ authSession? . presentationContextProvider = self
274+ authSession? . prefersEphemeralWebBrowserSession = false
275+ if authSession? . start ( ) != true {
276+ continuation. resume ( throwing: SyncError . authorizationFailed ( " Unable to start authentication " ) )
277+ }
278+ }
279+ }
280+ #else
281+ func loginTrakt( ) async throws { throw SyncError . unsupportedPlatform }
282+ func loginAniList( ) async throws { throw SyncError . unsupportedPlatform }
283+ #endif
284+
257285 private func refreshTraktUsername( ) async {
258286 do {
259287 let token = try await validToken ( for: . trakt)
@@ -317,34 +345,6 @@ final class ProgressSyncManager: NSObject, ObservableObject {
317345 }
318346 }
319347
320- private func runAuthSession( url: URL ) async throws -> URL {
321- try await withCheckedThrowingContinuation { continuation in
322- authSession = ASWebAuthenticationSession ( url: url, callbackURLScheme: callbackScheme) { callbackURL, error in
323- if let callbackURL {
324- continuation. resume ( returning: callbackURL)
325- return
326- }
327-
328- if let error {
329- continuation. resume ( throwing: error)
330- return
331- }
332-
333- continuation. resume ( throwing: SyncError . authorizationFailed ( " Authentication was cancelled " ) )
334- }
335-
336- authSession? . presentationContextProvider = self
337- authSession? . prefersEphemeralWebBrowserSession = false
338- if authSession? . start ( ) != true {
339- continuation. resume ( throwing: SyncError . authorizationFailed ( " Unable to start authentication " ) )
340- }
341- }
342- }
343- #else
344- func loginTrakt( ) async throws { throw SyncError . unsupportedPlatform }
345- func loginAniList( ) async throws { throw SyncError . unsupportedPlatform }
346- #endif
347-
348348 func pushMovieProgress( tmdbId: Int , title: String , progress: Double ) {
349349 Task {
350350 await pushToProviders ( movieId: tmdbId, title: title, progress: progress)
0 commit comments