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

timeline queue: refactor the code a bit #3433

Merged
merged 3 commits into from
May 20, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented May 17, 2024

Part of #3361. This is me understanding the code and starting to refactor it a bit.

A few renamings here and there, making use of `as_variant!` a bit more,
adding a few comments,…
@bnjbvr bnjbvr requested a review from a team as a code owner May 17, 2024 16:47
@bnjbvr bnjbvr requested review from Hywan and removed request for a team May 17, 2024 16:47
@bnjbvr bnjbvr force-pushed the bnjbvr/bnjbvrify-the-timeline-sending-q branch from 79fc8fc to 55540f2 Compare May 17, 2024 16:51
Copy link

codecov bot commented May 17, 2024

Codecov Report

Attention: Patch coverage is 64.58333% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 83.14%. Comparing base (6c18bcf) to head (1609236).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/queue.rs 66.66% 13 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/mod.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3433      +/-   ##
==========================================
+ Coverage   83.12%   83.14%   +0.01%     
==========================================
  Files         247      247              
  Lines       25016    25008       -8     
==========================================
- Hits        20795    20793       -2     
+ Misses       4221     4215       -6     

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

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Left a couple of nits, but looks good.

// reflected in the timeline, so we set all other pending events to
// cancelled.
//
// TODO(bnjbvr): spooky action at a distance here^
Copy link
Contributor

Choose a reason for hiding this comment

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

While I like the physics reference and don't want you to remove it, maybe it would make sense what the physicist in you meant here? I can guess that it's probably about one item affecting/cancelling other items, it would be nice to write it down.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah fun, I for one didn't know it was a physics reference xD

https://en.wikipedia.org/wiki/Action_at_a_distance_(computer_programming)

In this case, there's tight coupling between this loop and the behavior of the sending queue, which is just working by coincidence (both paths know they interact together that way), and it's not good. Will update the comment.

error_return!("Retrying state events is not currently supported");
| TimelineItemContent::OtherState(_)
| TimelineItemContent::CallInvite => {
error_return!("Retrying state events/call invite is not currently supported");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
error_return!("Retrying state events/call invite is not currently supported");
error_return!("Retrying state events/call invites is not currently supported");

},
)
.await;
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would you do a if/return/implicit return instead of a if/else here? I understand the above one to avoid a nested if, this one seems to go a bit too far with the removal of the nesting.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do like that the main operation is not under a conditional, and just lives at the end in the main path, but I can revert this one change here.

crates/matrix-sdk-ui/src/timeline/queue.rs Show resolved Hide resolved
@bnjbvr bnjbvr enabled auto-merge (rebase) May 20, 2024 09:07
@bnjbvr bnjbvr merged commit 5df53d7 into main May 20, 2024
36 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/bnjbvrify-the-timeline-sending-q branch May 20, 2024 09:18
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.

None yet

2 participants