fix an issue that the camera freezes after scanning something other than a session id in new conversation screen

pull/891/head
Ryan ZHAO 11 months ago
parent d6b8616543
commit e82cf79dd4

@ -53,6 +53,10 @@ struct NewMessageScreen: View {
fileprivate func startNewPrivateChatIfPossible(with sessionId: String, onError: (() -> ())?) {
if !KeyPair.isValidHexEncodedPublicKey(candidate: sessionId) {
errorString = "qrNotAccountId".localized()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
onError?()
}
}
else {
startNewDM(with: sessionId)
@ -64,16 +68,12 @@ struct NewMessageScreen: View {
}
func continueWithAccountIdOrONS() {
startNewDMIfPossible(with: accountIdOrONS, onError: nil)
}
fileprivate func startNewDMIfPossible(with onsNameOrPublicKey: String, onError: (() -> ())?) {
let maybeSessionId: SessionId? = SessionId(from: onsNameOrPublicKey)
let maybeSessionId: SessionId? = SessionId(from: accountIdOrONS)
if KeyPair.isValidHexEncodedPublicKey(candidate: onsNameOrPublicKey) {
if KeyPair.isValidHexEncodedPublicKey(candidate: accountIdOrONS) {
switch maybeSessionId?.prefix {
case .standard:
startNewDM(with: onsNameOrPublicKey)
startNewDM(with: accountIdOrONS)
default:
errorString = "accountIdErrorInvalid".localized()
@ -85,7 +85,7 @@ struct NewMessageScreen: View {
ModalActivityIndicatorViewController
.present(fromViewController: self.host.controller?.navigationController!, canCancel: false) { modalActivityIndicator in
SnodeAPI
.getSessionID(for: onsNameOrPublicKey)
.getSessionID(for: accountIdOrONS)
.subscribe(on: DispatchQueue.global(qos: .userInitiated))
.receive(on: DispatchQueue.main)
.sinkUntilComplete(
@ -120,7 +120,7 @@ struct NewMessageScreen: View {
)
}
}
private func startNewDM(with sessionId: String) {
SessionApp.presentConversationCreatingIfNeeded(
for: sessionId,

Loading…
Cancel
Save