reload page if the user closes the modal or not clicking on the notification

This commit is contained in:
negue
2018-09-30 17:22:44 +02:00
parent 07bc374078
commit 5632031f16
3 changed files with 32 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
<template lang="pug">
b-modal#rebirth(:title="$t('modalAchievement')", size='md', :hide-footer="true")
b-modal#rebirth(:title="$t('modalAchievement')", size='md', :hide-footer="true", @hidden="reloadPage()")
.modal-body
.col-12
// @TODO: +achievementAvatar('sun',0)
@@ -24,23 +24,26 @@
</style>
<script>
import achievementFooter from './achievementFooter';
import achievementAvatar from './achievementAvatar';
import achievementFooter from './achievementFooter';
import achievementAvatar from './achievementAvatar';
import { mapState } from 'client/libs/store';
import {mapState} from 'client/libs/store';
export default {
components: {
achievementFooter,
achievementAvatar,
},
computed: {
...mapState({user: 'user.data'}),
},
methods: {
close () {
this.$root.$emit('bv::hide::modal', 'rebirth');
export default {
components: {
achievementFooter,
achievementAvatar,
},
},
};
computed: {
...mapState({user: 'user.data'}),
},
methods: {
close () {
this.$root.$emit('bv::hide::modal', 'rebirth');
},
reloadPage () {
window.location.reload(true);
},
},
};
</script>

View File

@@ -363,7 +363,18 @@ export default {
this.playSound(config.sound);
}
if (forceToModal) {
if (type === 'REBIRTH_ACHIEVEMENT') {
// reload if the user hasn't clicked on the notification
const timeOut = setTimeout(() => {
window.location.reload(true);
}, 60000);
this.text(config.label(this.$t), () => {
// prevent the current reload timeout
clearTimeout(timeOut);
this.$root.$emit('bv::show::modal', config.modalId);
}, false);
} else if (forceToModal) {
this.$root.$emit('bv::show::modal', config.modalId);
} else {
this.text(config.label(this.$t), () => {

View File

@@ -139,8 +139,6 @@ export function newStuffLater (store) {
export async function rebirth () {
let result = await axios.post('/api/v4/user/rebirth');
window.location.reload(true);
return result;
}