mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-30 17:36:22 +00:00
Reload CollectionView (messages) when a single item has been downloaded
This commit is contained in:
parent
d1ae0af1f3
commit
d739052d1a
3 changed files with 30 additions and 7 deletions
|
|
@ -18,7 +18,7 @@ class ChatConversationTableViewModel: ControlsViewModel {
|
||||||
|
|
||||||
var chatRoom: ChatRoom? = nil
|
var chatRoom: ChatRoom? = nil
|
||||||
|
|
||||||
var nbEventDisplayed = MutableLiveData<Int>(20)
|
var refreshIndexPath = MutableLiveData<Int>(0)
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
@ -68,4 +68,8 @@ class ChatConversationTableViewModel: ControlsViewModel {
|
||||||
func eventTypeIsOfInterestForOne(toOneRoom type: EventLogType) -> Bool {
|
func eventTypeIsOfInterestForOne(toOneRoom type: EventLogType) -> Bool {
|
||||||
return type.rawValue == LinphoneEventLogTypeConferenceChatMessage.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageEnabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageDisabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageLifetimeChanged.rawValue
|
return type.rawValue == LinphoneEventLogTypeConferenceChatMessage.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageEnabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageDisabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageLifetimeChanged.rawValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reloadCollectionViewCell(){
|
||||||
|
refreshIndexPath.value! += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(self.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(self.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
||||||
|
|
||||||
ChatConversationTableViewModel.sharedModel.nbEventDisplayed.observe { index in
|
ChatConversationTableViewModel.sharedModel.refreshIndexPath.observe { index in
|
||||||
self.collectionView.reloadData()
|
self.collectionView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
collectionView.isUserInteractionEnabled = true
|
collectionView.isUserInteractionEnabled = true
|
||||||
|
|
@ -155,7 +155,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
||||||
}
|
}
|
||||||
|
|
||||||
if let event = ChatConversationTableViewModel.sharedModel.getMessage(index: indexPath.row){
|
if let event = ChatConversationTableViewModel.sharedModel.getMessage(index: indexPath.row){
|
||||||
cell.configure(event: event)
|
cell.configure(event: event, selfIndexPathConfigure: indexPath)
|
||||||
|
|
||||||
if (event.chatMessage != nil){
|
if (event.chatMessage != nil){
|
||||||
cell.onLongClickOneClick {
|
cell.onLongClickOneClick {
|
||||||
|
|
@ -377,4 +377,8 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
||||||
message.chatRoom?.deleteMessage(message: message)
|
message.chatRoom?.deleteMessage(message: message)
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func reloadCollectionViewCell(indexPath: IndexPath){
|
||||||
|
collectionView.reloadItems(at: [indexPath])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func configure(event: EventLog) {
|
func configure(event: EventLog, selfIndexPathConfigure: IndexPath) {
|
||||||
chatMessage = event.chatMessage
|
chatMessage = event.chatMessage
|
||||||
addMessageDelegate()
|
addMessageDelegate()
|
||||||
if event.chatMessage != nil {
|
if event.chatMessage != nil {
|
||||||
|
|
@ -1222,6 +1222,21 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
||||||
imagesGridURLCollection[indexTransferProgress] = (URL(string: content.filePath)!)
|
imagesGridURLCollection[indexTransferProgress] = (URL(string: content.filePath)!)
|
||||||
imagesGridCollectionView[indexTransferProgress] = getImageFrom(content.getCobject, filePath: content.filePath, forReplyBubble: true)!
|
imagesGridCollectionView[indexTransferProgress] = getImageFrom(content.getCobject, filePath: content.filePath, forReplyBubble: true)!
|
||||||
|
|
||||||
|
|
||||||
|
if (imagesGridCollectionView.count <= 1){
|
||||||
|
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
|
||||||
|
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||||
|
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||||
|
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||||
|
}
|
||||||
|
} else if let imageMessage = UIImage(named: content.filePath){
|
||||||
|
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||||
|
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||||
|
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||||
indexTransferProgress = -1
|
indexTransferProgress = -1
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue