Send sync messages with link previews preference.

pull/1/head
Matthew Chen 6 years ago
parent b1cce5ef71
commit 77396e11fd

@ -239,11 +239,13 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled; BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators; BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled; BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
BOOL sendLinkPreviews = SSKPreferences.areLinkPreviewsEnabled;
OWSSyncConfigurationMessage *syncConfigurationMessage = OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
showTypingIndicators:showTypingIndicators]; showTypingIndicators:showTypingIndicators
sendLinkPreviews:sendLinkPreviews];
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction]; [self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction];

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "OWSOutgoingSyncMessage.h" #import "OWSOutgoingSyncMessage.h"
@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled - (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators NS_DESIGNATED_INITIALIZER; showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "OWSSyncConfigurationMessage.h" #import "OWSSyncConfigurationMessage.h"
@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled; @property (nonatomic, readonly) BOOL areReadReceiptsEnabled;
@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators; @property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators;
@property (nonatomic, readonly) BOOL showTypingIndicators; @property (nonatomic, readonly) BOOL showTypingIndicators;
@property (nonatomic, readonly) BOOL sendLinkPreviews;
@end @end
@ -19,7 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled - (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators { showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews
{
self = [super init]; self = [super init];
if (!self) { if (!self) {
return nil; return nil;
@ -28,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
_areReadReceiptsEnabled = areReadReceiptsEnabled; _areReadReceiptsEnabled = areReadReceiptsEnabled;
_showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators; _showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators;
_showTypingIndicators = showTypingIndicators; _showTypingIndicators = showTypingIndicators;
_sendLinkPreviews = sendLinkPreviews;
return self; return self;
} }
@ -43,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
configurationBuilder.readReceipts = self.areReadReceiptsEnabled; configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators; configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators;
configurationBuilder.typingIndicators = self.showTypingIndicators; configurationBuilder.typingIndicators = self.showTypingIndicators;
configurationBuilder.linkPreviews = self.sendLinkPreviews;
NSError *error; NSError *error;
SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error]; SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error];

@ -21,8 +21,9 @@ public class SSKPreferences: NSObject {
@objc @objc
public class func setAreLinkPreviewsEnabled(value: Bool) { public class func setAreLinkPreviewsEnabled(value: Bool) {
return OWSPrimaryStorage.dbReadWriteConnection().setBool(value, OWSPrimaryStorage.dbReadWriteConnection().setBool(value,
forKey: areLinkPreviewsEnabledKey, forKey: areLinkPreviewsEnabledKey,
inCollection: collection) inCollection: collection)
SSKEnvironment.shared.syncManager.sendConfigurationSyncMessage()
} }
} }

Loading…
Cancel
Save