This commit is contained in:
Niels Andriesse 2019-09-10 13:26:58 +10:00
parent be00f8c6ad
commit 1338fcda21
8 changed files with 15 additions and 20 deletions

View File

@ -1666,7 +1666,6 @@
4C948FF62146EB4800349F0D /* BlockListCache.swift */, 4C948FF62146EB4800349F0D /* BlockListCache.swift */,
343D3D991E9283F100165CA4 /* BlockListUIUtils.h */, 343D3D991E9283F100165CA4 /* BlockListUIUtils.h */,
343D3D9A1E9283F100165CA4 /* BlockListUIUtils.m */, 343D3D9A1E9283F100165CA4 /* BlockListUIUtils.m */,
241C6312231F5F1D00B4198E /* CGFloat+Rounding.swift */,
3466087120E550F300AFFE73 /* ConversationStyle.swift */, 3466087120E550F300AFFE73 /* ConversationStyle.swift */,
34480B4D1FD0A7A300BC14EF /* DebugLogger.h */, 34480B4D1FD0A7A300BC14EF /* DebugLogger.h */,
34480B4E1FD0A7A300BC14EF /* DebugLogger.m */, 34480B4E1FD0A7A300BC14EF /* DebugLogger.m */,
@ -1699,7 +1698,6 @@
45360B8C1F9521F800FA666C /* Searcher.swift */, 45360B8C1F9521F800FA666C /* Searcher.swift */,
346129BD1FD2068600532771 /* ThreadUtil.h */, 346129BD1FD2068600532771 /* ThreadUtil.h */,
346129BE1FD2068600532771 /* ThreadUtil.m */, 346129BE1FD2068600532771 /* ThreadUtil.m */,
241C6310231F5C4400B4198E /* UIColor+Helper.swift */,
340872BE22393CF900CB25B0 /* UIGestureRecognizer+OWS.swift */, 340872BE22393CF900CB25B0 /* UIGestureRecognizer+OWS.swift */,
4C858A51212DC5E1001B45D3 /* UIImage+OWS.swift */, 4C858A51212DC5E1001B45D3 /* UIImage+OWS.swift */,
B97940251832BD2400BD66CB /* UIUtil.h */, B97940251832BD2400BD66CB /* UIUtil.h */,
@ -2651,6 +2649,8 @@
children = ( children = (
241C630E231F5AAC00B4198E /* JazzIcon.swift */, 241C630E231F5AAC00B4198E /* JazzIcon.swift */,
B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */, B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */,
241C6312231F5F1D00B4198E /* CGFloat+Rounding.swift */,
241C6310231F5C4400B4198E /* UIColor+Helper.swift */,
); );
path = Loki; path = Loki;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@ -50,7 +50,6 @@ public final class LokiGroupChatPoller : NSObject {
let endIndex = senderHexEncodedPublicKey.endIndex let endIndex = senderHexEncodedPublicKey.endIndex
let cutoffIndex = senderHexEncodedPublicKey.index(endIndex, offsetBy: -8) let cutoffIndex = senderHexEncodedPublicKey.index(endIndex, offsetBy: -8)
let senderDisplayName = "\(message.displayName) (...\(senderHexEncodedPublicKey[cutoffIndex..<endIndex]))" let senderDisplayName = "\(message.displayName) (...\(senderHexEncodedPublicKey[cutoffIndex..<endIndex]))"
let id = group.id.data(using: String.Encoding.utf8)! let id = group.id.data(using: String.Encoding.utf8)!
let x1 = SSKProtoGroupContext.builder(id: id, type: .deliver) let x1 = SSKProtoGroupContext.builder(id: id, type: .deliver)
x1.setName(group.displayName) x1.setName(group.displayName)
@ -69,10 +68,9 @@ public final class LokiGroupChatPoller : NSObject {
x4.setSource(senderHexEncodedPublicKey) x4.setSource(senderHexEncodedPublicKey)
x4.setSourceDevice(OWSDevicePrimaryDeviceId) x4.setSourceDevice(OWSDevicePrimaryDeviceId)
x4.setContent(try! x3.build().serializedData()) x4.setContent(try! x3.build().serializedData())
let storage = OWSPrimaryStorage.shared() let storage = OWSPrimaryStorage.shared()
storage.dbReadWriteConnection.readWrite { transaction in storage.dbReadWriteConnection.readWrite { transaction in
// Set the display name of the user
transaction.setObject(senderDisplayName, forKey: senderHexEncodedPublicKey, inCollection: group.id) transaction.setObject(senderDisplayName, forKey: senderHexEncodedPublicKey, inCollection: group.id)
SSKEnvironment.shared.messageManager.throws_processEnvelope(try! x4.build(), plaintextData: try! x3.build().serializedData(), wasReceivedByUD: false, transaction: transaction) SSKEnvironment.shared.messageManager.throws_processEnvelope(try! x4.build(), plaintextData: try! x3.build().serializedData(), wasReceivedByUD: false, transaction: transaction)
} }

View File

@ -1509,13 +1509,10 @@ static const int kYapDatabaseRangeMaxLength = 25000;
= (![NSObject isNullableObject:previousIncomingSenderId equalTo:incomingSenderId] = (![NSObject isNullableObject:previousIncomingSenderId equalTo:incomingSenderId]
|| viewItem.hasCellHeader); || viewItem.hasCellHeader);
} }
if (shouldShowSenderName) { if (shouldShowSenderName) {
senderName = [self.contactsManager senderName = [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:incomingSenderId primaryAttributes:[OWSMessageBubbleView senderNamePrimaryAttributes]
attributedContactOrProfileNameForPhoneIdentifier:incomingSenderId secondaryAttributes:[OWSMessageBubbleView senderNameSecondaryAttributes]];
primaryAttributes:[OWSMessageBubbleView
senderNamePrimaryAttributes]
secondaryAttributes:[OWSMessageBubbleView
senderNameSecondaryAttributes]];
if ([self.thread isKindOfClass:[TSGroupThread class]]) { if ([self.thread isKindOfClass:[TSGroupThread class]]) {
TSGroupThread *groupThread = (TSGroupThread *)self.thread; TSGroupThread *groupThread = (TSGroupThread *)self.thread;

View File

@ -1,5 +1,7 @@
extension CGFloat { extension CGFloat {
/// Rounds the float to decimal places value
/// Round the number to the given amount of decimal places.
func rounded(toPlaces places:Int) -> CGFloat { func rounded(toPlaces places:Int) -> CGFloat {
let divisor = pow(10.0, CGFloat(places)) let divisor = pow(10.0, CGFloat(places))
return (self * divisor).rounded() / divisor return (self * divisor).rounded() / divisor

View File

@ -1,3 +1,4 @@
@objc(LKIdenticon) @objc(LKIdenticon)
final class Identicon : NSObject { final class Identicon : NSObject {
@ -6,11 +7,7 @@ final class Identicon : NSObject {
let iconLayer = icon.generateLayer(ofSize: size) let iconLayer = icon.generateLayer(ofSize: size)
let rect = CGRect(origin: CGPoint.zero, size: iconLayer.frame.size) let rect = CGRect(origin: CGPoint.zero, size: iconLayer.frame.size)
let renderer = UIGraphicsImageRenderer(size: rect.size) let renderer = UIGraphicsImageRenderer(size: rect.size)
let image = renderer.image { let image = renderer.image { iconLayer.render(in: $0.cgContext) }
context in
return iconLayer.render(in: context.cgContext)
}
return image return image
} }
} }

View File

@ -1,4 +1,6 @@
extension UIColor { extension UIColor {
public func adjust(hueBy degrees: CGFloat) -> UIColor { public func adjust(hueBy degrees: CGFloat) -> UIColor {
var currentHue: CGFloat = 0.0 var currentHue: CGFloat = 0.0

View File

@ -1,3 +1,4 @@
@objc public extension SSKProtoEnvelope { @objc public extension SSKProtoEnvelope {
@objc public var isGroupChatMessage: Bool { @objc public var isGroupChatMessage: Bool {
@ -7,7 +8,5 @@
} catch { } catch {
return false return false
} }
return true;
} }
} }

View File

@ -1387,7 +1387,7 @@ NS_ASSUME_NONNULL_BEGIN
[incomingMessage.attachmentIds addObject:pointer.uniqueId]; [incomingMessage.attachmentIds addObject:pointer.uniqueId];
} }
// Loki: Don't process friend requests in the group chats // Loki: Don't process friend requests in group chats
if (body.length == 0 && attachmentPointers.count < 1 && !contact) { if (body.length == 0 && attachmentPointers.count < 1 && !contact) {
OWSLogWarn(@"ignoring empty incoming message from: %@ for group: %@ with timestamp: %lu", OWSLogWarn(@"ignoring empty incoming message from: %@ for group: %@ with timestamp: %lu",