Comments (11)
@mschonvogel Good to know. Thank you.
I have just released the 1.1.1 version. It contains performance improvements and also a fix for your issue. I neede to change the processing order. I covered your case with a unit test and it seems to be fine. Please check it out.
Please do not hesitate to contact me on twitter @ekazaev
from chatlayout.
@mschonvogel Hi
Thank you very much. Appreciate.
I never checked it with RxDataSources. But it should not be something big. Most likely I am missing something in my math. Can you please provide an example where I can play around with it?
Also, so I can start quicker, can you add print to the ChatLayout.prepare(forCollectionViewUpdates:) and print updateItems for me.
print("\(updateItems)")
I need a log what RXDataSource sends there before you hit an assertion. It seems to be pretty straight forward. For some reason there is less items than the index that is in the item array.
Thank you.
from chatlayout.
@mschonvogel At the first look it seems that RXDataSources flattens somehow the update commands.
from chatlayout.
@mschonvogel
Can you also try to replace an else
block at line 514 in StateController with the next code:
} else {
guard var item = self.item(for: indexPath.itemPath, kind: .cell, at: .beforeUpdate) else {
assertionFailure("Internal inconsistency")
return
}
item.resetSize()
var newIndexPath: IndexPath!
for (sectionIndex, section) in afterUpdateModel.sections.enumerated() {
if let itemIndex = section.items.firstIndex(where: { $0.id == item.id }) {
newIndexPath = ItemPath(item: itemIndex, section: sectionIndex).indexPath
}
}
afterUpdateModel.replaceItem(item, at: newIndexPath)
reloadedIndexes.insert(newIndexPath)
}
If ypu wont get a crash It will give me some ideas about what is going on. But of corse an example with the crash is ideal.
from chatlayout.
@ekazaev thank you for the quick reply
I've added RxDataSources to the example but I'm not able to replicate the bug in there: https://github.com/mschonvogel/ChatLayout/tree/rxdatasources
print("(updateItems)"):
[D(0,0), D(0,1), R(0,30)]
Fatal error: Internal inconsistency: file ChatLayout/SectionModel.swift, line 155
from chatlayout.
Thank you @mschonvogel
Ill have a look soon. I think I know what is going on. So expect that it will be fixed soon.
from chatlayout.
Thank you @ekazaev. Btw replacing the block at line 514 helped, it's not hitting the assertionFailure anymore.
However, prepare(forCollectionViewUpdates:)
seems to get called twice now which leads to an ugly insert animation:
print("(updateItems)"):
[D(0,0), D(0,1), R(0,25)]
[I(0,0), I(0,25)]
from chatlayout.
@mschonvogel That is absolutely normal that the prepare(forCollectionViewUpdates:)
is being called twice or more times. It meana that the performBatchUpdates
is also being called twice. But why it happens - its already up to you and how you detect the changes in your model. I would recommend you to check your model. and the comparison there. The chain of the commands has no sense. It deletes the cell and [0, 0] and then inserts it [0, 0]. Are you sure it is what suppose to happen? Why its not just calling reload [0, 0].
I cant say exactly how RXDataSources works. But in terms of DifferenceKit the identifier of said cell should stay the same but the content should be flagged as different. To control that is on your side. But Ill include the fix for your reload situation in the upcoming update after the proper testing. Ugly animation usually mean the model problem.
I can offer you to have a call so we can have a look at your particular situation together.
from chatlayout.
@ekazaev Okay, I found the problem. 🤦♂️ I am using a Firebase Firestore query listener with a limit of 25. Whenever I insert a new message, an older one gets deleted. that's why the deletes were at the beginning of the collection.
Now everything looks fine when I insert a new message...:
[R(0,34)]
[I(0,35)]
I'll test this some more, but everything should work as expected now. I'm happy to jump on a call, to test the changes you made to the lib if it helps
from chatlayout.
Thank you, it works as expected now!
from chatlayout.
@mschonvogel Fantastic! Happy to hear!
from chatlayout.
Related Issues (20)
- Cannot installed with Carthage HOT 6
- General Question UITableView vs UICollectionView HOT 5
- Cells disappearing during layout animation HOT 5
- How to implement UICollectionView inside UICollectionViewCell right way? HOT 3
- How to implement UICollectionView inside UICollectionViewCell right way? HOT 4
- ChatLayout paging HOT 12
- How to design the structure of clicking the message to jump to the next page? HOT 2
- The message list will shake. HOT 4
- Performance when push to ChatViewController not good HOT 12
- Bottom offset keeping issues HOT 8
- What is the function of this code? HOT 11
- Incorrect chat layout frame when running on iOS 17 HOT 7
- Audio message HOT 5
- Image View Play Button Constraints HOT 2
- chat layout blinking HOT 3
- Text message bubble calc in ex app
- Can you write an example where inputBarView is a subview? HOT 2
- transitioning into the chat interface from the conversationList page is slow HOT 10
- Forgot to use self. in closure HOT 3
- PDF cells HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatlayout.