Skip to content

Commit

Permalink
Filtering out hidden chatrooms.
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBonus committed Jun 28, 2018
1 parent 011737a commit d0b66dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Adamant/Services/DataProviders/AdamantChatsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ extension AdamantChatsProvider {
let request: NSFetchRequest<Chatroom> = NSFetchRequest(entityName: Chatroom.entityName)
request.sortDescriptors = [NSSortDescriptor(key: "updatedAt", ascending: false),
NSSortDescriptor(key: "title", ascending: true)]
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [NSPredicate(format: "partner!=nil"), NSPredicate(format: "isHidden = false")])
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [
NSPredicate(format: "partner!=nil"),
NSPredicate(format: "isHidden = false")])
let controller = NSFetchedResultsController(fetchRequest: request, managedObjectContext: stack.container.viewContext, sectionNameKeyPath: nil, cacheName: nil)

return controller
Expand All @@ -575,7 +577,10 @@ extension AdamantChatsProvider {

func getUnreadMessagesController() -> NSFetchedResultsController<ChatTransaction> {
let request = NSFetchRequest<ChatTransaction>(entityName: "ChatTransaction")
request.predicate = NSPredicate(format: "isUnread == true")
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [
NSPredicate(format: "isUnread == true"),
NSPredicate(format: "chatroom.isHidden == false")])

request.sortDescriptors = [NSSortDescriptor.init(key: "date", ascending: false),
NSSortDescriptor(key: "transactionId", ascending: false)]

Expand Down
2 changes: 1 addition & 1 deletion Adamant/Stories/Chats/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ extension ChatListViewController {
private func showNotification(for transaction: ChatTransaction) {
// MARK: 1. Show notification only for incomming transactions
guard !transaction.silentNotification, !transaction.isOutgoing,
let chatroom = transaction.chatroom, chatroom != presentedChatroom(),
let chatroom = transaction.chatroom, chatroom != presentedChatroom(), !chatroom.isHidden,
let partner = chatroom.partner else {
return
}
Expand Down

0 comments on commit d0b66dd

Please sign in to comment.