Skip to content

Commit

Permalink
Hidden system chats.
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBonus committed Jun 28, 2018
1 parent de6a233 commit 011737a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17E202" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17F77" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="BaseTransaction" representedClassName="BaseTransaction" isAbstract="YES" syncable="YES">
<attribute name="amount" optional="YES" attributeType="Decimal" defaultValueString="0" syncable="YES"/>
<attribute name="blockId" attributeType="String" syncable="YES"/>
Expand All @@ -15,6 +15,7 @@
</entity>
<entity name="Chatroom" representedClassName="Chatroom" syncable="YES">
<attribute name="hasUnreadMessages" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isHidden" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isReadonly" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
Expand Down Expand Up @@ -48,7 +49,7 @@
</entity>
<elements>
<element name="BaseTransaction" positionX="378" positionY="18" width="128" height="210"/>
<element name="Chatroom" positionX="-74" positionY="26" width="128" height="150"/>
<element name="Chatroom" positionX="-74" positionY="26" width="128" height="165"/>
<element name="ChatTransaction" positionX="142" positionY="137" width="128" height="120"/>
<element name="CoreDataAccount" positionX="-236" positionY="174" width="128" height="150"/>
<element name="MessageTransaction" positionX="243" positionY="326" width="128" height="90"/>
Expand Down
5 changes: 3 additions & 2 deletions Adamant/CoreData/Chatroom+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Chatroom+CoreDataProperties.swift
// Adamant
//
// Created by Anokhov Pavel on 02.06.2018.
// Created by Anokhov Pavel on 28.06.2018.
// Copyright © 2018 Adamant. All rights reserved.
//
//
Expand All @@ -18,9 +18,10 @@ extension Chatroom {
}

@NSManaged public var hasUnreadMessages: Bool
@NSManaged public var isReadonly: Bool
@NSManaged public var title: String?
@NSManaged public var updatedAt: NSDate?
@NSManaged public var isReadonly: Bool
@NSManaged public var isHidden: Bool
@NSManaged public var lastTransaction: ChatTransaction?
@NSManaged public var partner: CoreDataAccount?
@NSManaged public var transactions: NSSet?
Expand Down
7 changes: 7 additions & 0 deletions Adamant/ServiceProtocols/DataProviders/AccountsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ enum AdamantContacts {
return true
}

var isHidden: Bool {
switch self {
case .adamantBountyWallet: return true
case .adamantIco: return false
}
}

var avatar: String {
return "avatar_bots"
}
Expand Down
3 changes: 3 additions & 0 deletions Adamant/Services/DataProviders/AdamantAccountsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class AdamantAccountsProvider: AccountsProvider {
let name: String
let avatar: String?
let isReadonly: Bool
let isHidden: Bool

fileprivate init(contact: AdamantContacts) {
self.address = contact.address
self.name = contact.name
self.avatar = contact.avatar
self.isReadonly = contact.isReadonly
self.isHidden = contact.isHidden
}
}

Expand Down Expand Up @@ -289,6 +291,7 @@ extension AdamantAccountsProvider {
coreAccount.avatar = acc.avatar
coreAccount.isSystem = true
chatroom.isReadonly = acc.isReadonly
chatroom.isHidden = acc.isHidden
chatroom.title = acc.name
}

Expand Down
2 changes: 1 addition & 1 deletion Adamant/Services/DataProviders/AdamantChatsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ extension AdamantChatsProvider {
let request: NSFetchRequest<Chatroom> = NSFetchRequest(entityName: Chatroom.entityName)
request.sortDescriptors = [NSSortDescriptor(key: "updatedAt", ascending: false),
NSSortDescriptor(key: "title", ascending: true)]
request.predicate = NSPredicate(format: "partner!=nil")
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 Down

0 comments on commit 011737a

Please sign in to comment.