-
Notifications
You must be signed in to change notification settings - Fork 267
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -655,11 +655,16 @@ impl Room { | |||||
|
||||||
/// Returns the current RoomNotableTags and subscribe to changes. | ||||||
pub async fn notable_tags_stream(&self) -> (RoomNotableTags, Subscriber<RoomNotableTags>) { | ||||||
(self.current_notable_tags().await, self.notable_tags.subscribe()) | ||||||
} | ||||||
|
||||||
/// Return the current RoomNotableTags extracted from store. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
pub async fn current_notable_tags(&self) -> RoomNotableTags { | ||||||
let current_tags = self.tags().await.unwrap_or_else(|e| { | ||||||
warn!("Failed to get tags from store: {}", e); | ||||||
None | ||||||
}); | ||||||
(RoomNotableTags::new(current_tags), self.notable_tags.subscribe()) | ||||||
RoomNotableTags::new(current_tags) | ||||||
} | ||||||
|
||||||
/// Get the `RoomMember` with the given `user_id`. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ use matrix_sdk_base::{ | |
}, | ||
instant::Instant, | ||
store::StateStoreExt, | ||
RoomMemberships, StateChanges, | ||
RoomMemberships, RoomNotableTags, StateChanges, | ||
}; | ||
use matrix_sdk_common::timeout::timeout; | ||
use mime::Mime; | ||
|
@@ -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<()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me neither. @bnjbvr do you have an opinion? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
let current_notable_tags = self.inner.current_notable_tags().await; | ||
if current_notable_tags.is_favorite != notable_tags.is_favorite { | ||
if notable_tags.is_favorite { | ||
self.set_tag(TagName::Favorite, TagInfo::default()).await?; | ||
} else { | ||
self.remove_tag(TagName::Favorite).await?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
/// Sets whether this room is a DM. | ||
/// | ||
/// When setting this room as DM, it will be marked as DM for all active | ||
|
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.
Please, use:
to first put
RoomNotableTags
in a<code>
, and then to create a link to it.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.
@Hywan I let you handle those changes on your own. There is tons of places where [
] notation is not used (almost everywhere actually).
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.
This is your code. Can you fix it please? I'll handle the others, but please handle it in your code.