TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

fix(QtDriver): redundant search override

Open career-yashaswee opened this issue 1 year ago • 1 comments

fix(QtDriver): redundant search override

Description:

This pull request addresses an issue where the filter_items function was being called unnecessarily in the QtDriver class. This function filters assets based on a search term.

Expected Behavior:

When the user enters a search term and clicks the search button or presses Enter: If the search term hasn't changed (i.e., it's the same as the previous search), filter_items shouldn't be called again. This check should be bypassed during window initialisation to ensure all assets are initially visible.

Previous Behavior: filter_items was called regardless of whether the search term had changed, leading to redundant filtering.

Changes Introduced: A new variable, previous_search_string, is introduced. When the user performs a search:previous_search_string is set to the current search term.

Before calling filter_items: The code checks if previous_search_string is the same as the current search term. If they are the same and the window is not initializing, filter_itemsis skipped. An override flag is added for functions that call filter_items during window initialisation to bypass the check and ensure all assets are displayed.

Benefits:

  • Improves performance by avoiding unnecessary filtering.
  • Enhances user experience by preventing redundant filtering actions.

Testing: Manual testing has been conducted to ensure the fix functions as intended.

  • Additional unit tests can be added to further solidify the fix.

Please review the code changes and provide feedback.

career-yashaswee avatar Jun 04 '24 08:06 career-yashaswee

You also fully broke some stuff from the main branch when merging that affects search

YoyloNerd avatar Jun 04 '24 21:06 YoyloNerd

Closing due to inactivity

CyanVoxel avatar Dec 05 '24 07:12 CyanVoxel