fix: toast not appearing when search results null

This commit is contained in:
ammarahm-ed
2020-03-09 18:33:40 +05:00
parent 81112f84a3
commit 0cd254c2db
3 changed files with 20 additions and 16 deletions

View File

@@ -98,20 +98,19 @@ export const Container = ({
data[0].data ? db.notes.all : data, data[0].data ? db.notes.all : data,
text, text,
); );
if (!searchResult || searchResult.length === 0) {
if (!searchResults && searchResults.length < 0) { ToastEvent.show('No search results found for ' + text, 'error');
ToastEvent.show('No search results found', 'error', 3000, () => {}, '');
return; return;
} else {
dispatch({
type: ACTIONS.SEARCH_RESULTS,
results: {
type,
results: searchResult,
keyword: text,
},
});
} }
dispatch({
type: ACTIONS.SEARCH_RESULTS,
results: {
type,
results: searchResult,
keyword: text,
},
});
}; };
const onBlur = () => { const onBlur = () => {

View File

@@ -206,7 +206,14 @@ export const Menu = ({
inputRef.current?.setNativeProps({ inputRef.current?.setNativeProps({
text: '', text: '',
}); });
dispatch({type: ACTIONS.SEARCH_RESULTS, results: []}); dispatch({
type: ACTIONS.SEARCH_RESULTS,
results: {
type: null,
results: [],
keyword: null,
},
});
} }
item.func(); item.func();
}} }}

View File

@@ -7,17 +7,15 @@ async function read(key, isArray = false) {
let data; let data;
if (isArray) { if (isArray) {
data = await getArray(key); data = await getArray(key);
data.push('hello');
} else { } else {
data = await FastStorage.getMap(key); data = await FastStorage.getMap(key);
} }
console.log('READ', data, key);
return data; return data;
} }
async function write(key, data) { async function write(key, data) {
if (data.length !== undefined) { if (data.length !== undefined) {
console.log(data, key);
return await setArray(key, data); return await setArray(key, data);
} else { } else {
return await FastStorage.setMap(key, data); return await FastStorage.setMap(key, data);