From 42779844a70bfe41fe64b035b9d66d5a32e5c338 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Tue, 4 Sep 2018 15:49:02 +0200 Subject: [PATCH] Prevent dismissed report details from immediately reopening --- src/components/Map.vue | 5 ++++- src/store/mutations.js | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Map.vue b/src/components/Map.vue index 5f9048c..a546ae4 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -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'); } diff --git a/src/store/mutations.js b/src/store/mutations.js index bfcb9a0..9a574d7 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -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); },