diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift index 49d789c05a05e390d1b685718abc2c5b5afeba3f..3b057610713fa72e4d8d6f4d9ce6eadf8d5f3221 100644 --- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift +++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift @@ -39,5 +39,9 @@ class MessageCell: UITableViewCell, NibReusable { @IBOutlet weak var profileImage: UIImageView! @IBOutlet weak var fallbackAvatar: UILabel! - let disposeBag = DisposeBag() + var disposeBag = DisposeBag() + + override func prepareForReuse() { + self.disposeBag = DisposeBag() + } } diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift index fe7fc2fb408403e36e562e71ad3dd3b1ff796bc8..b5caefaa19e1269c81f92bdabf8beaa7f21221fb 100644 --- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift +++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift @@ -93,7 +93,6 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo return defaultAvatarColor } - self.tableView.contentInset.bottom = messageAccessoryView.frame.size.height self.tableView.scrollIndicatorInsets.bottom = messageAccessoryView.frame.size.height @@ -402,17 +401,20 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo cell.bubbleBottomConstraint.constant = 16 } - if messageVM.bubblePosition() == .sent { + if messageVM.bubblePosition() == .generated { + cell.failedStatusLabel.isHidden = true + cell.sendingIndicator.stopAnimating() + } else if messageVM.bubblePosition() == .sent { messageVM.status.asObservable() .observeOn(MainScheduler.instance) .map { value in value == MessageStatus.sending ? true : false } .bind(to: cell.sendingIndicator.rx.isAnimating) - .disposed(by: disposeBag) + .disposed(by: cell.disposeBag) messageVM.status.asObservable() .observeOn(MainScheduler.instance) .map { value in value == MessageStatus.failure ? false : true } .bind(to: cell.failedStatusLabel.rx.isHidden) - .disposed(by: disposeBag) + .disposed(by: cell.disposeBag) } else { // avatar guard let fallbackAvatar = cell.fallbackAvatar else { @@ -429,14 +431,14 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo .observeOn(MainScheduler.instance) .map { value in value.prefixString().capitalized } .bind(to: fallbackAvatar.rx.text) - .disposed(by: disposeBag) + .disposed(by: cell.disposeBag) // Set placeholder avatar to backgroundColorObservable self.backgroundColorObservable .subscribe(onNext: { backgroundColor in fallbackAvatar.backgroundColor = backgroundColor }) - .disposed(by: disposeBag) + .disposed(by: cell.disposeBag) // Set image if any cell.profileImage?.image = nil diff --git a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift index 69fc315c0d6e11396cf004f05aef5868ab3a6d16..77434e58b533dd72480e8b5abc713c93865f6bd4 100644 --- a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift +++ b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift @@ -52,4 +52,10 @@ class ConversationCell: UITableViewCell, NibReusable { self.presenceIndicator.backgroundColor = presenceBGColor self.fallbackAvatar.backgroundColor = fallbackAvatarBGColor } + + var disposeBag = DisposeBag() + + override func prepareForReuse() { + self.disposeBag = DisposeBag() + } } diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift index da9719ea62b48f6e86676acc3cf8cf0109c66a32..52cf2121e9e5053aa78e2592f16a84485cfc28b8 100644 --- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift +++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift @@ -125,14 +125,14 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased item.userName.asObservable() .observeOn(MainScheduler.instance) .bind(to: cell.nameLabel.rx.text) - .disposed(by: self.disposeBag) + .disposed(by: cell.disposeBag) // Avatar placeholder initial item.userName.asObservable() .observeOn(MainScheduler.instance) .map { value in value.prefixString().capitalized } .bind(to: cell.fallbackAvatar.rx.text) - .disposed(by: self.disposeBag) + .disposed(by: cell.disposeBag) // UIColor that observes "best Id" prefix self.backgroundColorObservable = item.userName.asObservable() @@ -151,7 +151,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased .subscribe(onNext: { backgroundColor in cell.fallbackAvatar.backgroundColor = backgroundColor }) - .disposed(by: self.disposeBag) + .disposed(by: cell.disposeBag) // Set image if any cell.fallbackAvatar.isHidden = false @@ -172,7 +172,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased .observeOn(MainScheduler.instance) .map { value in !value } .bind(to: cell.presenceIndicator.rx.isHidden) - .disposed(by: self.disposeBag) + .disposed(by: cell.disposeBag) return cell } diff --git a/Ring/Ring/Features/Me/Me/LinkNewDeviceCell.swift b/Ring/Ring/Features/Me/Me/LinkNewDeviceCell.swift index 6ecb75f4b61c7f7e0f49a7be8a43cd00921ad247..745fe0a012a44db12673df6c404cf2c69c21fa17 100644 --- a/Ring/Ring/Features/Me/Me/LinkNewDeviceCell.swift +++ b/Ring/Ring/Features/Me/Me/LinkNewDeviceCell.swift @@ -25,5 +25,9 @@ import RxSwift class LinkNewDeviceCell: UITableViewCell, NibReusable { @IBOutlet weak var addDeviceButton: UIButton! - let disposeBag = DisposeBag() + var disposeBag = DisposeBag() + + override func prepareForReuse() { + self.disposeBag = DisposeBag() + } }