mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
use UUID for TSInteractions.uniqueId
This commit is contained in:
parent
65cef9f980
commit
366b228c01
|
@ -174,7 +174,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
|||
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction {
|
||||
if (!self.uniqueId) {
|
||||
OWSFailDebug(self.uniqueId);
|
||||
self.uniqueId = [OWSPrimaryStorage getAndIncrementMessageIdWithTransaction:transaction];
|
||||
self.uniqueId = [NSUUID new];
|
||||
}
|
||||
|
||||
[super saveWithTransaction:transaction];
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSPrimaryStorage.h"
|
||||
|
||||
@interface OWSPrimaryStorage (messageIDs)
|
||||
|
||||
+ (NSString *)getAndIncrementMessageIdWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
@end
|
|
@ -1,34 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSPrimaryStorage+messageIDs.h"
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
|
||||
#define TSStorageParametersCollection @"TSStorageParametersCollection"
|
||||
#define TSMessagesLatestId @"TSMessagesLatestId"
|
||||
|
||||
@implementation OWSPrimaryStorage (messageIDs)
|
||||
|
||||
+ (NSString *)getAndIncrementMessageIdWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
NSString *messageId = [transaction objectForKey:TSMessagesLatestId inCollection:TSStorageParametersCollection];
|
||||
if (!messageId) {
|
||||
messageId = @"0";
|
||||
}
|
||||
|
||||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
NSNumber *myNumber = [numberFormatter numberFromString:messageId];
|
||||
|
||||
unsigned long long nextMessageId = [myNumber unsignedLongLongValue];
|
||||
nextMessageId++;
|
||||
|
||||
NSString *nextMessageIdString = [[NSNumber numberWithUnsignedLongLong:nextMessageId] stringValue];
|
||||
|
||||
[transaction setObject:nextMessageIdString forKey:TSMessagesLatestId inCollection:TSStorageParametersCollection];
|
||||
|
||||
return messageId;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue