Skip to content

Conversation

@ceebeel
Copy link
Owner

@ceebeel ceebeel commented Jun 26, 2024

Summary by Sourcery

This pull request introduces a responsive grid layout for displaying presets and adds a filtering mechanism to search and display presets based on a query string. It also includes enhancements to the preset display logic and updates the README to reflect these changes.

  • New Features:
    • Introduced a responsive grid layout for displaying presets, adjusting the number of columns based on available width.
    • Added a filtering mechanism to search and display presets based on a query string.
  • Enhancements:
    • Updated the preset display logic to remove redundant search query checks, improving performance.
    • Aligned text to the left in the flat preset view for better readability.
  • Documentation:
    • Updated the README to reflect the new features: preset filtering, responsive grid layout, and aligned text in flat preset view.

@ceebeel ceebeel marked this pull request as ready for review June 26, 2024 14:03
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 26, 2024

Reviewer's Guide by Sourcery

This pull request focuses on improving the user interface for preset management by making the grid layout responsive and adding a search filter for presets. Significant changes include the addition of a new function to filter presets, updates to the UI to use this filtered data, and various code cleanups and TODO removals.

File-Level Changes

Files Changes
src/redrop/src/presets_ui.rs
src/redrop/src/main_ui.rs
src/redrop/src/main.rs
Implemented responsive grid layout and integrated preset filtering based on search query.
src/common/src/preset.rs
src/redrop/src/main_ui.rs
Added functionality to filter presets based on a search query and updated the UI to reflect these changes.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ceebeel - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 6 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 2 issues found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

.spacing([4., 4.])
.show(ui, |ui| {
let mut preset_count = 0;
let max_preset_per_row = (ui.available_width() / 68.) as usize; // Preset width = 64. + 4. (spacing)
Copy link

Choose a reason for hiding this comment

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

suggestion: Magic number for preset width

Consider defining a constant or a configuration parameter for the preset width (68) to improve readability and maintainability.

Suggested change
let max_preset_per_row = (ui.available_width() / 68.) as usize; // Preset width = 64. + 4. (spacing)
const PRESET_WIDTH: f32 = 68.0;
let max_preset_per_row = (ui.available_width() / PRESET_WIDTH) as usize;

Comment on lines -20 to -22
if self.presets.lists[*preset_id]
.name
.contains(&self.preset_search_query)
Copy link

Choose a reason for hiding this comment

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

issue (performance): Removed search query filtering

The removal of the search query filtering might lead to performance issues if the preset list is large. Ensure that the filtering is handled elsewhere effectively.

pub img: Option<PathBuf>,
}

#[derive(Debug, Clone)]
Copy link

Choose a reason for hiding this comment

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

question: Added Debug and Clone traits

Adding Debug and Clone traits is useful for logging and copying. Ensure that these traits are necessary for the Node enum to avoid unnecessary trait implementations.

}
}

pub fn filter_presets_tree(query: &str, node: &BTreeMap<String, Node>) -> BTreeMap<String, Node> {
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): New filter_presets_tree function

The new filter_presets_tree function is a good addition for filtering. Ensure that this function is optimized for large trees to avoid performance bottlenecks.

Suggested change
pub fn filter_presets_tree(query: &str, node: &BTreeMap<String, Node>) -> BTreeMap<String, Node> {
pub fn filter_presets_tree<'a>(query: &str, node: &'a BTreeMap<String, Node>) -> BTreeMap<String, Node> {
node.iter()
.filter(|(name, _)| name.contains(query))
.map(|(name, node)| (name.clone(), node.clone()))
.collect()
}

Comment on lines +13 to +14
self.filtered_presets_tree =
filter_presets_tree(&self.preset_search_query, &self.presets.tree);
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Filtering presets on search query change

Filtering presets on search query change is a good approach. Ensure that the UI updates efficiently to reflect the filtered results without noticeable lag.

Suggested change
self.filtered_presets_tree =
filter_presets_tree(&self.preset_search_query, &self.presets.tree);
self.filtered_presets_tree = {
let query = self.preset_search_query.clone();
let tree = self.presets.tree.clone();
filter_presets_tree(&query, &tree)
};

- [X] Filter preset / Hide Empty Categories
- [X] Grid Layout: Responsive
- [X] Show Flat Preset: Align text to the left
- [ ] Change preset time interval on nBar (4 beat)
Copy link

Choose a reason for hiding this comment

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

question (documentation): Clarify 'Set Window default size (persistence !?)'

The exclamation and question marks might be confusing. Consider rephrasing to 'Set Window default size (persistent?)' or clarify the intended meaning.

@ceebeel ceebeel marked this pull request as draft June 26, 2024 14:11
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.

2 participants