Switch onboarding seed step and display name step

pull/52/head
Niels Andriesse 6 years ago
parent 99e217e323
commit d6e499bd9a

@ -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 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)
} }
} }

@ -225,12 +225,10 @@ final class SeedViewController : OnboardingBaseViewController {
let hexEncodedPublicKey = keyPair.hexEncodedPublicKey let hexEncodedPublicKey = keyPair.hexEncodedPublicKey
let accountManager = TSAccountManager.sharedInstance() let accountManager = TSAccountManager.sharedInstance()
accountManager.phoneNumberAwaitingVerification = hexEncodedPublicKey accountManager.phoneNumberAwaitingVerification = hexEncodedPublicKey
accountManager.didRegister()
switch mode { switch mode {
case .register: Analytics.shared.track("Seed Created") case .register: Analytics.shared.track("Seed Created")
case .restore: Analytics.shared.track("Seed Restored") case .restore: Analytics.shared.track("Seed Restored")
} }
onboardingController.verificationDidComplete(fromView: self) onboardingController.pushAccountDetailsViewController(from: self)
UserDefaults.standard.set(true, forKey: "didUpdateForMainnet")
} }
} }

@ -98,7 +98,7 @@ public class OnboardingController: NSObject {
// MARK: - Transitions // MARK: - Transitions
public func onboardingSplashDidComplete(viewController: UIViewController) { public func onboardingSplashDidComplete(viewController: UIViewController) {
pushAccountDetailsViewController(from: viewController) pushSeedViewController(from: viewController)
} }
public func onboardingPermissionsWasSkipped(viewController: UIViewController) { public func onboardingPermissionsWasSkipped(viewController: UIViewController) {
@ -106,7 +106,7 @@ public class OnboardingController: NSObject {
Logger.info("") Logger.info("")
pushAccountDetailsViewController(from: viewController) pushSeedViewController(from: viewController)
} }
public func onboardingPermissionsDidComplete(viewController: UIViewController) { public func onboardingPermissionsDidComplete(viewController: UIViewController) {
@ -114,20 +114,20 @@ public class OnboardingController: NSObject {
Logger.info("") Logger.info("")
pushAccountDetailsViewController(from: viewController) pushSeedViewController(from: viewController)
}
private func pushAccountDetailsViewController(from viewController: UIViewController) {
AssertIsOnMainThread()
let accountDetailsVC = AccountDetailsViewController(onboardingController: self)
viewController.navigationController?.pushViewController(accountDetailsVC, animated: true)
} }
func pushKeyPairViewController(from viewController: UIViewController) { public func pushSeedViewController(from viewController: UIViewController) {
AssertIsOnMainThread() AssertIsOnMainThread()
let seedVC = SeedViewController(onboardingController: self) let seedVC = SeedViewController(onboardingController: self)
viewController.navigationController?.pushViewController(seedVC, animated: true) 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) { public func onboardingRegistrationSucceeded(viewController: UIViewController) {
AssertIsOnMainThread() AssertIsOnMainThread()

@ -8,7 +8,7 @@ extension String {
} }
private class RNG { private class RNG {
private let int32Max: Int = Int(Int32.max) // 2147483647 private let int32Max = Int(Int32.max) // 2147483647
private var seed: Int private var seed: Int
private var initial: Int private var initial: Int

@ -11,7 +11,11 @@ public final class LokiGroupChatAPI : NSObject {
private static let maxRetryCount: UInt = 4 private static let maxRetryCount: UInt = 4
// MARK: Public Chat // 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" @objc public static let publicChatServer = "https://chat.lokinet.org"
#endif
@objc public static let publicChatMessageType = "network.loki.messenger.publicChat" @objc public static let publicChatMessageType = "network.loki.messenger.publicChat"
@objc public static let publicChatServerID: UInt64 = 1 @objc public static let publicChatServerID: UInt64 = 1

@ -414,9 +414,9 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
// Loki: Handle any friend request accepts if we need to // Loki: Handle friend request acceptance if needed
// TODO: We'll need to fix this up if we ever start using Sync messages // TODO: We'll need to fix this up if we ever start using sync messages
[self handleFriendRequestAcceptIfNeededWithEnvelope:envelope transaction:transaction]; [self handleFriendRequestAcceptanceIfNeededWithEnvelope:envelope transaction:transaction];
if (envelope.content != nil) { if (envelope.content != nil) {
NSError *error; NSError *error;
@ -1488,9 +1488,8 @@ NS_ASSUME_NONNULL_BEGIN
return nil; return nil;
} }
// Loki // Loki: If we received a message from a contact in the last 2 minutes that wasn't P2P, then we need to ping them.
// 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.
// We assume this occurred because they don't have our p2p details.
if (!envelope.isPtpMessage && envelope.source != nil) { if (!envelope.isPtpMessage && envelope.source != nil) {
uint64_t timestamp = envelope.timestamp; uint64_t timestamp = envelope.timestamp;
uint64_t now = NSDate.ows_millisecondTimeStamp; 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 { - (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 (envelope.isGroupChatMessage || envelope.type != SSKProtoEnvelopeTypeFriendRequest) return;
if (thread.hasCurrentUserSentFriendRequest) { if (thread.hasCurrentUserSentFriendRequest) {
// This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his // 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 // 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 { - (void)handleFriendRequestAcceptanceIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope transaction:(YapDatabaseReadWriteTransaction *)transaction {
// If we get any other envelope type then we can assume that we had to use signal cipher decryption // If we get an envelope that isn't a friend request, then we can infer that we had to use
// and that means we must have a session with the other person. // Signal cipher decryption and thus that we 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
if (envelope.isGroupChatMessage || envelope.type == SSKProtoEnvelopeTypeFriendRequest) return; if (envelope.isGroupChatMessage || envelope.type == SSKProtoEnvelopeTypeFriendRequest) return;
// If we're already friends then there's no point in continuing // 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 // 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 // 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]; TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
if (thread.isContactFriend) return; if (thread.isContactFriend) return;
// Become happy friends and go on great adventures // Become happy friends and go on great adventures
[thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:transaction]; [thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:transaction];
TSOutgoingMessage *existingFriendRequestMessage = (TSOutgoingMessage *)[thread.lastInteraction as:TSOutgoingMessage.class]; TSOutgoingMessage *existingFriendRequestMessage = (TSOutgoingMessage *)[thread.lastInteraction as:TSOutgoingMessage.class];

Loading…
Cancel
Save