Fix stale search results when files are deleted from posts (#8985)
* Fix stale search results when files are deleted from posts * Minor * cleaned the dependency from useDidUpdate to not trigger unnecessary API call * Added comment
This commit is contained in:
parent
0d3369d062
commit
bfe6852ae7
1 changed files with 13 additions and 0 deletions
|
|
@ -374,6 +374,19 @@ const SearchScreen = ({teamId, teams, crossTeamSearchEnabled}: Props) => {
|
|||
}
|
||||
}, [isFocused]);
|
||||
|
||||
useDidUpdate(() => {
|
||||
if (isFocused && lastSearchedValue && showResults) {
|
||||
// requestAnimationFrame for smooth UI updates
|
||||
requestAnimationFrame(() => {
|
||||
handleSearch(searchTeamId, lastSearchedValue);
|
||||
});
|
||||
}
|
||||
|
||||
// Only watch isFocused to re-run search when screen comes back into focus
|
||||
// Removed lastSearchedValue, showResults, handleSearch, searchTeamId from dependencies
|
||||
// to prevent duplicate search calls (these values are updated by handleSearch itself)
|
||||
}, [isFocused]);
|
||||
|
||||
const handleEnterPressed = useCallback(() => {
|
||||
const topScreen = NavigationStore.getVisibleScreen();
|
||||
if (topScreen === Screens.HOME && isFocused) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue