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:
Rajat Dabade 2025-07-14 18:03:24 +05:30 committed by GitHub
parent 0d3369d062
commit bfe6852ae7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {