mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Correct some modal repops (#11739)
* fix(modals): correct some repops * fix(modals): also clean out "prev" * refactor(modals): hide in dismiss event
This commit is contained in:
@@ -609,6 +609,25 @@ export default {
|
||||
|
||||
if (modalBefore) this.$root.$emit('bv::show::modal', modalBefore, { fromRoot: true });
|
||||
});
|
||||
|
||||
// Dismiss modal aggressively. Pass a modal ID to remove a modal instance from the stack
|
||||
// (both the stack entry itself and its "prev" reference) so we don't reopen it
|
||||
this.$root.$on('habitica::dismiss-modal', oldModal => {
|
||||
if (!oldModal) return;
|
||||
this.$root.$emit('bv::hide::modal', oldModal);
|
||||
let removeIndex = this.$store.state.modalStack
|
||||
.map(modal => modal.modalId)
|
||||
.indexOf(oldModal);
|
||||
if (removeIndex >= 0) {
|
||||
this.$store.state.modalStack.splice(removeIndex, 1);
|
||||
}
|
||||
removeIndex = this.$store.state.modalStack
|
||||
.map(modal => modal.prev)
|
||||
.indexOf(oldModal);
|
||||
if (removeIndex >= 0) {
|
||||
delete this.$store.state.modalStack[removeIndex].prev;
|
||||
}
|
||||
});
|
||||
},
|
||||
validStack (modalStack) {
|
||||
const modalsThatCanShowTwice = ['profile'];
|
||||
|
||||
Reference in New Issue
Block a user