mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +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'];
|
||||
|
||||
@@ -592,7 +592,7 @@ export default {
|
||||
this.$emit('createChallenge', challenge);
|
||||
this.resetWorkingChallenge();
|
||||
|
||||
this.$root.$emit('bv::hide::modal', 'challenge-modal');
|
||||
this.$root.$emit('habitica::dismiss-modal', 'challenge-modal');
|
||||
this.$router.push(`/challenges/${challenge._id}`);
|
||||
},
|
||||
async updateChallenge () {
|
||||
@@ -613,7 +613,7 @@ export default {
|
||||
const challenge = await this.$store.dispatch('challenges:updateChallenge', { challenge: challengeDetails });
|
||||
this.$emit('updatedChallenge', { challenge });
|
||||
this.resetWorkingChallenge();
|
||||
this.$root.$emit('bv::hide::modal', 'challenge-modal');
|
||||
this.$root.$emit('habitica::dismiss-modal', 'challenge-modal');
|
||||
},
|
||||
toggleCategorySelect () {
|
||||
this.showCategorySelect = !this.showCategorySelect;
|
||||
|
||||
@@ -144,14 +144,16 @@ export default {
|
||||
challengeId: this.challengeId,
|
||||
winnerId: this.winner._id,
|
||||
});
|
||||
this.$root.$emit('habitica::dismiss-modal', 'close-challenge-modal');
|
||||
this.$router.push('/challenges/myChallenges');
|
||||
},
|
||||
async deleteChallenge () {
|
||||
if (!window.confirm('Are you sure you want to delete this challenge?')) return;
|
||||
if (!window.confirm(this.$t('sureDelCha'))) return;
|
||||
this.challenge = await this.$store.dispatch('challenges:deleteChallenge', {
|
||||
challengeId: this.challengeId,
|
||||
prize: this.prize,
|
||||
});
|
||||
this.$root.$emit('habitica::dismiss-modal', 'close-challenge-modal');
|
||||
this.$router.push('/challenges/myChallenges');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -294,7 +294,7 @@ export default {
|
||||
this.sendingInProgress = false;
|
||||
},
|
||||
close () {
|
||||
this.$root.$emit('bv::hide::modal', 'send-gems');
|
||||
this.$root.$emit('habitica::dismiss-modal', 'send-gems');
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user