Merge branch 'charlesmchen/syncLinkPreviewsSetting'
This commit is contained in:
commit
cf93949b43
@ -298,7 +298,6 @@
|
||||
34EA69422194DE8000702471 /* MediaUploadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34EA69412194DE7F00702471 /* MediaUploadView.swift */; };
|
||||
34F308A21ECB469700BB7697 /* OWSBezierPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34F308A11ECB469700BB7697 /* OWSBezierPathView.m */; };
|
||||
34FDB29221FF986600A01202 /* UIView+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34FDB29121FF986600A01202 /* UIView+OWS.swift */; };
|
||||
34FDB2942200974600A01202 /* OWS115LinkPreviewsMigration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34FDB2932200974600A01202 /* OWS115LinkPreviewsMigration.swift */; };
|
||||
4503F1BE20470A5B00CEE724 /* classic-quiet.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */; };
|
||||
4503F1BF20470A5B00CEE724 /* classic.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BC20470A5B00CEE724 /* classic.aifc */; };
|
||||
4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */ = {isa = PBXBuildFile; fileRef = 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */; };
|
||||
@ -1015,7 +1014,6 @@
|
||||
34F308A01ECB469700BB7697 /* OWSBezierPathView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSBezierPathView.h; sourceTree = "<group>"; };
|
||||
34F308A11ECB469700BB7697 /* OWSBezierPathView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBezierPathView.m; sourceTree = "<group>"; };
|
||||
34FDB29121FF986600A01202 /* UIView+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+OWS.swift"; sourceTree = "<group>"; };
|
||||
34FDB2932200974600A01202 /* OWS115LinkPreviewsMigration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWS115LinkPreviewsMigration.swift; sourceTree = "<group>"; };
|
||||
435EAC2E5E22D3F087EB3192 /* Pods-SignalShareExtension.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.app store release.xcconfig"; sourceTree = "<group>"; };
|
||||
4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = "classic-quiet.aifc"; sourceTree = "<group>"; };
|
||||
4503F1BC20470A5B00CEE724 /* classic.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = classic.aifc; sourceTree = "<group>"; };
|
||||
@ -1682,7 +1680,6 @@
|
||||
34B6A908218B8824007C4606 /* OWS112TypingIndicatorsMigration.swift */,
|
||||
4C7537882193779700DF5E37 /* OWS113MultiAttachmentMediaMessages.swift */,
|
||||
34BEDB0A21C2FA3D007B0EAE /* OWS114RemoveDynamicInteractions.swift */,
|
||||
34FDB2932200974600A01202 /* OWS115LinkPreviewsMigration.swift */,
|
||||
346129931FD1E30000532771 /* OWSDatabaseMigration.h */,
|
||||
346129941FD1E30000532771 /* OWSDatabaseMigration.m */,
|
||||
346129E51FD5C0C600532771 /* OWSDatabaseMigrationRunner.h */,
|
||||
@ -3414,7 +3411,6 @@
|
||||
346129AF1FD1F5D900532771 /* SystemContactsFetcher.swift in Sources */,
|
||||
34AC09E3211B39B100997B47 /* OWSViewController.m in Sources */,
|
||||
346129C81FD2072E00532771 /* NSAttributedString+OWS.m in Sources */,
|
||||
34FDB2942200974600A01202 /* OWS115LinkPreviewsMigration.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@ -1326,12 +1326,17 @@ static NSTimeInterval launchStartedAt;
|
||||
|
||||
[self.primaryStorage touchDbAsync];
|
||||
|
||||
// Try to update account attributes every time we upgrade.
|
||||
// Every time the user upgrades to a new version:
|
||||
//
|
||||
// * Update account attributes.
|
||||
// * Sync configuration.
|
||||
if ([self.tsAccountManager isRegistered]) {
|
||||
AppVersion *appVersion = AppVersion.sharedInstance;
|
||||
if (appVersion.lastAppVersion.length > 0
|
||||
&& ![appVersion.lastAppVersion isEqualToString:appVersion.currentAppVersion]) {
|
||||
[[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
|
||||
|
||||
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,11 +239,13 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
|
||||
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
|
||||
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
|
||||
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
|
||||
BOOL sendLinkPreviews = SSKPreferences.areLinkPreviewsEnabled;
|
||||
|
||||
OWSSyncConfigurationMessage *syncConfigurationMessage =
|
||||
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
|
||||
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
|
||||
showTypingIndicators:showTypingIndicators];
|
||||
showTypingIndicators:showTypingIndicators
|
||||
sendLinkPreviews:sendLinkPreviews];
|
||||
|
||||
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction];
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SignalServiceKit
|
||||
|
||||
@objc
|
||||
public class OWS115LinkPreviewsMigration: OWSDatabaseMigration {
|
||||
|
||||
// MARK: -
|
||||
|
||||
// Increment a similar constant for each migration.
|
||||
@objc
|
||||
class func migrationId() -> String {
|
||||
return "115"
|
||||
}
|
||||
|
||||
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) {
|
||||
Logger.debug("")
|
||||
BenchAsync(title: "Link Previews Migration") { (benchCompletion) in
|
||||
self.doMigrationAsync(completion: {
|
||||
benchCompletion()
|
||||
completion()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func doMigrationAsync(completion : @escaping OWSDatabaseMigrationCompletion) {
|
||||
DispatchQueue.main.async {
|
||||
// Link Previews should be disabled by default for legacy users.
|
||||
SSKPreferences.setAreLinkPreviewsEnabled(value: false)
|
||||
|
||||
DispatchQueue.global().async {
|
||||
self.dbReadWriteConnection().readWrite { transaction in
|
||||
self.save(with: transaction)
|
||||
}
|
||||
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[[OWS112TypingIndicatorsMigration alloc] init],
|
||||
[[OWS113MultiAttachmentMediaMessages alloc] init],
|
||||
[[OWS114RemoveDynamicInteractions alloc] init],
|
||||
[[OWS115LinkPreviewsMigration alloc] init],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -304,9 +304,10 @@ message SyncMessage {
|
||||
}
|
||||
|
||||
message Configuration {
|
||||
optional bool readReceipts = 1;
|
||||
optional bool readReceipts = 1;
|
||||
optional bool unidentifiedDeliveryIndicators = 2;
|
||||
optional bool typingIndicators = 3;
|
||||
optional bool typingIndicators = 3;
|
||||
optional bool linkPreviews = 4;
|
||||
}
|
||||
|
||||
optional Sent sent = 1;
|
||||
|
||||
@ -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"
|
||||
@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
|
||||
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;
|
||||
|
||||
|
||||
@ -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"
|
||||
@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled;
|
||||
@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators;
|
||||
@property (nonatomic, readonly) BOOL showTypingIndicators;
|
||||
@property (nonatomic, readonly) BOOL sendLinkPreviews;
|
||||
|
||||
@end
|
||||
|
||||
@ -19,7 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
|
||||
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
|
||||
showTypingIndicators:(BOOL)showTypingIndicators {
|
||||
showTypingIndicators:(BOOL)showTypingIndicators
|
||||
sendLinkPreviews:(BOOL)sendLinkPreviews
|
||||
{
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
@ -28,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
_areReadReceiptsEnabled = areReadReceiptsEnabled;
|
||||
_showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators;
|
||||
_showTypingIndicators = showTypingIndicators;
|
||||
_sendLinkPreviews = sendLinkPreviews;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -43,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
|
||||
configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators;
|
||||
configurationBuilder.typingIndicators = self.showTypingIndicators;
|
||||
configurationBuilder.linkPreviews = self.sendLinkPreviews;
|
||||
|
||||
NSError *error;
|
||||
SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error];
|
||||
|
||||
@ -4307,6 +4307,9 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
|
||||
if hasTypingIndicators {
|
||||
builder.setTypingIndicators(typingIndicators)
|
||||
}
|
||||
if hasLinkPreviews {
|
||||
builder.setLinkPreviews(linkPreviews)
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
@ -4328,6 +4331,10 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
|
||||
proto.typingIndicators = valueParam
|
||||
}
|
||||
|
||||
@objc public func setLinkPreviews(_ valueParam: Bool) {
|
||||
proto.linkPreviews = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SSKProtoSyncMessageConfiguration {
|
||||
return try SSKProtoSyncMessageConfiguration.parseProto(proto)
|
||||
}
|
||||
@ -4360,6 +4367,13 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
|
||||
return proto.hasTypingIndicators
|
||||
}
|
||||
|
||||
@objc public var linkPreviews: Bool {
|
||||
return proto.linkPreviews
|
||||
}
|
||||
@objc public var hasLinkPreviews: Bool {
|
||||
return proto.hasLinkPreviews
|
||||
}
|
||||
|
||||
private init(proto: SignalServiceProtos_SyncMessage.Configuration) {
|
||||
self.proto = proto
|
||||
}
|
||||
|
||||
@ -1795,6 +1795,15 @@ struct SignalServiceProtos_SyncMessage {
|
||||
/// Clears the value of `typingIndicators`. Subsequent reads from it will return its default value.
|
||||
mutating func clearTypingIndicators() {self._typingIndicators = nil}
|
||||
|
||||
var linkPreviews: Bool {
|
||||
get {return _linkPreviews ?? false}
|
||||
set {_linkPreviews = newValue}
|
||||
}
|
||||
/// Returns true if `linkPreviews` has been explicitly set.
|
||||
var hasLinkPreviews: Bool {return self._linkPreviews != nil}
|
||||
/// Clears the value of `linkPreviews`. Subsequent reads from it will return its default value.
|
||||
mutating func clearLinkPreviews() {self._linkPreviews = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
@ -1802,6 +1811,7 @@ struct SignalServiceProtos_SyncMessage {
|
||||
fileprivate var _readReceipts: Bool? = nil
|
||||
fileprivate var _unidentifiedDeliveryIndicators: Bool? = nil
|
||||
fileprivate var _typingIndicators: Bool? = nil
|
||||
fileprivate var _linkPreviews: Bool? = nil
|
||||
}
|
||||
|
||||
init() {}
|
||||
@ -4199,6 +4209,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
|
||||
1: .same(proto: "readReceipts"),
|
||||
2: .same(proto: "unidentifiedDeliveryIndicators"),
|
||||
3: .same(proto: "typingIndicators"),
|
||||
4: .same(proto: "linkPreviews"),
|
||||
]
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
@ -4207,6 +4218,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
|
||||
case 1: try decoder.decodeSingularBoolField(value: &self._readReceipts)
|
||||
case 2: try decoder.decodeSingularBoolField(value: &self._unidentifiedDeliveryIndicators)
|
||||
case 3: try decoder.decodeSingularBoolField(value: &self._typingIndicators)
|
||||
case 4: try decoder.decodeSingularBoolField(value: &self._linkPreviews)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
@ -4222,6 +4234,9 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
|
||||
if let v = self._typingIndicators {
|
||||
try visitor.visitSingularBoolField(value: v, fieldNumber: 3)
|
||||
}
|
||||
if let v = self._linkPreviews {
|
||||
try visitor.visitSingularBoolField(value: v, fieldNumber: 4)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
@ -4229,6 +4244,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
|
||||
if lhs._readReceipts != rhs._readReceipts {return false}
|
||||
if lhs._unidentifiedDeliveryIndicators != rhs._unidentifiedDeliveryIndicators {return false}
|
||||
if lhs._typingIndicators != rhs._typingIndicators {return false}
|
||||
if lhs._linkPreviews != rhs._linkPreviews {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -21,8 +21,9 @@ public class SSKPreferences: NSObject {
|
||||
|
||||
@objc
|
||||
public class func setAreLinkPreviewsEnabled(value: Bool) {
|
||||
return OWSPrimaryStorage.dbReadWriteConnection().setBool(value,
|
||||
forKey: areLinkPreviewsEnabledKey,
|
||||
inCollection: collection)
|
||||
OWSPrimaryStorage.dbReadWriteConnection().setBool(value,
|
||||
forKey: areLinkPreviewsEnabledKey,
|
||||
inCollection: collection)
|
||||
SSKEnvironment.shared.syncManager.sendConfigurationSyncMessage()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user