Keep search results on data cleanup (#1147)

This commit is contained in:
enahum 2017-11-15 11:52:25 -03:00 committed by Harrison Healey
parent 2e9fb7f824
commit 073ddc9d44
2 changed files with 13 additions and 1 deletions

View file

@ -10,6 +10,7 @@ export default class SearchResultPost extends PureComponent {
static propTypes = {
isDeleted: PropTypes.bool.isRequired,
goToThread: PropTypes.func.isRequired,
managedConfig: PropTypes.object.isRequired,
navigator: PropTypes.object.isRequired,
postId: PropTypes.string.isRequired,
previewPost: PropTypes.func.isRequired
@ -24,6 +25,7 @@ export default class SearchResultPost extends PureComponent {
postComponentProps.onPress = this.props.previewPost;
postComponentProps.onReply = this.props.goToThread;
postComponentProps.shouldRenderReplyButton = true;
postComponentProps.managedConfig = this.props.managedConfig;
}
return (

View file

@ -203,6 +203,13 @@ function cleanupState(action, keepCurrent = false) {
return array.concat(ids);
}, []);
let searchResults = [];
if (payload.entities.search && payload.entities.search.results.length) {
const {results} = payload.entities.search;
searchResults = results;
postIdsToKeep.push(...results);
}
postIdsToKeep.forEach((postId) => {
const post = payload.entities.posts.posts[postId];
@ -253,7 +260,10 @@ function cleanupState(action, keepCurrent = false) {
emojis: payload.entities.emojis,
general: resetPayload.entities.general,
preferences: resetPayload.entities.preferences,
search: resetPayload.entities.search,
search: {
...resetPayload.entities.search,
results: searchResults
},
teams: resetPayload.entities.teams,
users: payload.entities.users
},