From d6e499bd9a89c1e052f195a6132e78260f0bd85d Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 18 Sep 2019 11:09:09 +1000 Subject: [PATCH] Switch onboarding seed step and display name step --- .../Loki/AccountDetailsViewController.swift | 4 ++- Signal/src/Loki/SeedViewController.swift | 4 +-- .../Registration/OnboardingController.swift | 20 ++++++------- SignalMessaging/Loki/JazzIcon.swift | 2 +- .../src/Loki/API/LokiGroupChatAPI.swift | 4 +++ .../src/Messages/OWSMessageManager.m | 28 +++++++------------ 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/Signal/src/Loki/AccountDetailsViewController.swift b/Signal/src/Loki/AccountDetailsViewController.swift index b8391878c..aae25b7b8 100644 --- a/Signal/src/Loki/AccountDetailsViewController.swift +++ b/Signal/src/Loki/AccountDetailsViewController.swift @@ -64,6 +64,8 @@ final class AccountDetailsViewController : OnboardingBaseViewController { } OWSProfileManager.shared().updateLocalProfileName(normalizedUserName, avatarImage: nil, success: { }, failure: { }) // Try to save the user name but ignore the result } - onboardingController.pushKeyPairViewController(from: self) + TSAccountManager.sharedInstance().didRegister() + UserDefaults.standard.set(true, forKey: "didUpdateForMainnet") + onboardingController.verificationDidComplete(fromView: self) } } diff --git a/Signal/src/Loki/SeedViewController.swift b/Signal/src/Loki/SeedViewController.swift index ae8ff0640..8d149b1c7 100644 --- a/Signal/src/Loki/SeedViewController.swift +++ b/Signal/src/Loki/SeedViewController.swift @@ -225,12 +225,10 @@ final class SeedViewController : OnboardingBaseViewController { let hexEncodedPublicKey = keyPair.hexEncodedPublicKey let accountManager = TSAccountManager.sharedInstance() accountManager.phoneNumberAwaitingVerification = hexEncodedPublicKey - accountManager.didRegister() switch mode { case .register: Analytics.shared.track("Seed Created") case .restore: Analytics.shared.track("Seed Restored") } - onboardingController.verificationDidComplete(fromView: self) - UserDefaults.standard.set(true, forKey: "didUpdateForMainnet") + onboardingController.pushAccountDetailsViewController(from: self) } } diff --git a/Signal/src/ViewControllers/Registration/OnboardingController.swift b/Signal/src/ViewControllers/Registration/OnboardingController.swift index c7adc4414..a937065b4 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingController.swift @@ -98,7 +98,7 @@ public class OnboardingController: NSObject { // MARK: - Transitions public func onboardingSplashDidComplete(viewController: UIViewController) { - pushAccountDetailsViewController(from: viewController) + pushSeedViewController(from: viewController) } public func onboardingPermissionsWasSkipped(viewController: UIViewController) { @@ -106,7 +106,7 @@ public class OnboardingController: NSObject { Logger.info("") - pushAccountDetailsViewController(from: viewController) + pushSeedViewController(from: viewController) } public func onboardingPermissionsDidComplete(viewController: UIViewController) { @@ -114,20 +114,20 @@ public class OnboardingController: NSObject { Logger.info("") - pushAccountDetailsViewController(from: viewController) - } - - private func pushAccountDetailsViewController(from viewController: UIViewController) { - AssertIsOnMainThread() - let accountDetailsVC = AccountDetailsViewController(onboardingController: self) - viewController.navigationController?.pushViewController(accountDetailsVC, animated: true) + pushSeedViewController(from: viewController) } - func pushKeyPairViewController(from viewController: UIViewController) { + public func pushSeedViewController(from viewController: UIViewController) { AssertIsOnMainThread() let seedVC = SeedViewController(onboardingController: self) viewController.navigationController?.pushViewController(seedVC, animated: true) } + + public func pushAccountDetailsViewController(from viewController: UIViewController) { + AssertIsOnMainThread() + let accountDetailsVC = AccountDetailsViewController(onboardingController: self) + viewController.navigationController?.pushViewController(accountDetailsVC, animated: true) + } public func onboardingRegistrationSucceeded(viewController: UIViewController) { AssertIsOnMainThread() diff --git a/SignalMessaging/Loki/JazzIcon.swift b/SignalMessaging/Loki/JazzIcon.swift index 0f96053cc..c1c5adfd5 100644 --- a/SignalMessaging/Loki/JazzIcon.swift +++ b/SignalMessaging/Loki/JazzIcon.swift @@ -8,7 +8,7 @@ extension String { } private class RNG { - private let int32Max: Int = Int(Int32.max) // 2147483647 + private let int32Max = Int(Int32.max) // 2147483647 private var seed: Int private var initial: Int diff --git a/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift b/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift index d6acc9cc0..5dc1ca137 100644 --- a/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift @@ -11,7 +11,11 @@ public final class LokiGroupChatAPI : NSObject { private static let maxRetryCount: UInt = 4 // MARK: Public Chat + #if DEBUG + @objc public static let publicChatServer = "https://chat-dev.lokinet.org" + #else @objc public static let publicChatServer = "https://chat.lokinet.org" + #endif @objc public static let publicChatMessageType = "network.loki.messenger.publicChat" @objc public static let publicChatServerID: UInt64 = 1 diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 6c88dd9ab..dea615411 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -414,9 +414,9 @@ NS_ASSUME_NONNULL_BEGIN return; } - // Loki: Handle any friend request accepts if we need to - // TODO: We'll need to fix this up if we ever start using Sync messages - [self handleFriendRequestAcceptIfNeededWithEnvelope:envelope transaction:transaction]; + // Loki: Handle friend request acceptance if needed + // TODO: We'll need to fix this up if we ever start using sync messages + [self handleFriendRequestAcceptanceIfNeededWithEnvelope:envelope transaction:transaction]; if (envelope.content != nil) { NSError *error; @@ -1488,9 +1488,8 @@ NS_ASSUME_NONNULL_BEGIN return nil; } - // Loki - // If we received a message from a contact in the last 2 minues that was not p2p, then we need to ping them. - // We assume this occurred because they don't have our p2p details. + // Loki: If we received a message from a contact in the last 2 minutes that wasn't P2P, then we need to ping them. + // We assume this occurred because they don't have our P2P details. if (!envelope.isPtpMessage && envelope.source != nil) { uint64_t timestamp = envelope.timestamp; uint64_t now = NSDate.ows_millisecondTimeStamp; @@ -1519,12 +1518,8 @@ NS_ASSUME_NONNULL_BEGIN } } -// The difference between this function and `handleFriendRequestAcceptIfNeededWithEnvelope:` is that this will setup the incoming message for display to the user -// While `handleFriendRequestAcceptIfNeededWithEnvelope:` handles friend request accepting logic and doesn't need a message - (void)handleFriendRequestMessageIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope message:(TSIncomingMessage *)message thread:(TSThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction { - // Check if it's a friend request message and make sure it's not a group message if (envelope.isGroupChatMessage || envelope.type != SSKProtoEnvelopeTypeFriendRequest) return; - if (thread.hasCurrentUserSentFriendRequest) { // This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his // mind and sent a friend request to Alice. In this case we want Alice to auto-accept the request @@ -1555,18 +1550,15 @@ NS_ASSUME_NONNULL_BEGIN } } -- (void)handleFriendRequestAcceptIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope transaction:(YapDatabaseReadWriteTransaction *)transaction { - // If we get any other envelope type then we can assume that we had to use signal cipher decryption - // and that means we must have a session with the other person. - // We also need to ensure that we're contacting the person directly and not through a public chat +- (void)handleFriendRequestAcceptanceIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope transaction:(YapDatabaseReadWriteTransaction *)transaction { + // If we get an envelope that isn't a friend request, then we can infer that we had to use + // Signal cipher decryption and thus that we have a session with the other person. if (envelope.isGroupChatMessage || envelope.type == SSKProtoEnvelopeTypeFriendRequest) return; - // If we're already friends then there's no point in continuing - // TODO: We'll need to fix this up if we ever start using Sync messages - // Currently it'll use `envelope.source` but with sync messages we need to use the message sender id + // TODO: We'll need to fix this up if we ever start using sync messages + // Currently it'll use `envelope.source` but with sync messages we need to use the message sender ID TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction]; if (thread.isContactFriend) return; - // Become happy friends and go on great adventures [thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:transaction]; TSOutgoingMessage *existingFriendRequestMessage = (TSOutgoingMessage *)[thread.lastInteraction as:TSOutgoingMessage.class];