-
Notifications
You must be signed in to change notification settings - Fork 212
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
[CIS-982] Crash when thread root message is not loaded #1263
Conversation
let indexPath = IndexPath(row: messageController.replies.count, section: 0) | ||
|
||
let listChange: ListChange<_ChatMessage<ExtraData>> | ||
switch change { | ||
case .create(let item): | ||
listChange = .insert(item, index: indexPath) | ||
case .update(let item): | ||
listChange = .update(item, index: indexPath) | ||
case .remove(let item): | ||
listChange = .remove(item, index: indexPath) | ||
} | ||
|
||
updateMessages(with: [listChange]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were supposed to call reloadData
but didChangeMessage
is triggered when thread root message is updated which can happen multiple times. Reloading single cell sounds better (the index calculations are straightforward since thread root is always at the end of message list)
let replies = Array(messageController.replies) | ||
|
||
if let threadRootMessage = messageController.message { | ||
return replies + [threadRootMessage] | ||
} else { | ||
return replies | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thread replies are evaluated from DTOs when converting messageController.replies
to an array. The solution I was thinking of is appending thread root message to replies: LazyCachedMapCollection
but seems it's not feasible 🤔
To not break the indexes of lazy map we would have to modify the source collection of message DTOs and a cache. It's quite straightforward with cache but the information about source collection Element
type is available only in init
and doesn't get stored for later use.
Don't see how we can handle this nicely on UI side (on LLC side we could tweak a replies observer to also include a thread root though)
fa5c12e
to
6926a83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Your comments on this PR are valuable and I think they actually should be included in the source code, rather than here ;-)
Codecov Report
@@ Coverage Diff @@
## main #1263 +/- ##
==========================================
- Coverage 91.40% 91.38% -0.02%
==========================================
Files 219 219
Lines 9419 9421 +2
==========================================
Hits 8609 8609
- Misses 810 812 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
6926a83
to
7f31131
Compare
This PR fixes crash on
ChatThreadVC
when root message is not loaded