prevent feedback; fix toolbars

This commit is contained in:
Levitating Pineapple
2024-10-16 12:28:27 +03:00
parent 141f3c8fe5
commit b24d4980b6
3 changed files with 16 additions and 8 deletions
@@ -216,6 +216,7 @@ struct ChatListView: View {
Spacer()
trailingToolbarItem.padding(.bottom, padding)
}
.privacySensitive(protectScreen)
.contentShape(Rectangle())
.onTapGesture { scrollToSearchBar = true }
}
@@ -251,11 +252,13 @@ struct ChatListView: View {
}
@ViewBuilder var trailingToolbarItem: some View {
switch chatModel.chatRunning {
case .some(true): NewChatMenuButton()
case .some(false): chatStoppedIcon()
case .none: EmptyView()
}
Group {
switch chatModel.chatRunning {
case .some(true): NewChatMenuButton()
case .some(false): chatStoppedIcon()
case .none: EmptyView()
}
}.privacySensitive(protectScreen)
}
@ViewBuilder private var chatList: some View {
@@ -412,6 +415,7 @@ struct SubsStatusIndicator: View {
@State private var showServersSummary = false
@AppStorage(DEFAULT_SHOW_SUBSCRIPTION_PERCENTAGE) private var showSubscriptionPercentage = false
@AppStorage(DEFAULT_PRIVACY_PROTECT_SCREEN) private var protectScreen = false
var body: some View {
Button {
@@ -426,6 +430,7 @@ struct SubsStatusIndicator: View {
}
}
.disabled(ChatModel.shared.chatRunning != true)
.privacySensitive(protectScreen)
.onAppear {
startTask()
}
@@ -65,14 +65,15 @@ func systemAuthenticate(_ reason: String, _ completed: @escaping (LAResult) -> V
logger.debug("DEBUGGING: systemAuthenticate: canEvaluatePolicy callback")
AppSheetState.shared.biometricAuth = true
laContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { success, authError in
AppSheetState.shared.biometricAuth = false
logger.debug("DEBUGGING: systemAuthenticate evaluatePolicy callback")
DispatchQueue.main.async {
if success {
completed(LAResult.success)
AppSheetState.shared.biometricAuth = false
} else {
logger.error("DEBUGGING: systemAuthenticate authentication error: \(authError.debugDescription)")
completed(LAResult.failed(authError: authError?.localizedDescription))
AppSheetState.shared.biometricAuth = false
}
}
}
@@ -59,8 +59,10 @@ struct UserProfilesView: View {
userProfilesView()
} else {
Button(action: runAuth) { Label("Unlock", systemImage: "lock") }
// TODO: Prevent Feedback loop
// .onAppear(perform: runAuth)
.onAppear {
// `scenePhase` check Prevents a feedback loop
if AppSheetState.shared.scenePhaseActive { runAuth() }
}
}
}