diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index 00a287b22..a9f760a52 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -203,7 +203,7 @@ extension MastodonPickServerViewModel { func chooseRandomServer() -> Mastodon.Entity.Server? { - let language = Locale.autoupdatingCurrent.languageCode?.lowercased() ?? "en" + let language = Locale.autoupdatingCurrent.language.languageCode?.identifier.lowercased() ?? "en" let servers = indexedServers.value guard servers.isNotEmpty else { return nil } diff --git a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift index 09411e88a..4679e0976 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift @@ -65,7 +65,7 @@ extension ThreadViewModel.LoadThreadState { authenticationBox: viewModel.authContext.mastodonAuthenticationBox ) - await enter(state: NoMore.self) + enter(state: NoMore.self) // assert(!Thread.isMainThread) // await Task.sleep(1_000_000_000) // 1s delay to prevent UI render issue @@ -88,7 +88,7 @@ extension ThreadViewModel.LoadThreadState { } ) } catch { - await enter(state: Fail.self) + enter(state: Fail.self) } } // end Task } diff --git a/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift b/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift index 3a30e9443..50b135c4f 100644 --- a/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift +++ b/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift @@ -94,18 +94,6 @@ public final class CoreDataStack { container.viewContext.automaticallyMergesChangesFromParent = true callback() - - #if DEBUG - do { - let storeURL = URL.storeURL(for: AppName.groupID, databaseName: "shared") - let data = try Data(contentsOf: storeURL) - let formatter = ByteCountFormatter() - formatter.allowedUnits = [.useMB] - formatter.countStyle = .file - let size = formatter.string(fromByteCount: Int64(data.count)) - } catch { - } - #endif }) } diff --git a/MastodonSDK/Sources/MastodonCore/Extension/MastodonSDK/Mastodon+Entity+Field.swift b/MastodonSDK/Sources/MastodonCore/Extension/MastodonSDK/Mastodon+Entity+Field.swift deleted file mode 100644 index c7fe63465..000000000 --- a/MastodonSDK/Sources/MastodonCore/Extension/MastodonSDK/Mastodon+Entity+Field.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// Mastodon+Entity+Field.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-5-25. -// - -import Foundation -import MastodonSDK - -extension Mastodon.Entity.Field: Equatable { - public static func == (lhs: Mastodon.Entity.Field, rhs: Mastodon.Entity.Field) -> Bool { - return lhs.name == rhs.name && - lhs.value == rhs.value && - lhs.verifiedAt == rhs.verifiedAt - } - - -} diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+History.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+History.swift index 523f95617..46ec1b9d4 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+History.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+History.swift @@ -50,7 +50,7 @@ extension APIService { domain: domain, authorization: authorization).singleOutput() - let responseHistory = try await Mastodon.API.Statuses.editHistory( + _ = try await Mastodon.API.Statuses.editHistory( forStatusID: statusID, session: session, domain: domain, diff --git a/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift b/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift index f7c6c08cf..0c60ad8e7 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift @@ -238,7 +238,7 @@ extension NotificationService { } private func authenticationBox(for pushNotification: MastodonPushNotification) async throws -> MastodonAuthenticationBox? { - guard let authenticationService = self.authenticationService else { return nil } + guard self.authenticationService != nil else { return nil } let results = AuthenticationServiceProvider.shared.authentications.filter { $0.userAccessToken == pushNotification.accessToken } guard let authentication = results.first else { return nil } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift index 53184cdfc..f7315700b 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift @@ -31,7 +31,7 @@ extension ComposeContentViewModel: UITextViewDelegate { switch textView { case contentMetaText?.textView: // update model - guard let metaText = self.contentMetaText else { + guard self.contentMetaText != nil else { assertionFailure() return } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift index 1e669d654..cd4b67780 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -211,7 +211,7 @@ public final class ComposeContentViewModel: NSObject, ObservableObject { let recentLanguages = context.settingService.currentSetting.value?.recentLanguages ?? [] self.recentLanguages = recentLanguages - self.language = recentLanguages.first ?? Locale.current.languageCode ?? "en" + self.language = recentLanguages.first ?? Locale.current.language.languageCode?.identifier ?? "en" super.init() // end init @@ -490,7 +490,7 @@ extension ComposeContentViewModel { .flatMap { settings in if let settings { return settings.publisher(for: \.recentLanguages, options: .initial).eraseToAnyPublisher() - } else if let code = Locale.current.languageCode { + } else if let code = Locale.current.language.languageCode?.identifier { return Just([code]).eraseToAnyPublisher() } return Just([]).eraseToAnyPublisher() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift index 2b25755b2..e830d04d3 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift @@ -32,7 +32,7 @@ extension ComposeContentToolbarView { @Published var isAttachmentButtonEnabled = false @Published var isPollButtonEnabled = false - @Published var language = Locale.current.languageCode ?? "en" + @Published var language = Locale.current.language.languageCode?.identifier ?? "en" @Published var recentLanguages: [String] = [] @Published public var maxTextInputLimit = 500 diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/LanguagePicker.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/LanguagePicker.swift index 10911c875..2f63a03d5 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/LanguagePicker.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/LanguagePicker.swift @@ -14,7 +14,7 @@ struct LanguagePicker: View { let locales = Locale.availableIdentifiers.map(Locale.init(identifier:)) var languages: [String: Language] = [:] for locale in locales { - if let code = locale.languageCode, + if let code = locale.language.languageCode?.identifier, let endonym = locale.localizedString(forLanguageCode: code), let exonym = Locale.current.localizedString(forLanguageCode: code) { // don’t overwrite the “base” language