Prevent dismissed report details from immediately reopening

This commit is contained in:
Lucas Verney 2018-09-04 15:49:02 +02:00
parent aaa8998466
commit 42779844a7
2 changed files with 10 additions and 1 deletions

View File

@ -493,7 +493,10 @@ export default {
);
// TODO: Take into account the history of positions for the direction
if (closestReport.id !== -1) {
this.$store.dispatch('showReportDetails', { id: closestReport.id, userAsked: false });
// Only open the details if the box was not just closed
if (this.$store.state.reportDetails.previousId !== closestReport.id) {
this.$store.dispatch('showReportDetails', { id: closestReport.id, userAsked: false });
}
} else {
this.$store.dispatch('hideReportDetails');
}

View File

@ -97,6 +97,7 @@ export const initialState = {
},
reportDetails: {
id: null,
previousId: null,
userAsked: null,
},
reports: [],
@ -192,6 +193,11 @@ export const mutations = {
state.settings[setting] = value;
},
[types.SHOW_REPORT_DETAILS](state, { id, userAsked }) {
if (id === null) {
// If closing the details, keep track of what the id was to prevent
// reopening the details immediately.
Vue.set(state.reportDetails, 'previousId', state.reportDetails.id);
}
Vue.set(state.reportDetails, 'id', id);
Vue.set(state.reportDetails, 'userAsked', userAsked);
},