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

Tags : introduce set_is_favorite and set_is_low_priority #3075

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

ganfra
Copy link
Contributor

@ganfra ganfra commented Jan 30, 2024

Handles "Expose a way to update tags in the bindings" from #3005

@ganfra ganfra requested a review from a team as a code owner January 30, 2024 16:54
@ganfra ganfra requested review from andybalaam and removed request for a team January 30, 2024 16:54
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6ef3361) 83.71% compared to head (eeafc19) 83.72%.
Report is 107 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3075   +/-   ##
=======================================
  Coverage   83.71%   83.72%           
=======================================
  Files         223      223           
  Lines       23395    23425   +30     
=======================================
+ Hits        19585    19612   +27     
- Misses       3810     3813    +3     

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

@@ -937,6 +937,20 @@ impl Room {
self.client.send(request, None).await
}

/// Update the tags from the room by calling set_tag or remove_tag method if
/// needed.
pub async fn update_notable_tags(&self, notable_tags: RoomNotableTags) -> Result<()> {
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'm not sure this is best to do like this for the future, or offer method for each tags like
set_is_favorite(bool)
set_is_low_priority(bool)

Copy link
Contributor

Choose a reason for hiding this comment

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

Me neither. @bnjbvr do you have an opinion?

Copy link
Member

Choose a reason for hiding this comment

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

I don't find it likely to change multiple ones at the same time, this shouldn't happen quite often so performance isn't critical, and having a single method for each notable tag makes for a better API IMO, so I'd in favor of having set_is_... methods 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it's worth checking the local value tags before sending the request?
I guess we can have some race condition (especially with this issue) which could prevent the request to happen when it should.

Copy link
Contributor

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

This is great, thank you. Please could you split the test up to make it easier to understand?

I would recommend:

  1. Several little helper methods e.g. mock_favourite to do the mocking stuff, do_sync (or a better name!) to do the sync stuff
  2. Break it into several tests with names like updating_notable_tags_causes_new_favourite_to_be_produced (or something better)

I really like my main test methods to be easily readable as "set up, do something, assert something" ("Given", "When", "Then" according to some people). At the moment, it takes a lot of reading to see what the test is really testing.

Thank you!

@ganfra
Copy link
Contributor Author

ganfra commented Feb 1, 2024

This is great, thank you. Please could you split the test up to make it easier to understand?

I would recommend:

  1. Several little helper methods e.g. mock_favourite to do the mocking stuff, do_sync (or a better name!) to do the sync stuff
  2. Break it into several tests with names like updating_notable_tags_causes_new_favourite_to_be_produced (or something better)

I really like my main test methods to be easily readable as "set up, do something, assert something" ("Given", "When", "Then" according to some people). At the moment, it takes a lot of reading to see what the test is really testing.

Thank you!

Honestly I wrote the tests in the same way other tests have been written, but I agree they are not easy to read..

@ganfra
Copy link
Contributor Author

ganfra commented Feb 6, 2024

@andybalaam ok so, I changed the method update_notable_tags with set_is_favorite and set_is_low_priority.
I also added the is_low_priority in RoomNotableTags.
And I've split all the tests so it's more readable.

Let me know what you think!

Copy link
Contributor

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

The tests look much better - I was much more able to understand what you were doing - thank you!

The code looks good to me, but I will want a nod from @bnjbvr before I merge, to check this is the right approach overall.

@ganfra ganfra changed the title tags : introduce update_notable_tags method Tags : introduce set_is_favorite and set_is_low_priority Feb 7, 2024
@@ -655,11 +655,16 @@ impl Room {

/// Returns the current RoomNotableTags and subscribe to changes.
Copy link
Member

Choose a reason for hiding this comment

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

Please, use:

- RoomNotableTags
+ [`RoomNotableTags`]

to first put RoomNotableTags in a <code>, and then to create a link to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Hywan I let you handle those changes on your own. There is tons of places where [ ] notation is not used (almost everywhere actually).

Copy link
Member

Choose a reason for hiding this comment

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

This is your code. Can you fix it please? I'll handle the others, but please handle it in your code.

(self.current_notable_tags().await, self.notable_tags.subscribe())
}

/// Return the current RoomNotableTags extracted from store.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Return the current RoomNotableTags extracted from store.
/// Return the current [`RoomNotableTags`] extracted from store.

@@ -937,6 +937,52 @@ impl Room {
self.client.send(request, None).await
}

/// Update the is_favorite flag from the room by calling set_tag or
/// remove_tag method on `m.favourite` tag.
/// If is_favorite is true, and `m.low_priority` tag is set on the room, the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// If is_favorite is true, and `m.low_priority` tag is set on the room, the
/// If `is_favorite` is `true`, and `m.low_priority` tag is set on the room, the

@ganfra ganfra requested a review from Hywan February 8, 2024 09:54
@Hywan Hywan enabled auto-merge (squash) February 8, 2024 10:00
@Hywan Hywan merged commit 0c1d90d into main Feb 8, 2024
34 checks passed
@Hywan Hywan deleted the fga/update_room_notable_tags branch February 8, 2024 11:32
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.

4 participants