Clean & debug
This commit is contained in:
parent
1822b661e4
commit
92304fa590
|
@ -29,7 +29,6 @@ extension Storage {
|
|||
let (ed25519KeyPair, x25519KeyPair) = KeyPairUtilities.generate(from: seed)
|
||||
KeyPairUtilities.store(seed: seed, ed25519KeyPair: ed25519KeyPair, x25519KeyPair: x25519KeyPair)
|
||||
TSAccountManager.sharedInstance().phoneNumberAwaitingVerification = x25519KeyPair.hexEncodedPublicKey
|
||||
OWSPrimaryStorage.shared().setRestorationTime(0)
|
||||
UserDefaults.standard[.hasViewedSeed] = false
|
||||
let displayName = UserDefaults.standard[.displayName]! // Checked earlier
|
||||
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }, requiresSync: false)
|
||||
|
|
|
@ -72,6 +72,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
result.axis = .vertical
|
||||
result.spacing = Values.mediumSpacing
|
||||
result.alignment = .center
|
||||
result.isHidden = true
|
||||
return result
|
||||
}()
|
||||
|
||||
|
@ -193,7 +194,6 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
let ext = dbConnection.ext(TSThreadDatabaseViewExtensionName) as! YapDatabaseViewConnection
|
||||
let hasChanges = ext.hasChanges(forGroup: TSInboxGroup, in: notifications)
|
||||
guard hasChanges else { return }
|
||||
guard !notifications.isEmpty else { return }
|
||||
if let firstChangeSet = notifications[0].userInfo {
|
||||
let firstSnapshot = firstChangeSet[YapDatabaseSnapshotKey] as! UInt64
|
||||
if threads.snapshotOfLastUpdate != firstSnapshot - 1 {
|
||||
|
|
|
@ -7,8 +7,8 @@ extension AppDelegate {
|
|||
guard Storage.shared.getUser()?.name != nil else { return }
|
||||
let userDefaults = UserDefaults.standard
|
||||
let lastSync = userDefaults[.lastConfigurationSync] ?? .distantPast
|
||||
guard Date().timeIntervalSince(lastSync) > 2 * 24 * 60 * 60 else { return } // Sync every 2 days
|
||||
let configurationMessage = ConfigurationMessage.getCurrent()
|
||||
guard Date().timeIntervalSince(lastSync) > 2 * 24 * 60 * 60,
|
||||
let configurationMessage = ConfigurationMessage.getCurrent() else { return } // Sync every 2 days
|
||||
let destination = Message.Destination.contact(publicKey: getUserHexEncodedPublicKey())
|
||||
Storage.shared.write { transaction in
|
||||
let job = MessageSendJob(message: configurationMessage, destination: destination)
|
||||
|
@ -18,8 +18,8 @@ extension AppDelegate {
|
|||
}
|
||||
|
||||
func forceSyncConfigurationNowIfNeeded() -> Promise<Void> {
|
||||
guard Storage.shared.getUser()?.name != nil else { return Promise.value(()) }
|
||||
let configurationMessage = ConfigurationMessage.getCurrent()
|
||||
guard Storage.shared.getUser()?.name != nil,
|
||||
let configurationMessage = ConfigurationMessage.getCurrent() else { return Promise.value(()) }
|
||||
let destination = Message.Destination.contact(publicKey: getUserHexEncodedPublicKey())
|
||||
let (promise, seal) = Promise<Void>.pending()
|
||||
Storage.writeSync { transaction in
|
||||
|
|
|
@ -9,15 +9,12 @@ enum Onboarding {
|
|||
let userDefaults = UserDefaults.standard
|
||||
KeyPairUtilities.store(seed: seed, ed25519KeyPair: ed25519KeyPair, x25519KeyPair: x25519KeyPair)
|
||||
TSAccountManager.sharedInstance().phoneNumberAwaitingVerification = x25519KeyPair.hexEncodedPublicKey
|
||||
let restorationTime: TimeInterval
|
||||
switch self {
|
||||
case .register:
|
||||
userDefaults[.hasViewedSeed] = false
|
||||
restorationTime = 0
|
||||
userDefaults[.hasSyncedInitialConfiguration] = true
|
||||
case .recover, .link:
|
||||
userDefaults[.hasViewedSeed] = true
|
||||
restorationTime = Date().timeIntervalSince1970
|
||||
userDefaults[.hasSyncedInitialConfiguration] = false
|
||||
}
|
||||
switch self {
|
||||
|
@ -26,7 +23,6 @@ enum Onboarding {
|
|||
userDefaults[.lastProfilePictureUpdate] = Date()
|
||||
case .link: break
|
||||
}
|
||||
OWSPrimaryStorage.shared().setRestorationTime(restorationTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ extension Storage {
|
|||
if contact.sessionID == getUserHexEncodedPublicKey() {
|
||||
notificationCenter.post(name: Notification.Name(kNSNotificationName_LocalProfileDidChange), object: nil)
|
||||
} else {
|
||||
notificationCenter.post(name: Notification.Name(kNSNotificationName_OtherUsersProfileDidChange), object: nil)
|
||||
let userInfo = [ kNSNotificationKey_ProfileRecipientId : contact.sessionID ]
|
||||
notificationCenter.post(name: Notification.Name(kNSNotificationName_OtherUsersProfileDidChange), object: nil, userInfo: userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
extension ConfigurationMessage {
|
||||
|
||||
public static func getCurrent() -> ConfigurationMessage {
|
||||
public static func getCurrent() -> ConfigurationMessage? {
|
||||
let storage = Storage.shared
|
||||
let user = storage.getUser()!
|
||||
guard let user = storage.getUser() else { return nil }
|
||||
let displayName = user.name
|
||||
let profilePictureURL = user.profilePictureURL
|
||||
let profileKey = user.profilePictureEncryptionKey?.keyData
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#import <SessionMessagingKit/OWSPrimaryStorage.h>
|
||||
|
||||
#import <Curve25519Kit/Ed25519.h>
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
|
||||
|
@ -7,25 +6,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSPrimaryStorage (Loki)
|
||||
|
||||
# pragma mark - Last Message Hash
|
||||
|
||||
/**
|
||||
* Gets the last message hash and removes it if its `expiresAt` has already passed.
|
||||
*/
|
||||
- (NSString *_Nullable)getLastMessageHashForSnode:(NSString *)snode transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)setLastMessageHashForSnode:(NSString *)snode hash:(NSString *)hash expiresAt:(u_int64_t)expiresAt transaction:(YapDatabaseReadWriteTransaction *)transaction NS_SWIFT_NAME(setLastMessageHash(forSnode:hash:expiresAt:transaction:));
|
||||
|
||||
# pragma mark - Open Groups
|
||||
|
||||
- (void)setIDForMessageWithServerID:(NSUInteger)serverID to:(NSString *)messageID in:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (NSString *_Nullable)getIDForMessageWithServerID:(NSUInteger)serverID in:(YapDatabaseReadTransaction *)transaction;
|
||||
- (void)updateMessageIDCollectionByPruningMessagesWithIDs:(NSSet<NSString *> *)targetMessageIDs in:(YapDatabaseReadWriteTransaction *)transaction NS_SWIFT_NAME(updateMessageIDCollectionByPruningMessagesWithIDs(_:in:));
|
||||
|
||||
# pragma mark - Restoration from Seed
|
||||
|
||||
- (void)setRestorationTime:(NSTimeInterval)time;
|
||||
- (NSTimeInterval)getRestorationTime;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -8,31 +8,9 @@
|
|||
#import "NSObject+Casting.h"
|
||||
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
|
||||
|
||||
@implementation OWSPrimaryStorage (Loki)
|
||||
|
||||
# pragma mark - Convenience
|
||||
|
||||
- (OWSIdentityManager *)identityManager {
|
||||
return OWSIdentityManager.sharedManager;
|
||||
}
|
||||
|
||||
- (TSAccountManager *)accountManager {
|
||||
return TSAccountManager.sharedInstance;
|
||||
}
|
||||
|
||||
# pragma mark - Open Groups
|
||||
|
||||
#define LKMessageIDCollection @"LKMessageIDCollection"
|
||||
|
||||
- (void)setIDForMessageWithServerID:(NSUInteger)serverID to:(NSString *)messageID in:(YapDatabaseReadWriteTransaction *)transaction {
|
||||
NSString *key = [NSString stringWithFormat:@"%@", @(serverID)];
|
||||
[transaction setObject:messageID forKey:key inCollection:LKMessageIDCollection];
|
||||
}
|
||||
|
||||
- (NSString *_Nullable)getIDForMessageWithServerID:(NSUInteger)serverID in:(YapDatabaseReadTransaction *)transaction {
|
||||
NSString *key = [NSString stringWithFormat:@"%@", @(serverID)];
|
||||
return [transaction objectForKey:key inCollection:LKMessageIDCollection];
|
||||
}
|
||||
@implementation OWSPrimaryStorage (Loki)
|
||||
|
||||
- (void)updateMessageIDCollectionByPruningMessagesWithIDs:(NSSet<NSString *> *)targetMessageIDs in:(YapDatabaseReadWriteTransaction *)transaction {
|
||||
NSMutableArray<NSString *> *serverIDs = [NSMutableArray new];
|
||||
|
@ -45,16 +23,4 @@
|
|||
[transaction removeObjectsForKeys:serverIDs inCollection:LKMessageIDCollection];
|
||||
}
|
||||
|
||||
# pragma mark - Restoration from Seed
|
||||
|
||||
#define LKGeneralCollection @"Loki"
|
||||
|
||||
- (void)setRestorationTime:(NSTimeInterval)time {
|
||||
[self.dbReadWriteConnection setDouble:time forKey:@"restoration_time" inCollection:LKGeneralCollection];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)getRestorationTime {
|
||||
return [self.dbReadConnection doubleForKey:@"restoration_time" inCollection:LKGeneralCollection defaultValue:0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue