Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/pages/Search/SearchSavePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,20 @@ function FilterValue({filterKey, value}: FilterValueWithKeyProps) {
function SearchSavePage() {
const styles = useThemeStyles();
const {translate, localeCompare} = useLocalize();
const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES);
const [searchAdvancedFiltersForm = getEmptyObject<Partial<SearchAdvancedFiltersForm>>()] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM);
const [name, setName] = useState('');

const {currentSearchQueryJSON} = useSearchStateContext();

const onSaveSearch = () => {
const savedSearchKeys = Object.keys(savedSearches ?? {});
if (!currentSearchQueryJSON || (savedSearches && savedSearchKeys.includes(String(currentSearchQueryJSON.hash)))) {
// If the search is already saved, we only display the results as we don't need to save it.
const newName = name?.trim() || currentSearchQueryJSON?.inputQuery;
Comment thread
JS00001 marked this conversation as resolved.
Outdated
Comment thread
JS00001 marked this conversation as resolved.
Outdated

if (!currentSearchQueryJSON) {
Navigation.goBack();
return;
}

if (name) {
saveSearch({queryJSON: currentSearchQueryJSON, newName: name});
} else {
saveSearch({queryJSON: currentSearchQueryJSON});
}
saveSearch({queryJSON: currentSearchQueryJSON, newName});
Navigation.goBack();
};

Expand Down
Loading