Merge branch 'charlesmchen/typingIndicators6'

This commit is contained in:
Matthew Chen 2018-11-01 15:23:01 -04:00
commit 13ab75fea9
7 changed files with 55 additions and 5 deletions

View file

@ -106,6 +106,11 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
return TSAccountManager.sharedInstance;
}
- (id<OWSTypingIndicators>)typingIndicators
{
return SSKEnvironment.shared.typingIndicators;
}
#pragma mark - Notifications
- (void)signalAccountsDidChange:(id)notification {
@ -219,10 +224,12 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators];
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
showTypingIndicators:showTypingIndicators];
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction];

View file

@ -296,8 +296,9 @@ message SyncMessage {
}
message Configuration {
optional bool readReceipts = 1;
optional bool unidentifiedDeliveryIndicators = 2;
optional bool readReceipts = 1;
optional bool unidentifiedDeliveryIndicators = 2;
optional bool typingIndicators = 3;
}
optional Sent sent = 1;

View file

@ -11,7 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators NS_DESIGNATED_INITIALIZER;
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View file

@ -11,13 +11,15 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled;
@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators;
@property (nonatomic, readonly) BOOL showTypingIndicators;
@end
@implementation OWSSyncConfigurationMessage
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators {
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators {
self = [super init];
if (!self) {
return nil;
@ -25,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
_areReadReceiptsEnabled = areReadReceiptsEnabled;
_showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators;
_showTypingIndicators = showTypingIndicators;
return self;
}
@ -39,6 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
SSKProtoSyncMessageConfigurationBuilder *configurationBuilder = [SSKProtoSyncMessageConfiguration builder];
configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators;
configurationBuilder.typingIndicators = self.showTypingIndicators;
NSError *error;
SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error];

View file

@ -4154,6 +4154,9 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
if hasUnidentifiedDeliveryIndicators {
builder.setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators)
}
if hasTypingIndicators {
builder.setTypingIndicators(typingIndicators)
}
return builder
}
@ -4171,6 +4174,10 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
proto.unidentifiedDeliveryIndicators = valueParam
}
@objc public func setTypingIndicators(_ valueParam: Bool) {
proto.typingIndicators = valueParam
}
@objc public func build() throws -> SSKProtoSyncMessageConfiguration {
return try SSKProtoSyncMessageConfiguration.parseProto(proto)
}
@ -4196,6 +4203,13 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
return proto.hasUnidentifiedDeliveryIndicators
}
@objc public var typingIndicators: Bool {
return proto.typingIndicators
}
@objc public var hasTypingIndicators: Bool {
return proto.hasTypingIndicators
}
private init(proto: SignalServiceProtos_SyncMessage.Configuration) {
self.proto = proto
}

View file

@ -1741,12 +1741,22 @@ struct SignalServiceProtos_SyncMessage {
/// Clears the value of `unidentifiedDeliveryIndicators`. Subsequent reads from it will return its default value.
mutating func clearUnidentifiedDeliveryIndicators() {self._unidentifiedDeliveryIndicators = nil}
var typingIndicators: Bool {
get {return _typingIndicators ?? false}
set {_typingIndicators = newValue}
}
/// Returns true if `typingIndicators` has been explicitly set.
var hasTypingIndicators: Bool {return self._typingIndicators != nil}
/// Clears the value of `typingIndicators`. Subsequent reads from it will return its default value.
mutating func clearTypingIndicators() {self._typingIndicators = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _readReceipts: Bool? = nil
fileprivate var _unidentifiedDeliveryIndicators: Bool? = nil
fileprivate var _typingIndicators: Bool? = nil
}
init() {}
@ -4048,6 +4058,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "readReceipts"),
2: .same(proto: "unidentifiedDeliveryIndicators"),
3: .same(proto: "typingIndicators"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
@ -4055,6 +4066,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
switch fieldNumber {
case 1: try decoder.decodeSingularBoolField(value: &self._readReceipts)
case 2: try decoder.decodeSingularBoolField(value: &self._unidentifiedDeliveryIndicators)
case 3: try decoder.decodeSingularBoolField(value: &self._typingIndicators)
default: break
}
}
@ -4067,12 +4079,16 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
if let v = self._unidentifiedDeliveryIndicators {
try visitor.visitSingularBoolField(value: v, fieldNumber: 2)
}
if let v = self._typingIndicators {
try visitor.visitSingularBoolField(value: v, fieldNumber: 3)
}
try unknownFields.traverse(visitor: &visitor)
}
static func ==(lhs: SignalServiceProtos_SyncMessage.Configuration, rhs: SignalServiceProtos_SyncMessage.Configuration) -> Bool {
if lhs._readReceipts != rhs._readReceipts {return false}
if lhs._unidentifiedDeliveryIndicators != rhs._unidentifiedDeliveryIndicators {return false}
if lhs._typingIndicators != rhs._typingIndicators {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}

View file

@ -67,6 +67,10 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
return SSKEnvironment.shared.primaryStorage
}
private var syncManager: OWSSyncManagerProtocol {
return SSKEnvironment.shared.syncManager
}
// MARK: -
@objc
@ -76,6 +80,8 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
_areTypingIndicatorsEnabled = value
primaryStorage.dbReadWriteConnection.setBool(value, forKey: kDatabaseKey_TypingIndicatorsEnabled, inCollection: kDatabaseCollection)
syncManager.sendConfigurationSyncMessage()
}
@objc