Fixed search issue

This commit is contained in:
Mustafa Buyukcelebi 2019-11-29 12:21:15 +03:00
parent 55858a2434
commit 1bbeb73ab5

View File

@ -99,37 +99,45 @@ const SearchModalContainer = ({
}); });
} }
} else if (feedType) { } else if (feedType) {
handleOnClose(); // handleOnClose();
setSearchResults({}); // setSearchResults({});
if (tag) { if (tag) {
navigation.navigate({ setSearchResults({
routeName: ROUTES.SCREENS.SEARCH_RESULT, type: 'feedType',
params: { data: [{ text: `#${tag}`, tag, filter: feedType }],
tag: tag,
filter: feedType,
},
}); });
// navigation.navigate({
// routeName: ROUTES.SCREENS.SEARCH_RESULT,
// params: {
// tag: tag,
// filter: feedType,
// },
// });
} else { } else {
navigation.navigate({ setSearchResults({
routeName: ROUTES.SCREENS.SEARCH_RESULT, type: 'feedType',
params: { data: [{ text: `#${feedType}`, filter: feedType }],
filter: feedType,
},
}); });
// navigation.navigate({
// routeName: ROUTES.SCREENS.SEARCH_RESULT,
// params: {
// filter: feedType,
// },
// });
} }
} }
} else {
search({ q: text }).then(res => {
res.results = res.results
.filter(item => item.title !== '')
.map(item => ({
image: item.img_url || getResizedAvatar(get(item, 'author')),
text: item.title,
...item,
}));
setSearchResults({ type: 'content', data: get(res, 'results', []) });
});
} }
} else {
search({ q: text }).then(res => {
res.results = res.results
.filter(item => item.title !== '')
.map(item => ({
image: item.img_url || getResizedAvatar(get(item, 'author')),
text: item.title,
...item,
}));
setSearchResults({ type: 'content', data: get(res, 'results', []) });
});
} }
} }
}; };
@ -165,6 +173,20 @@ const SearchModalContainer = ({
}; };
break; break;
case 'feedType':
routeName = ROUTES.SCREENS.SEARCH_RESULT;
if (get(item, 'tag', false)) {
params = {
tag: get(item, 'tag', ''),
filter: get(item, 'filter', ''),
};
} else {
params = {
filter: get(item, 'filter', ''),
};
}
break;
default: default:
break; break;
} }