Fix some warnings

This commit is contained in:
Nathan Mattes 2023-11-16 10:08:34 +01:00
parent 9947335b20
commit a2aa9b70d2
10 changed files with 10 additions and 41 deletions

View File

@ -203,7 +203,7 @@ extension MastodonPickServerViewModel {
func chooseRandomServer() -> Mastodon.Entity.Server? { 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 let servers = indexedServers.value
guard servers.isNotEmpty else { return nil } guard servers.isNotEmpty else { return nil }

View File

@ -65,7 +65,7 @@ extension ThreadViewModel.LoadThreadState {
authenticationBox: viewModel.authContext.mastodonAuthenticationBox authenticationBox: viewModel.authContext.mastodonAuthenticationBox
) )
await enter(state: NoMore.self) enter(state: NoMore.self)
// assert(!Thread.isMainThread) // assert(!Thread.isMainThread)
// await Task.sleep(1_000_000_000) // 1s delay to prevent UI render issue // await Task.sleep(1_000_000_000) // 1s delay to prevent UI render issue
@ -88,7 +88,7 @@ extension ThreadViewModel.LoadThreadState {
} }
) )
} catch { } catch {
await enter(state: Fail.self) enter(state: Fail.self)
} }
} // end Task } // end Task
} }

View File

@ -94,18 +94,6 @@ public final class CoreDataStack {
container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.automaticallyMergesChangesFromParent = true
callback() 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
}) })
} }

View File

@ -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
}
}

View File

@ -50,7 +50,7 @@ extension APIService {
domain: domain, domain: domain,
authorization: authorization).singleOutput() authorization: authorization).singleOutput()
let responseHistory = try await Mastodon.API.Statuses.editHistory( _ = try await Mastodon.API.Statuses.editHistory(
forStatusID: statusID, forStatusID: statusID,
session: session, session: session,
domain: domain, domain: domain,

View File

@ -238,7 +238,7 @@ extension NotificationService {
} }
private func authenticationBox(for pushNotification: MastodonPushNotification) async throws -> MastodonAuthenticationBox? { 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 } let results = AuthenticationServiceProvider.shared.authentications.filter { $0.userAccessToken == pushNotification.accessToken }
guard let authentication = results.first else { return nil } guard let authentication = results.first else { return nil }

View File

@ -31,7 +31,7 @@ extension ComposeContentViewModel: UITextViewDelegate {
switch textView { switch textView {
case contentMetaText?.textView: case contentMetaText?.textView:
// update model // update model
guard let metaText = self.contentMetaText else { guard self.contentMetaText != nil else {
assertionFailure() assertionFailure()
return return
} }

View File

@ -211,7 +211,7 @@ public final class ComposeContentViewModel: NSObject, ObservableObject {
let recentLanguages = context.settingService.currentSetting.value?.recentLanguages ?? [] let recentLanguages = context.settingService.currentSetting.value?.recentLanguages ?? []
self.recentLanguages = recentLanguages self.recentLanguages = recentLanguages
self.language = recentLanguages.first ?? Locale.current.languageCode ?? "en" self.language = recentLanguages.first ?? Locale.current.language.languageCode?.identifier ?? "en"
super.init() super.init()
// end init // end init
@ -490,7 +490,7 @@ extension ComposeContentViewModel {
.flatMap { settings in .flatMap { settings in
if let settings { if let settings {
return settings.publisher(for: \.recentLanguages, options: .initial).eraseToAnyPublisher() 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([code]).eraseToAnyPublisher()
} }
return Just([]).eraseToAnyPublisher() return Just([]).eraseToAnyPublisher()

View File

@ -32,7 +32,7 @@ extension ComposeContentToolbarView {
@Published var isAttachmentButtonEnabled = false @Published var isAttachmentButtonEnabled = false
@Published var isPollButtonEnabled = 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 var recentLanguages: [String] = []
@Published public var maxTextInputLimit = 500 @Published public var maxTextInputLimit = 500

View File

@ -14,7 +14,7 @@ struct LanguagePicker: View {
let locales = Locale.availableIdentifiers.map(Locale.init(identifier:)) let locales = Locale.availableIdentifiers.map(Locale.init(identifier:))
var languages: [String: Language] = [:] var languages: [String: Language] = [:]
for locale in locales { for locale in locales {
if let code = locale.languageCode, if let code = locale.language.languageCode?.identifier,
let endonym = locale.localizedString(forLanguageCode: code), let endonym = locale.localizedString(forLanguageCode: code),
let exonym = Locale.current.localizedString(forLanguageCode: code) { let exonym = Locale.current.localizedString(forLanguageCode: code) {
// dont overwrite the base language // dont overwrite the base language