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(ui): Add function to toggle reactions from timeline #2118

Merged
merged 41 commits into from
Jun 26, 2023

Conversation

jonnyandrew
Copy link
Contributor

@jonnyandrew jonnyandrew commented Jun 20, 2023

Changes

  • Add function to toggle reactions from the timeline
  • Add local echo for reactions in the timeline
  • Support local echo changing during previous request to add or redact a reaction

Current limitations

Does not include

Context

Tasks

  • Add toggle_reaction function to timeline
    • Integration test
    • Unit tests

Signed-off-by:

@jonnyandrew jonnyandrew changed the title feat(ui): Add toggle_reaction function to timeline feat(ui): Add function to toggle reactions from timeline Jun 20, 2023
@jonnyandrew jonnyandrew marked this pull request as ready for review June 21, 2023 14:50
@jonnyandrew jonnyandrew requested a review from a team as a code owner June 21, 2023 14:50
@jonnyandrew jonnyandrew requested review from jplatte and aringenbach and removed request for a team June 21, 2023 14:50
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Patch coverage: 86.25% and project coverage change: +0.19 🎉

Comparison is base (4c24007) 76.12% compared to head (291612c) 76.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2118      +/-   ##
==========================================
+ Coverage   76.12%   76.32%   +0.19%     
==========================================
  Files         163      163              
  Lines       17303    17513     +210     
==========================================
+ Hits        13172    13366     +194     
- Misses       4131     4147      +16     
Impacted Files Coverage Δ
crates/matrix-sdk-ui/src/timeline/event_handler.rs 73.09% <68.00%> (-0.35%) ⬇️
crates/matrix-sdk-ui/src/timeline/inner.rs 74.56% <88.51%> (+4.82%) ⬆️
crates/matrix-sdk-ui/src/timeline/mod.rs 82.72% <88.57%> (+1.74%) ⬆️
...s/matrix-sdk-ui/src/timeline/event_item/content.rs 60.64% <100.00%> (+4.06%) ⬆️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Very rough first review. Thanks for adding a bunch of tests!

crates/matrix-sdk-ui/src/timeline/event_item/content.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_item/content.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_item/content.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_item/content.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/reactions.rs Outdated Show resolved Hide resolved
@jonnyandrew jonnyandrew requested a review from jplatte June 21, 2023 16:13
@jonnyandrew
Copy link
Contributor Author

Thanks for the review @jplatte - I have addressed the issues

crates/matrix-sdk-ui/src/timeline/event_handler.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_handler.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_handler.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_item/content.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/inner.rs Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/inner.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/inner.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/reactions.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/tests/helpers.rs Outdated Show resolved Hide resolved
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.

Small code comments here and there, but with the main locking issue resolved, that looks good to me! Will let @jplatte handle the final approval.

crates/matrix-sdk-ui/src/timeline/inner.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/inner.rs Outdated Show resolved Hide resolved
testing/matrix-sdk-integration-testing/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +273 to +279
match result {
ReactionAction::None => {}
ReactionAction::SendRemote(_) | ReactionAction::RedactRemote(_) => {
// Remember the new in flight request
state.in_flight_reaction.insert(annotation.into(), reaction_state);
}
};
Copy link
Member

Choose a reason for hiding this comment

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

nit: This match could be avoided if we duplicated line 277 in the two places in the above match. I would prefer this slightly better, but it's personal taste, so feel free to dismiss :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added two matches to make it a bit clearer what is being done (i.e. first calculate the result, then update the state) and avoid the side effect getting lost amongst the other logic.

Given the function is already pretty long I'd probably err on the side of clarity if that makes sense to you also?

Copy link
Collaborator

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

One last thing, I think then we can merge.

crates/matrix-sdk-ui/src/timeline/tests/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/tests/mod.rs Outdated Show resolved Hide resolved
@jonnyandrew jonnyandrew requested a review from jplatte June 26, 2023 14:51
@jonnyandrew
Copy link
Contributor Author

Thanks @jplatte and @bnjbvr for the reviews! I don't have permissions to merge - are you able to take care of that?

@jplatte jplatte enabled auto-merge (squash) June 26, 2023 15:03
@jplatte jplatte merged commit 7e7996d into main Jun 26, 2023
@jplatte jplatte deleted the jonny/timeline-reactions branch June 26, 2023 15:17
@bnjbvr
Copy link
Member

bnjbvr commented Jun 26, 2023

Great work @jonnyandrew!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants