Merge branch 'dev' into voice-calls-2
This commit is contained in:
commit
a31fb7f957
|
@ -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
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
|
|||
}
|
||||
TSThread *thread = (TSThread *)object;
|
||||
|
||||
if (thread.isMessageRequest) {
|
||||
if ([thread isMessageRequestUsingTransaction:transaction]) {
|
||||
return nil;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ BOOL IsNoteToSelfEnabled(void);
|
|||
*/
|
||||
- (NSUInteger)numberOfInteractions;
|
||||
|
||||
- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
NS_SWIFT_NAME(unreadMessageCount(transaction:));
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) }
|
||||
|
|
|
@ -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…
Reference in New Issue