From bdb01e4a4041ce5ee1bec241c4ec2ba267306808 Mon Sep 17 00:00:00 2001 From: Diego Sanchez Date: Tue, 9 Feb 2016 16:13:43 +0000 Subject: [PATCH] Allows data source to trigger updates with concrete context. Basically this allows to trigger some updates with a non-animated reloadData while others will be animated (performBatchUpdates) --- .../ChatController/BaseChatViewController+Changes.swift | 8 ++------ .../Source/ChatController/ChatDataSourceProtocol.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Chatto/Source/ChatController/BaseChatViewController+Changes.swift b/Chatto/Source/ChatController/BaseChatViewController+Changes.swift index a55da6f..2650661 100644 --- a/Chatto/Source/ChatController/BaseChatViewController+Changes.swift +++ b/Chatto/Source/ChatController/BaseChatViewController+Changes.swift @@ -26,12 +26,8 @@ import Foundation extension BaseChatViewController: ChatDataSourceDelegateProtocol { - public enum UpdateContext { - case Normal - case FirstLoad - case Pagination - case Reload - case MessageCountReduction + public func chatDataSourceDidUpdate(chatDataSource: ChatDataSourceProtocol, context: UpdateContext) { + self.enqueueModelUpdate(context: context) } public func chatDataSourceDidUpdate(chatDataSource: ChatDataSourceProtocol) { diff --git a/Chatto/Source/ChatController/ChatDataSourceProtocol.swift b/Chatto/Source/ChatController/ChatDataSourceProtocol.swift index a833287..36143d0 100644 --- a/Chatto/Source/ChatController/ChatDataSourceProtocol.swift +++ b/Chatto/Source/ChatController/ChatDataSourceProtocol.swift @@ -24,8 +24,17 @@ import Foundation +public enum UpdateContext { + case Normal + case FirstLoad + case Pagination + case Reload + case MessageCountReduction +} + public protocol ChatDataSourceDelegateProtocol: class { func chatDataSourceDidUpdate(chatDataSource: ChatDataSourceProtocol) + func chatDataSourceDidUpdate(chatDataSource: ChatDataSourceProtocol, context: UpdateContext) } public protocol ChatDataSourceProtocol: class {