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) {
handleOnClose();
setSearchResults({});
// handleOnClose();
// setSearchResults({});
if (tag) {
navigation.navigate({
routeName: ROUTES.SCREENS.SEARCH_RESULT,
params: {
tag: tag,
filter: feedType,
},
setSearchResults({
type: 'feedType',
data: [{ text: `#${tag}`, tag, filter: feedType }],
});
// navigation.navigate({
// routeName: ROUTES.SCREENS.SEARCH_RESULT,
// params: {
// tag: tag,
// filter: feedType,
// },
// });
} else {
navigation.navigate({
routeName: ROUTES.SCREENS.SEARCH_RESULT,
params: {
filter: feedType,
},
setSearchResults({
type: 'feedType',
data: [{ text: `#${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;
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:
break;
}