Fix build
This commit is contained in:
parent
4f3544c1fc
commit
4105f17c02
|
@ -18,6 +18,7 @@
|
|||
#import <SessionServiceKit/TSQuotedMessage.h>
|
||||
#import <SessionServiceKit/TSThread.h>
|
||||
#import <SessionServiceKit/YapDatabaseTransaction+OWS.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
|
|
@ -376,25 +376,22 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
|
|||
// TODO - in line with QuotedReply and other message attachments, saving should happen as part of sending
|
||||
// preparation rather than duplicated here and in the SAE
|
||||
|
||||
// TODO: <--------
|
||||
|
||||
[self.dbReadWriteConnection
|
||||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
if (contactShare.avatarImage) {
|
||||
[contactShare.dbRecord saveAvatarImage:contactShare.avatarImage transaction:transaction];
|
||||
}
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
if (contactShare.avatarImage) {
|
||||
[contactShare.dbRecord saveAvatarImage:contactShare.avatarImage transaction:transaction];
|
||||
}
|
||||
completionBlock:^{
|
||||
__block TSOutgoingMessage *outgoingMessage = nil;
|
||||
outgoingMessage = [ThreadUtil sendMessageNonDurablyWithContactShare:contactShare.dbRecord
|
||||
inThread:self.thread
|
||||
messageSender:self.messageSender
|
||||
completion:^(NSError *_Nullable error) {
|
||||
sendCompletion(error, outgoingMessage);
|
||||
}];
|
||||
// This is necessary to show progress.
|
||||
self.outgoingMessage = outgoingMessage;
|
||||
}];
|
||||
}
|
||||
completion:^{
|
||||
__block TSOutgoingMessage *outgoingMessage = nil;
|
||||
outgoingMessage = [ThreadUtil sendMessageNonDurablyWithContactShare:contactShare.dbRecord
|
||||
inThread:self.thread
|
||||
messageSender:self.messageSender
|
||||
completion:^(NSError *_Nullable error) {
|
||||
sendCompletion(error, outgoingMessage);
|
||||
}];
|
||||
// This is necessary to show progress.
|
||||
self.outgoingMessage = outgoingMessage;
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -72,14 +72,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSDatabaseConnection *dbConnection = (OWSDatabaseConnection *)self.primaryStorage.newDatabaseConnection;
|
||||
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[self runUpWithTransaction:transaction];
|
||||
}
|
||||
completionBlock:^{
|
||||
OWSLogInfo(@"Completed migration %@", self.uniqueId);
|
||||
[self save];
|
||||
[self runUpWithTransaction:transaction];
|
||||
}
|
||||
completion:^{
|
||||
OWSLogInfo(@"Completed migration %@", self.uniqueId);
|
||||
[self save];
|
||||
|
||||
completion();
|
||||
}];
|
||||
completion();
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Database Connections
|
||||
|
|
|
@ -25,14 +25,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[recordIds addObjectsFromArray:[transaction allKeysInCollection:collection]];
|
||||
OWSLogInfo(@"Migrating %lu records from: %@.", (unsigned long)recordIds.count, collection);
|
||||
}
|
||||
completionQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
|
||||
completionBlock:^{
|
||||
[self resaveBatch:recordIds
|
||||
collection:collection
|
||||
filter:filter
|
||||
dbConnection:dbConnection
|
||||
completion:completion];
|
||||
}];
|
||||
completion:^{
|
||||
[self resaveBatch:recordIds
|
||||
collection:collection
|
||||
filter:filter
|
||||
dbConnection:dbConnection
|
||||
completion:completion];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resaveBatch:(NSMutableArray<NSString *> *)recordIds
|
||||
|
@ -66,14 +65,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[entity saveWithTransaction:transaction];
|
||||
}
|
||||
}
|
||||
completionBlock:^{
|
||||
// Process the next batch.
|
||||
[self resaveBatch:recordIds
|
||||
collection:collection
|
||||
filter:filter
|
||||
dbConnection:dbConnection
|
||||
completion:completion];
|
||||
}];
|
||||
completion:^{
|
||||
// Process the next batch.
|
||||
[self resaveBatch:recordIds
|
||||
collection:collection
|
||||
filter:filter
|
||||
dbConnection:dbConnection
|
||||
completion:completion];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#import <SessionServiceKit/TSYapDatabaseObject.h>
|
||||
#import <SessionServiceKit/UIImage+OWS.h>
|
||||
#import <SessionServiceKit/YapDatabaseConnection+OWS.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -813,16 +814,16 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
[newRecipientIds addObject:recipientId];
|
||||
}
|
||||
}
|
||||
completionBlock:^{
|
||||
for (NSString *recipientId in newRecipientIds) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kNSNotificationKey_ProfileRecipientId : recipientId,
|
||||
}];
|
||||
}
|
||||
}];
|
||||
completion:^{
|
||||
for (NSString *recipientId in newRecipientIds) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kNSNotificationKey_ProfileRecipientId : recipientId,
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)isUserInProfileWhitelist:(NSString *)recipientId
|
||||
|
@ -859,16 +860,16 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
didChange = YES;
|
||||
}
|
||||
}
|
||||
completionBlock:^{
|
||||
if (didChange) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kNSNotificationKey_ProfileGroupId : groupId,
|
||||
}];
|
||||
}
|
||||
}];
|
||||
completion:^{
|
||||
if (didChange) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kNSNotificationKey_ProfileGroupId : groupId,
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)addThreadToProfileWhitelist:(TSThread *)thread
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#import <SessionServiceKit/TSInvalidIdentityKeyErrorMessage.h>
|
||||
#import <SessionServiceKit/TSOutgoingMessage.h>
|
||||
#import <SessionServiceKit/TSThread.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -203,28 +204,23 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
|
|||
block:^(void (^benchmarkCompletion)(void)) {
|
||||
// To avoid blocking the send flow, we dispatch an async write from within this read
|
||||
// transaction
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull writeTransaction) {
|
||||
[message saveWithTransaction:writeTransaction];
|
||||
|
||||
// TODO: <-------
|
||||
|
||||
[self.dbConnection
|
||||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull writeTransaction) {
|
||||
[message saveWithTransaction:writeTransaction];
|
||||
|
||||
OWSLinkPreview *_Nullable linkPreview =
|
||||
[self linkPreviewForLinkPreviewDraft:linkPreviewDraft
|
||||
transaction:writeTransaction];
|
||||
if (linkPreview) {
|
||||
[message updateWithLinkPreview:linkPreview transaction:writeTransaction];
|
||||
}
|
||||
|
||||
NSMutableArray<OWSOutgoingAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
OWSOutgoingAttachmentInfo *attachmentInfo = [attachment buildOutgoingAttachmentInfoWithMessage:message];
|
||||
[attachmentInfos addObject:attachmentInfo];
|
||||
}
|
||||
completionBlock(message, attachmentInfos, writeTransaction);
|
||||
OWSLinkPreview *_Nullable linkPreview =
|
||||
[self linkPreviewForLinkPreviewDraft:linkPreviewDraft
|
||||
transaction:writeTransaction];
|
||||
if (linkPreview) {
|
||||
[message updateWithLinkPreview:linkPreview transaction:writeTransaction];
|
||||
}
|
||||
completionBlock:benchmarkCompletion];
|
||||
|
||||
NSMutableArray<OWSOutgoingAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
OWSOutgoingAttachmentInfo *attachmentInfo = [attachment buildOutgoingAttachmentInfoWithMessage:message];
|
||||
[attachmentInfos addObject:attachmentInfo];
|
||||
}
|
||||
completionBlock(message, attachmentInfos, writeTransaction);
|
||||
} completion:benchmarkCompletion];
|
||||
}];
|
||||
|
||||
return message;
|
||||
|
@ -721,7 +717,7 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
|
|||
} @catch (NSException *exception) {
|
||||
// Do nothing
|
||||
}
|
||||
}];
|
||||
} error:nil];
|
||||
[TSAttachmentStream deleteAttachments];
|
||||
}
|
||||
|
||||
|
|
|
@ -32,27 +32,39 @@ public final class Storage : NSObject {
|
|||
// • There can only be a single write transaction per database at any one time, so all write transactions must use `OWSPrimaryStorage`'s `dbReadWriteConnection`.
|
||||
// • Executing a write transaction from within a write transaction causes a deadlock and must be avoided.
|
||||
|
||||
@discardableResult
|
||||
@objc(writeWithBlock:)
|
||||
public static func objc_write(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) -> AnyPromise {
|
||||
return AnyPromise.from(write(with: block))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public static func write(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) -> Promise<Void> {
|
||||
return write(with: block) { }
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
@objc(writeWithBlock:completion:)
|
||||
public static func objc_write(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void, completion: @escaping () -> Void) -> AnyPromise {
|
||||
return AnyPromise.from(write(with: block, completion: completion))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public static func write(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void, completion: @escaping () -> Void) -> Promise<Void> {
|
||||
let (promise, seal) = Promise<Void>.pending()
|
||||
serialQueue.async { // TODO: There are cases where this isn't necessary
|
||||
owsStorage.dbReadWriteConnection.readWrite(block)
|
||||
DispatchQueue.main.async {
|
||||
completion()
|
||||
}
|
||||
seal.fulfill(())
|
||||
}
|
||||
return promise
|
||||
}
|
||||
|
||||
/// Blocks the calling thread until the write has finished.
|
||||
@discardableResult
|
||||
@objc(writeSyncWithBlock:error:)
|
||||
public static func objc_writeSync(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) throws {
|
||||
try writeSync(with: block)
|
||||
}
|
||||
|
||||
/// Blocks the calling thread until the write has finished.
|
||||
public static func writeSync(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) throws {
|
||||
try write(with: block).wait()
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#import "TSMessage.h"
|
||||
#import "TSThread.h"
|
||||
#import <SessionCoreKit/NSDate+OWS.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <YapDatabase/YapDatabaseQuery.h>
|
||||
#import <YapDatabase/YapDatabaseSecondaryIndex.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <YapDatabase/YapDatabaseQuery.h>
|
||||
#import <YapDatabase/YapDatabaseSecondaryIndex.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <YapDatabase/YapDatabaseQuery.h>
|
||||
#import <YapDatabase/YapDatabaseSecondaryIndex.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#import "OWSPrimaryStorage.h"
|
||||
#import "SSKEnvironment.h"
|
||||
#import <YapDatabase/YapDatabaseTransaction.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -52,11 +53,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (void)saveAsyncWithCompletionBlock:(void (^_Nullable)(void))completionBlock
|
||||
{
|
||||
// TODO: <--------
|
||||
[[self dbReadWriteConnection] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[self saveWithTransaction:transaction];
|
||||
}
|
||||
completionBlock:completionBlock];
|
||||
} completion:completionBlock];
|
||||
}
|
||||
|
||||
- (void)touchWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#import <Reachability/Reachability.h>
|
||||
#import <SessionCoreKit/Cryptography.h>
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <SessionServiceKit/SessionServiceKit-Swift.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
Loading…
Reference in New Issue