Browse Source

Merge branch 'dev' into voice-calls-2

pull/605/head
Ryan Zhao 11 months ago
parent
commit
a31fb7f957
  1. 2
      Session/Notifications/AppNotifications.swift
  2. 2
      SessionMessagingKit/Database/TSDatabaseView.m
  3. 9
      SessionMessagingKit/Messages/Control Messages/ConfigurationMessage+Convenience.swift
  4. 2
      SessionMessagingKit/Threads/TSThread.h
  5. 9
      SessionMessagingKit/Threads/TSThread.m
  6. 2
      SessionNotificationServiceExtension/NSENotificationPresenter.swift
  7. 12
      SignalUtilitiesKit/Profile Pictures/Identicon+ObjC.swift
  8. 1
      SignalUtilitiesKit/Profile Pictures/PlaceholderIcon.swift

2
Session/Notifications/AppNotifications.swift

@ -176,7 +176,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
}
else if isMessageRequest && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
// If there are other interactions on this thread already then don't show the notification
if thread.numberOfInteractions() > 1 { return }
if thread.numberOfInteractions(with: transaction) > 1 { return }
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false
}

2
SessionMessagingKit/Database/TSDatabaseView.m

@ -287,7 +287,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
}
TSThread *thread = (TSThread *)object;
if (thread.isMessageRequest) {
if ([thread isMessageRequestUsingTransaction:transaction]) {
return nil;
}
else {

9
SessionMessagingKit/Messages/Control Messages/ConfigurationMessage+Convenience.swift

@ -55,17 +55,16 @@ extension ConfigurationMessage {
return (
// Skip the current user
contact.sessionID != currentUserPublicKey && (
contact.sessionID != currentUserPublicKey &&
// Contacts which have visible threads
TSContactThread.fetch(uniqueId: threadID, transaction: transaction)?.shouldBeVisible == true && (
// Include already approved contacts
contact.isApproved ||
contact.didApproveMe ||
// Sync blocked contacts
SSKEnvironment.shared.blockingManager.isRecipientIdBlocked(contact.sessionID) ||
// Contacts which have visible threads (sanity check - should be included as already approved)
TSContactThread.fetch(uniqueId: threadID, transaction: transaction)?.shouldBeVisible == true
SSKEnvironment.shared.blockingManager.isRecipientIdBlocked(contact.sessionID)
)
)
}

2
SessionMessagingKit/Threads/TSThread.h

@ -74,6 +74,8 @@ BOOL IsNoteToSelfEnabled(void);
*/
- (NSUInteger)numberOfInteractions;
- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(unreadMessageCount(transaction:));

9
SessionMessagingKit/Threads/TSThread.m

@ -245,12 +245,17 @@ BOOL IsNoteToSelfEnabled(void)
{
__block NSUInteger count;
[[self dbReadConnection] readWithBlock:^(YapDatabaseReadTransaction *transaction) {
YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName];
count = [interactionsByThread numberOfItemsInGroup:self.uniqueId];
count = [self numberOfInteractionsWithTransaction:transaction];
}];
return count;
}
- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction
{
YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName];
return [interactionsByThread numberOfItemsInGroup:self.uniqueId];
}
- (NSArray<id<OWSReadTracking>> *)unseenMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
{
NSMutableArray<id<OWSReadTracking>> *messages = [NSMutableArray new];

2
SessionNotificationServiceExtension/NSENotificationPresenter.swift

@ -22,7 +22,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
}
else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
// If there are other interactions on this thread already then don't show the notification
if thread.numberOfInteractions() > 1 { return }
if thread.numberOfInteractions(with: transaction) > 1 { return }
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false
}

12
SignalUtilitiesKit/Profile Pictures/Identicon+ObjC.swift

@ -8,7 +8,17 @@ public final class Identicon : NSObject {
if content.count > 2 && content.hasPrefix("05") {
content.removeFirst(2)
}
let layer = icon.generateLayer(with: size, text: content.substring(to: 1))
let initials: String = content
.split(separator: " ")
.compactMap { word in word.first.map { String($0) } }
.joined()
let layer = icon.generateLayer(
with: size,
text: (initials.count >= 2 ?
initials.substring(to: 2).uppercased() :
content.substring(to: 2).uppercased()
)
)
let rect = CGRect(origin: CGPoint.zero, size: layer.frame.size)
let renderer = UIGraphicsImageRenderer(size: rect.size)
return renderer.image { layer.render(in: $0.cgContext) }

1
SignalUtilitiesKit/Profile Pictures/PlaceholderIcon.swift

@ -37,7 +37,6 @@ public class PlaceholderIcon {
}
private func getTextLayer(with diameter: CGFloat, colour: CGColor? = nil, text: String) -> CALayer {
let text = text.capitalized
let font = UIFont.boldSystemFont(ofSize: diameter / 2)
let height = NSString(string: text).boundingRect(with: CGSize(width: diameter, height: CGFloat.greatestFiniteMagnitude),
options: .usesLineFragmentOrigin, attributes: [ NSAttributedString.Key.font : font ], context: nil).height

Loading…
Cancel
Save