Merge branch 'dev' of https://github.com/loki-project/loki-messenger-ios into sync-closed-group

pull/104/head
Ryan ZHAO 5 years ago
commit b206f2944e

@ -4230,7 +4230,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -4244,7 +4244,7 @@
INFOPLIST_FILE = SignalShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -4292,7 +4292,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO;
@ -4311,7 +4311,7 @@
INFOPLIST_FILE = SignalShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -4346,7 +4346,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
@ -4365,7 +4365,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@ -4415,7 +4415,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
@ -4439,7 +4439,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@ -4624,7 +4624,7 @@
CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -4659,7 +4659,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;
@ -4691,7 +4691,7 @@
CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 45;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -4726,7 +4726,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;

@ -155,7 +155,7 @@ final class DisplayNameVC : UIViewController {
return showError(title: NSLocalizedString("Please pick a shorter display name", comment: ""))
}
TSAccountManager.sharedInstance().didRegister()
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }) // Try to save the user name but ignore the result
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }, requiresSync: false) // Try to save the user name but ignore the result
let homeVC = HomeVC()
navigationController!.setViewControllers([ homeVC ], animated: true)
}

@ -152,6 +152,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
// openGroupSuggestionSheet.modalTransitionStyle = .crossDissolve
// present(openGroupSuggestionSheet, animated: true, completion: nil)
// }
UserDefaults.standard.set(true, forKey: "hasLaunchedOnce")
}
override func viewWillDisappear(_ animated: Bool) {

@ -288,7 +288,7 @@ final class SettingsVC : UIViewController, AvatarViewHelperDelegate {
self?.present(alert, animated: true, completion: nil)
}
}
})
}, requiresSync: true)
}
}

@ -428,7 +428,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
@"profile update fails.")];
}];
});
}];
} requiresSync:NO];
}];
}

@ -177,7 +177,7 @@ public class OnboardingProfileViewController: OnboardingBaseViewController {
comment: "Error message shown when a profile update fails."))
})
}
})
}, requiresSync: false)
}
}

@ -339,7 +339,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
failure:^(NSError *error) {
// Ignore errors related to local profile.
resolve(@(1));
}];
}
requiresSync:YES];
}];
}

@ -225,9 +225,13 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
if (!self.tsAccountManager.isRegisteredAndReady) {
return;
}
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
BOOL hasLaunchedOnce = [userDefaults boolForKey:@"hasLaunchedOnce"];
if (hasLaunchedOnce) { // FIXME: Quick and dirty workaround to not do this on initial launch
[self sendConfigurationSyncMessage_AppReady];
}
[self sendConfigurationSyncMessage_AppReady];
}];
}

@ -50,7 +50,8 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
- (void)updateLocalProfileName:(nullable NSString *)profileName
avatarImage:(nullable UIImage *)avatarImage
success:(void (^)(void))successBlock
failure:(void (^)(NSError *))failureBlock;
failure:(void (^)(NSError *))failureBlock
requiresSync:(BOOL)requiresSync;
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;

@ -230,6 +230,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
avatarImage:(nullable UIImage *)avatarImage
success:(void (^)(void))successBlockParameter
failure:(void (^)(NSError *))failureBlockParameter
requiresSync:(BOOL)requiresSync
{
OWSAssertDebug(successBlockParameter);
OWSAssertDebug(failureBlockParameter);
@ -244,7 +245,9 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
//
// NOTE: We also inform the desktop in the failure case,
// since that _may have_ affected service state.
[[self.syncManager syncLocalContact] retainUntilComplete];
if (requiresSync) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}
dispatch_async(dispatch_get_main_queue(), ^{
failureBlockParameter(error);
@ -256,7 +259,9 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
// We use a "self-only" contact sync to indicate to desktop
// that we've changed our profile and that it should do a
// profile fetch for "self".
[[self.syncManager syncLocalContact] retainUntilComplete];
if (requiresSync) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}
dispatch_async(dispatch_get_main_queue(), ^{
successBlockParameter();

@ -243,7 +243,10 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
// We populate an initial (empty) profile on launch of a new install, but until
// we have a registered account, syncing will fail (and there could not be any
// linked device to sync to at this point anyway).
if ([self.tsAccountManager isRegistered] && CurrentAppContext().isMainApp) {
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
BOOL hasLaunchedOnce = [userDefaults boolForKey:@"hasLaunchedOnce"];
if ([self.tsAccountManager isRegistered] && CurrentAppContext().isMainApp && hasLaunchedOnce) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}

@ -3,7 +3,7 @@ import SignalMetadataKit
/// Base class for `LokiFileServerAPI` and `LokiPublicChatAPI`.
public class LokiDotNetAPI : NSObject {
// MARK: Convenience
internal static let storage = OWSPrimaryStorage.shared()
internal static let userKeyPair = OWSIdentityManager.shared().identityKeyPair()!
@ -41,6 +41,17 @@ public class LokiDotNetAPI : NSObject {
return result
}
}
internal static func getAuthToken(for server: String, in transaction: YapDatabaseReadWriteTransaction? = nil) -> Promise<String> {
if let token = getAuthTokenFromDatabase(for: server, in: transaction) {
return Promise.value(token)
} else {
return requestNewAuthToken(for: server).then(on: DispatchQueue.global()) { submitAuthToken($0, for: server) }.map { token -> String in
setAuthToken(for: server, to: token, in: transaction)
return token
}
}
}
private static func setAuthToken(for server: String, to newValue: String, in transaction: YapDatabaseReadWriteTransaction? = nil) {
func setAuthTokenInternal(in transaction: YapDatabaseReadWriteTransaction) {
@ -159,18 +170,6 @@ public class LokiDotNetAPI : NSObject {
}
}
}
// MARK: Internal API
internal static func getAuthToken(for server: String, in transaction: YapDatabaseReadWriteTransaction? = nil) -> Promise<String> {
if let token = getAuthTokenFromDatabase(for: server, in: transaction) {
return Promise.value(token)
} else {
return requestNewAuthToken(for: server).then(on: DispatchQueue.global()) { submitAuthToken($0, for: server) }.map { token -> String in
setAuthToken(for: server, to: token, in: transaction)
return token
}
}
}
// MARK: Private API
private static func requestNewAuthToken(for server: String) -> Promise<String> {

Loading…
Cancel
Save