mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Show orb of rebirth confirmation modal after use (window refresh) (#15540)
* fix(content): textual tweaks and updates * fix(link): direct to FAQ instead of wiki * fix(faq): correct Markdown * Show orb of rebirth confirmation modal after use (window refresh) * Set and check rebirth confirmation modal from localstorage Set and check rebirth confirmation modal from localstorage after window reload * Don't show orb of rebirth confirmation modal until page reloads --------- Co-authored-by: Kalista Payne <kalista@habitica.com>
This commit is contained in:
@@ -328,6 +328,8 @@ export default {
|
|||||||
alreadyReadNotification,
|
alreadyReadNotification,
|
||||||
nextCron: null,
|
nextCron: null,
|
||||||
handledNotifications,
|
handledNotifications,
|
||||||
|
isInitialLoadComplete: false,
|
||||||
|
pendingRebirthNotification: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -453,6 +455,18 @@ export default {
|
|||||||
|
|
||||||
return this.runYesterDailies();
|
return this.runYesterDailies();
|
||||||
},
|
},
|
||||||
|
async showPendingRebirthModal () {
|
||||||
|
if (this.pendingRebirthNotification) {
|
||||||
|
this.playSound('Achievement_Unlocked');
|
||||||
|
this.$root.$emit('bv::show::modal', 'rebirth');
|
||||||
|
|
||||||
|
await axios.post('/api/v4/notifications/read', {
|
||||||
|
notificationIds: [this.pendingRebirthNotification.id],
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pendingRebirthNotification = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
showDeathModal () {
|
showDeathModal () {
|
||||||
this.playSound('Death');
|
this.playSound('Death');
|
||||||
this.$root.$emit('bv::show::modal', 'death');
|
this.$root.$emit('bv::show::modal', 'death');
|
||||||
@@ -661,6 +675,18 @@ export default {
|
|||||||
this.showLevelUpNotifications(this.user.stats.lvl);
|
this.showLevelUpNotifications(this.user.stats.lvl);
|
||||||
}
|
}
|
||||||
this.handleUserNotifications(this.user.notifications);
|
this.handleUserNotifications(this.user.notifications);
|
||||||
|
|
||||||
|
this.isInitialLoadComplete = true;
|
||||||
|
|
||||||
|
const hasRebirthConfirmationFlag = localStorage.getItem('show-rebirth-confirmation') === 'true';
|
||||||
|
|
||||||
|
if (hasRebirthConfirmationFlag) {
|
||||||
|
localStorage.removeItem('show-rebirth-confirmation');
|
||||||
|
this.playSound('Achievement_Unlocked');
|
||||||
|
this.$root.$emit('bv::show::modal', 'rebirth');
|
||||||
|
} else {
|
||||||
|
this.showPendingRebirthModal();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async handleUserNotifications (after) {
|
async handleUserNotifications (after) {
|
||||||
if (this.$store.state.isRunningYesterdailies) return;
|
if (this.$store.state.isRunningYesterdailies) return;
|
||||||
@@ -700,8 +726,15 @@ export default {
|
|||||||
this.$root.$emit('habitica:won-challenge', notification);
|
this.$root.$emit('habitica:won-challenge', notification);
|
||||||
break;
|
break;
|
||||||
case 'REBIRTH_ACHIEVEMENT':
|
case 'REBIRTH_ACHIEVEMENT':
|
||||||
|
if (localStorage.getItem('show-rebirth-confirmation') === 'true') {
|
||||||
|
markAsRead = false;
|
||||||
|
} else if (!this.isInitialLoadComplete) {
|
||||||
|
this.pendingRebirthNotification = notification;
|
||||||
|
markAsRead = false;
|
||||||
|
} else {
|
||||||
this.playSound('Achievement_Unlocked');
|
this.playSound('Achievement_Unlocked');
|
||||||
this.$root.$emit('bv::show::modal', 'rebirth');
|
this.$root.$emit('bv::show::modal', 'rebirth');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'STREAK_ACHIEVEMENT':
|
case 'STREAK_ACHIEVEMENT':
|
||||||
this.text(`${this.$t('streaks')}: ${this.user.achievements.streak}`, () => {
|
this.text(`${this.$t('streaks')}: ${this.user.achievements.streak}`, () => {
|
||||||
|
|||||||
@@ -873,10 +873,15 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.genericPurchase) {
|
if (this.genericPurchase) {
|
||||||
|
if (this.item.key === 'rebirth_orb') {
|
||||||
|
localStorage.setItem('show-rebirth-confirmation', 'true');
|
||||||
|
}
|
||||||
await this.makeGenericPurchase(this.item, 'buyModal', this.selectedAmountToBuy);
|
await this.makeGenericPurchase(this.item, 'buyModal', this.selectedAmountToBuy);
|
||||||
|
if (this.item.key !== 'rebirth_orb') {
|
||||||
await this.purchased(this.item.text);
|
await this.purchased(this.item.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.$emit('buyPressed', this.item);
|
this.$emit('buyPressed', this.item);
|
||||||
this.hideDialog();
|
this.hideDialog();
|
||||||
|
|||||||
Reference in New Issue
Block a user