-
Notifications
You must be signed in to change notification settings - Fork 14
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
improve search filter capabilities #71
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jonas Fentker <jonas@fentker.eu>
Signed-off-by: Jonas Fentker <jonas@fentker.eu>
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.
Looks generally sane, but we should add tests to check if it works, also the search config doesn't seem to allow setting multiple rooms nor senders.
@@ -48,7 +49,7 @@ impl SearchConfig { | |||
/// | |||
/// * `room_id` - The unique id of the room. | |||
pub fn for_room(&mut self, room_id: &str) -> &mut Self { | |||
self.room_id = Some(room_id.to_owned()); | |||
self.room_ids = Some(vec![room_id.to_owned()]); |
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.
We need to allow multiple room ids to be set, no? That is we should allow the for_room
method to be called multiple times, every time adding another room to the vec.
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.
Both seshat-node and radical-native just deserialize the json for the searchConfig, so I didn't add any methods.
But I've now added them for the test 😃
} else { | ||
term.to_owned() | ||
for room in rooms { | ||
room_parts.push(format!("room_id:\"{}\"", room)) |
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 seems sensible, but did you test that this works as expected? I'm not sure how the query parser reacts to this. As I mentioned, having tests for this would be very welcome.
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.
I black-box-tested it with radical-native (and now added a test)
if let Some(senders) = &config.sender_ids { | ||
let mut sender_parts = Vec::new(); | ||
keys.push(self.sender_field); | ||
for sender in senders { |
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.
Same for the senders as for the multiple room ids.
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.
see previous
parts.push(format!("+({})", room_parts.join(" "))) | ||
}; | ||
|
||
if let Some(senders) = &config.sender_ids { |
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.
There doesn't seem to be a method to set the sender in the search config, or am I missing something?
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.
see first comment
Signed-off-by: Jonas Fentker <jonas@fentker.eu>
I tried to get this working with your matrix-react-sdk PR but the tab to select "All rooms" vs "This room" seems to be gone because of it, is there some other way to select which room to search? The screenshot seems to suggest that it's still using the tab. The tests seem sane but I wanted to check this out a bit on live Element before merging. |
Updated the OP at matrix-org/matrix-react-sdk#4156 to make it a little more obvious that room filter has been moved to the new autocomplete filter feature |
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.
Ok, tested this and was confused why it didn't work, we (or rather I) forgot that serde isn't used to create a SearchConfig
in the node bindings.
So the node bindings need to be updated as well, something like
if let Ok(k) = argument.get(&mut *cx, "sender_ids") {
if let Ok(k) = k.downcast::<JsArray>() {
let mut ids: Vec<Handle<JsValue>> = k.to_vec(&mut *cx)?;
let ids: Vec<String> = ids
.drain(..)
.filter_map(|id| id.downcast::<JsString>().ok())
.map(|s| s.value())
.collect();
config.for_senders(&ids);
}
}
needs to be added somewhere over here.
The new options should also be documented over here.
I found the way we set which room to search in inside of Element a bit confusing, I still haven't figured out how to search in a single DM considering that they won't complete after a #
but that's something to figure out on the Element side of things.
Companion to matrix-org/matrix-react-sdk#4156