Skip to content

Commit

Permalink
Move HashableItem declaration to the root of the file
Browse files Browse the repository at this point in the history
  • Loading branch information
wiruzx committed Feb 8, 2019
1 parent ca0ea24 commit 02a1d07
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Chatto/Source/ChatController/BaseChatViewController+Changes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

import Foundation

private struct HashableItem: Hashable {
private let uid: String
private let type: String
init(chatItem: ChatItemProtocol) {
self.uid = chatItem.uid
self.type = chatItem.type
}
}

extension BaseChatViewController {

public func enqueueModelUpdate(updateType: UpdateType, completion: (() -> Void)? = nil) {
Expand Down Expand Up @@ -273,16 +282,6 @@ extension BaseChatViewController {

private func createModelUpdates(newItems: [ChatItemProtocol], oldItems: ChatItemCompanionCollection, collectionViewWidth: CGFloat) -> (changes: CollectionChanges, updateModelClosure: () -> Void) {
let newDecoratedItems = self.chatItemsDecorator?.decorateItems(newItems) ?? newItems.map { DecoratedChatItem(chatItem: $0, decorationAttributes: nil) }

struct HashableItem: Hashable {
private let uid: String
private let type: String
init(chatItem: ChatItemProtocol) {
self.uid = chatItem.uid
self.type = chatItem.type
}
}

let changes = Chatto.generateChanges(oldCollection: oldItems.map { HashableItem(chatItem: $0.chatItem) },
newCollection: newDecoratedItems.map { HashableItem(chatItem: $0.chatItem) })
let itemCompanionCollection = self.createCompanionCollection(fromChatItems: newDecoratedItems, previousCompanionCollection: oldItems)
Expand Down

0 comments on commit 02a1d07

Please sign in to comment.