Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion LoopFollow/Remote/LoopAPNS/LoopAPNSBolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct LoopAPNSBolusView: View {
@State private var lastLoopTime: TimeInterval? = nil
@State private var otpTimeRemaining: Int? = nil
@State private var showOldCalculationWarning = false
@State private var showTOTPWarning = false
private let otpPeriod: TimeInterval = 30
private var otpTimer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()

Expand Down Expand Up @@ -125,7 +126,7 @@ struct LoopAPNSBolusView: View {
}

// TOTP Blocking Warning Section
if isTOTPBlocked {
if isTOTPBlocked && showTOTPWarning {
Section {
VStack(alignment: .leading, spacing: 8) {
HStack {
Expand Down Expand Up @@ -187,6 +188,15 @@ struct LoopAPNSBolusView: View {

// Validate TOTP state when view appears
_ = isTOTPBlocked

// Add delay before showing TOTP warning to prevent flash after successful send
if isTOTPBlocked {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
showTOTPWarning = true
}
} else {
showTOTPWarning = false
}
}
.onReceive(otpTimer) { _ in
let now = Date().timeIntervalSince1970
Expand Down
12 changes: 11 additions & 1 deletion LoopFollow/Remote/LoopAPNS/LoopAPNSCarbsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct LoopAPNSCarbsView: View {
@State private var alertMessage = ""
@State private var alertType: AlertType = .success
@State private var otpTimeRemaining: Int? = nil
@State private var showTOTPWarning = false
private let otpPeriod: TimeInterval = 30
private var otpTimer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()

Expand Down Expand Up @@ -178,7 +179,7 @@ struct LoopAPNSCarbsView: View {
}

// TOTP Blocking Warning Section
if isTOTPBlocked {
if isTOTPBlocked && showTOTPWarning {
Section {
VStack(alignment: .leading, spacing: 8) {
HStack {
Expand Down Expand Up @@ -250,6 +251,15 @@ struct LoopAPNSCarbsView: View {

// Validate TOTP state when view appears
_ = isTOTPBlocked

// Add delay before showing TOTP warning to prevent flash after successful send
if isTOTPBlocked {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
showTOTPWarning = true
}
} else {
showTOTPWarning = false
}
}
.onReceive(otpTimer) { _ in
let now = Date().timeIntervalSince1970
Expand Down