Skip to content
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

feat(common): Implement LinkedChunk::clear #4317

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Nov 25, 2024

This patch implements LinkedChunk::clear. The code from impl Drop for LinkedChunk has been moved inside Ends::clear, and replaced by a simple self.links.clear(). In addition, LinkedChunk::clear indeed calls self.links.clear() but also resets all fields.

This patch adds the Clear variant to Update.

This patch updates AsVector to emit a VectorDiff::Clear on Update::Clear.

Finally, this patch adds the necessary tests.


@Hywan Hywan requested a review from a team as a code owner November 25, 2024 14:29
@Hywan Hywan requested review from bnjbvr and removed request for a team November 25, 2024 14:29
@Hywan Hywan force-pushed the feat-common-linked-chunk-reset branch from 3497c7e to 848451f Compare November 25, 2024 14:30
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.06%. Comparing base (079ec02) to head (84a8355).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...es/matrix-sdk-common/src/linked_chunk/as_vector.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4317      +/-   ##
==========================================
- Coverage   85.10%   85.06%   -0.04%     
==========================================
  Files         274      274              
  Lines       30203    30213      +10     
==========================================
- Hits        25703    25700       -3     
- Misses       4500     4513      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you also want to have RoomEvents::reset make use of this function in this PR, or in a different one? (it would require a new test that when subscribing to updates_as_vec of the underlying linked chunk, the subscription stream doesn't shut down when RoomEvents::reset() is called)

crates/matrix-sdk-common/src/linked_chunk/mod.rs Outdated Show resolved Hide resolved
@Hywan
Copy link
Member Author

Hywan commented Nov 25, 2024

It's purposely on another PR, not yet submitted to avoid PR stacking :-).

@Hywan Hywan force-pushed the feat-common-linked-chunk-reset branch from 848451f to 31fc3b3 Compare November 25, 2024 15:50
@Hywan Hywan enabled auto-merge (rebase) November 25, 2024 15:51
This patch implements `LinkedChunk::clear`. The code from `impl Drop
for LinkedChunk` has been moved inside `Ends::clear`, and replaced by
a simple `self.links.clear()`. In addition, `LinkedChunk::clear` indeed
calls `self.links.clear()` but also resets all fields.

This patch adds the `Clear` variant to `Update`.

This patch updates `AsVector` to emit a `VectorDiff::Clear` on
`Update::Clear`.

Finally, this patch adds the necessary tests.
@Hywan Hywan force-pushed the feat-common-linked-chunk-reset branch from 31fc3b3 to 84a8355 Compare November 25, 2024 15:53
@Hywan Hywan disabled auto-merge November 25, 2024 16:08
@Hywan Hywan merged commit 2abbf58 into matrix-org:main Nov 25, 2024
38 checks passed
@Hywan Hywan mentioned this pull request Nov 28, 2024
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants