Skip to content

Commit d0b66dd

Browse files
committed
Filtering out hidden chatrooms.
1 parent 011737a commit d0b66dd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Adamant/Services/DataProviders/AdamantChatsProvider.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,9 @@ extension AdamantChatsProvider {
553553
let request: NSFetchRequest<Chatroom> = NSFetchRequest(entityName: Chatroom.entityName)
554554
request.sortDescriptors = [NSSortDescriptor(key: "updatedAt", ascending: false),
555555
NSSortDescriptor(key: "title", ascending: true)]
556-
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [NSPredicate(format: "partner!=nil"), NSPredicate(format: "isHidden = false")])
556+
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [
557+
NSPredicate(format: "partner!=nil"),
558+
NSPredicate(format: "isHidden = false")])
557559
let controller = NSFetchedResultsController(fetchRequest: request, managedObjectContext: stack.container.viewContext, sectionNameKeyPath: nil, cacheName: nil)
558560

559561
return controller
@@ -575,7 +577,10 @@ extension AdamantChatsProvider {
575577

576578
func getUnreadMessagesController() -> NSFetchedResultsController<ChatTransaction> {
577579
let request = NSFetchRequest<ChatTransaction>(entityName: "ChatTransaction")
578-
request.predicate = NSPredicate(format: "isUnread == true")
580+
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [
581+
NSPredicate(format: "isUnread == true"),
582+
NSPredicate(format: "chatroom.isHidden == false")])
583+
579584
request.sortDescriptors = [NSSortDescriptor.init(key: "date", ascending: false),
580585
NSSortDescriptor(key: "transactionId", ascending: false)]
581586

Adamant/Stories/Chats/ChatListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ extension ChatListViewController {
417417
private func showNotification(for transaction: ChatTransaction) {
418418
// MARK: 1. Show notification only for incomming transactions
419419
guard !transaction.silentNotification, !transaction.isOutgoing,
420-
let chatroom = transaction.chatroom, chatroom != presentedChatroom(),
420+
let chatroom = transaction.chatroom, chatroom != presentedChatroom(), !chatroom.isHidden,
421421
let partner = chatroom.partner else {
422422
return
423423
}

0 commit comments

Comments
 (0)