New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add updating logic to text message #178
Conversation
Current coverage is 63.55% (diff: 42.85%)@@ dev #178 diff @@
==========================================
Files 62 62
Lines 3430 3452 +22
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 2191 2194 +3
- Misses 1239 1258 +19
Partials 0 0
|
Hi @maxkonovalov, Yes, I think we should move the avatar thing to the BaseMessagePresenter and clean the text and photo ones a little bit. We would appreciate if you do this here (not required). I was tracking down your need for the dispatch_async. Check the root cause here: https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160711/002580.html. If you don't mind, could you make Observable a class and remove the dispatch_async? Thank you! |
Hey @diegosanchezr, sorry for the delay, sure, I'll try add these changes as soon as possible. |
Hi @maxkonovalov, are you still able to work on this? We'd definitely like to merge this. Thank you! |
Hey @diegosanchezr, sorry again - very busy with my other projects, but will get back to this issue in a few days! |
Cool, thank you! |
Hey @diegosanchezr! As requested, I updated the For refactoring, I only moved the declarations of the methods Also changed the avatar show/hide logic, because the previous implementation triggered |
@maxkonovalov Thank you! |
Added support for
willBeShown()
andwasHidden()
functions inTextMessageViewModel
. The main purpose of this is to give chance to the client to load the avatar images when needed. Most of the code was copied from the corresponding functions inPhotoMessagePresenter
.Both Text and Photo message models now look pretty similar, so maybe you guys consider moving some parts to the base classes?
Also added the missing
observe
calls for the avatar image in view models.And the essential part of this commit is the call to the main queue in
updateClosure
:It looks strange, but if you try to set the observable value in
willBeShown()
, although the model itself has been updated, inBaseMessageCollectionViewCell.updateViews()
it still gets the old value, so the update has no visible effect. Deferring the update with an async call to the main queue seems to fix the issue here.