Minor fixes

This commit is contained in:
世界
2024-10-13 21:16:49 +08:00
parent 5e2af0a5c7
commit 6d4ed01a6d
6 changed files with 22 additions and 13 deletions
@@ -76,7 +76,7 @@ public struct ShareButtonCompat<Label>: View where Label: View {
#if os(iOS) #if os(iOS)
private nonisolated func shareItem0() async { private nonisolated func shareItem0() async {
do { do {
let shareItem = try itemURL() let shareItem = try await itemURL()
await MainActor.run { await MainActor.run {
shareItem1(shareItem) shareItem1(shareItem)
} }
@@ -71,7 +71,7 @@ public struct GroupItemView: View {
do { do {
try await LibboxNewStandaloneCommandClient()!.selectOutbound(group.tag, outboundTag: item.tag) try await LibboxNewStandaloneCommandClient()!.selectOutbound(group.tag, outboundTag: item.tag)
var newGroup = await group var newGroup = await group
newGroup.selected = item.tag newGroup.selected = await item.tag
await MainActor.run { [newGroup] in await MainActor.run { [newGroup] in
_group.wrappedValue = newGroup _group.wrappedValue = newGroup
} }
@@ -162,7 +162,7 @@ public struct EditProfileView: View {
do { do {
_ = try await ProfileManager.update(profile) _ = try await ProfileManager.update(profile)
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
try await UIProfileUpdateTask.configure() try UIProfileUpdateTask.configure()
#else #else
try await ProfileUpdateTask.configure() try await ProfileUpdateTask.configure()
#endif #endif
@@ -243,7 +243,7 @@ public struct NewProfileView: View {
)) ))
if profileType == .remote { if profileType == .remote {
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
try await UIProfileUpdateTask.configure() try UIProfileUpdateTask.configure()
#else #else
try await ProfileUpdateTask.configure() try await ProfileUpdateTask.configure()
#endif #endif
@@ -3,6 +3,7 @@ import Libbox
import Library import Library
import SwiftUI import SwiftUI
@MainActor
public struct CoreView: View { public struct CoreView: View {
@State private var isLoading = true @State private var isLoading = true
@@ -51,13 +52,17 @@ public struct CoreView: View {
private nonisolated func loadSettings() async { private nonisolated func loadSettings() async {
if ApplicationLibrary.inPreview { if ApplicationLibrary.inPreview {
version = "<redacted>" await MainActor.run {
dataSize = LibboxFormatBytes(1000 * 1000 * 10) version = "<redacted>"
isLoading = false dataSize = LibboxFormatBytes(1000 * 1000 * 10)
isLoading = false
}
} else { } else {
version = LibboxVersion() await MainActor.run {
dataSize = "Loading..." version = LibboxVersion()
isLoading = false dataSize = "Loading..."
isLoading = false
}
await loadSettingsBackground() await loadSettingsBackground()
} }
} }
+7 -3
View File
@@ -85,8 +85,12 @@ public class CommandClient: ObservableObject {
} }
private func initializeConnectionFilterState() async { private func initializeConnectionFilterState() async {
connectionStateFilter = await .init(rawValue: SharedPreferences.connectionStateFilter.get()) ?? .all let newFilter: ConnectionStateFilter = await .init(rawValue: SharedPreferences.connectionStateFilter.get()) ?? .active
connectionSort = await .init(rawValue: SharedPreferences.connectionSort.get()) ?? .byDate let newSort: ConnectionSort = await .init(rawValue: SharedPreferences.connectionSort.get()) ?? .byDate
await MainActor.run {
connectionStateFilter = newFilter
connectionSort = newSort
}
} }
private nonisolated func connect0() async { private nonisolated func connect0() async {
@@ -111,7 +115,7 @@ public class CommandClient: ObservableObject {
case .log: case .log:
clientOptions.statusInterval = Int64(500 * NSEC_PER_MSEC) clientOptions.statusInterval = Int64(500 * NSEC_PER_MSEC)
default: default:
clientOptions.statusInterval = Int64(2 * NSEC_PER_SEC) clientOptions.statusInterval = Int64(NSEC_PER_SEC)
} }
let client = LibboxNewCommandClient(clientHandler(self), clientOptions)! let client = LibboxNewCommandClient(clientHandler(self), clientOptions)!
do { do {