|
|
|
@ -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(
|
|
|
|
|