Skip to content

Commit ef465eb

Browse files
Fix displaying of omemo keys view trust alerts
1 parent f689162 commit ef465eb

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Monal/Classes/OmemoKeysView.swift

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ struct OmemoKeysEntryView: View {
1212
private let contactJid: String
1313

1414
@State private var trustLevel: NSNumber
15-
@State private var showEntryInfo = false
16-
@State private var showClipboardCopy = false
15+
@State private var showAlert: Alert?
1716

1817
private let deviceId: NSNumber
1918
private let fingerprint: Data
@@ -159,14 +158,18 @@ struct OmemoKeysEntryView: View {
159158
}
160159
.onTapGesture(count: 2) {
161160
UIPasteboard.general.setValue(clipboardValue, forPasteboardType:UTType.utf8PlainText.identifier)
162-
showClipboardCopy = true
161+
showAlert = Alert(
162+
title: Text("Copied to clipboard"),
163+
message: Text(clipboardValue),
164+
dismissButton: nil
165+
)
163166
}
164167
Spacer()
165168
// the trust level of our own device should not be displayed
166169
if(!isOwnDevice) {
167170
VStack(alignment:.center) {
168171
Button {
169-
showEntryInfo = true
172+
showAlert = getEntryInfoAlert()
170173
} label: {
171174
getTrustLevelIcon()
172175
}
@@ -175,21 +178,14 @@ struct OmemoKeysEntryView: View {
175178
}
176179
} else {
177180
Button {
178-
showEntryInfo = true
181+
showAlert = getEntryInfoAlert()
179182
} label: {
180183
getDeviceIconForOwnDevice()
181184
}
182185
}
183186
}
184-
.alert(isPresented: $showEntryInfo) {
185-
getEntryInfoAlert()
186-
}
187-
.alert(isPresented: $showClipboardCopy) {
188-
Alert(
189-
title: Text("Copied to clipboard"),
190-
message: Text(clipboardValue),
191-
dismissButton: nil
192-
);
187+
.alert(isPresented: $showAlert.optionalMappedToBool()) {
188+
showAlert!
193189
}
194190
}
195191
}

0 commit comments

Comments
 (0)