add delay, move createInvitation
This commit is contained in:
parent
6d583ad057
commit
3c7adfbce7
@ -80,6 +80,9 @@ struct NewChatView: View {
|
|||||||
case .invite:
|
case .invite:
|
||||||
prepareAndInviteView()
|
prepareAndInviteView()
|
||||||
.transition(.move(edge: .leading))
|
.transition(.move(edge: .leading))
|
||||||
|
.onAppear {
|
||||||
|
createInvitation()
|
||||||
|
}
|
||||||
case .connect:
|
case .connect:
|
||||||
ConnectView(showQRCodeScanner: showQRCodeScanner, pastedLink: $pastedLink, alert: $alert)
|
ConnectView(showQRCodeScanner: showQRCodeScanner, pastedLink: $pastedLink, alert: $alert)
|
||||||
.transition(.move(edge: .trailing))
|
.transition(.move(edge: .trailing))
|
||||||
@ -109,12 +112,6 @@ struct NewChatView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.background(Color(.systemGroupedBackground))
|
.background(Color(.systemGroupedBackground))
|
||||||
.onChange(of: selection) { sel in
|
|
||||||
createInvitation(sel)
|
|
||||||
}
|
|
||||||
.onAppear {
|
|
||||||
createInvitation(selection)
|
|
||||||
}
|
|
||||||
.onChange(of: invitationUsed) { used in
|
.onChange(of: invitationUsed) { used in
|
||||||
if used && !(m.showingInvitation?.connChatUsed ?? true) {
|
if used && !(m.showingInvitation?.connChatUsed ?? true) {
|
||||||
m.markShowingInvitationUsed()
|
m.markShowingInvitationUsed()
|
||||||
@ -165,11 +162,11 @@ struct NewChatView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createInvitation(_ selection: NewChatOption) {
|
private func createInvitation() {
|
||||||
if case .invite = selection,
|
if connReqInvitation == "" && contactConnection == nil && !creatingConnReq {
|
||||||
connReqInvitation == "" && contactConnection == nil && !creatingConnReq {
|
|
||||||
creatingConnReq = true
|
creatingConnReq = true
|
||||||
Task {
|
Task {
|
||||||
|
_ = try? await Task.sleep(nanoseconds: 250_000000)
|
||||||
let (r, apiAlert) = await apiAddContact(incognito: incognitoGroupDefault.get())
|
let (r, apiAlert) = await apiAddContact(incognito: incognitoGroupDefault.get())
|
||||||
if let (connReq, pcc) = r {
|
if let (connReq, pcc) = r {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
@ -197,9 +194,7 @@ struct NewChatView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func retryButton() -> some View {
|
private func retryButton() -> some View {
|
||||||
Button {
|
Button(action: createInvitation) {
|
||||||
createInvitation(selection)
|
|
||||||
} label: {
|
|
||||||
VStack(spacing: 6) {
|
VStack(spacing: 6) {
|
||||||
Image(systemName: "arrow.counterclockwise")
|
Image(systemName: "arrow.counterclockwise")
|
||||||
Text("Retry")
|
Text("Retry")
|
||||||
|
@ -94,7 +94,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
Task {
|
Task {
|
||||||
var state = appState
|
var state = appState
|
||||||
for _ in 1...5 {
|
for _ in 1...5 {
|
||||||
_ = try await Task.sleep(nanoseconds: suspendingDelay)
|
_ = try? await Task.sleep(nanoseconds: suspendingDelay)
|
||||||
state = appStateGroupDefault.get()
|
state = appStateGroupDefault.get()
|
||||||
if state == .suspended || state != .suspending { break }
|
if state == .suspended || state != .suspending { break }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user