mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 18:22:21 +00:00
fix(quests): level up if appropriate after completion
This commit is contained in:
parent
06f522e2c9
commit
ce1d1a763b
4 changed files with 29 additions and 0 deletions
|
|
@ -91,6 +91,7 @@ export default {
|
|||
this.close();
|
||||
},
|
||||
hide () {
|
||||
this.$store.dispatch('user:statSync');
|
||||
this.$store.dispatch('user:set', { 'party.quest.completed': '' });
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export const NotificationMixins = {
|
|||
this.notify(`${this.sign(val)}${val}`, 'damage');
|
||||
},
|
||||
exp (val) {
|
||||
if (val === 0) return;
|
||||
const message = getXPMessage(val);
|
||||
this.notify(message, 'xp', 'glyphicon glyphicon-star', this.sign(val));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import disableClassesOp from '@/../../common/script/ops/disableClasses';
|
|||
import openMysteryItemOp from '@/../../common/script/ops/openMysteryItem';
|
||||
import { unEquipByType } from '../../../../common/script/ops/unequip';
|
||||
import markPMSRead from '../../../../common/script/ops/markPMSRead';
|
||||
import updateStats from '../../../../common/script/fns/updateStats';
|
||||
|
||||
export function fetch (store, options = {}) { // eslint-disable-line no-shadow
|
||||
return loadAsyncResource({
|
||||
|
|
@ -179,6 +180,10 @@ export async function getPurchaseHistory () {
|
|||
return response.data.data;
|
||||
}
|
||||
|
||||
export function statSync (store) {
|
||||
updateStats(store.state.user.data, store.state.user.data.stats);
|
||||
return axios.post('/api/v4/user/stat-sync');
|
||||
}
|
||||
|
||||
export function newPrivateMessageTo (store, params) {
|
||||
const { member } = params;
|
||||
|
|
|
|||
|
|
@ -1775,4 +1775,26 @@ api.movePinnedItem = {
|
|||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/user/stat-sync
|
||||
* Request a refresh of user stats, including processing of pending level-ups
|
||||
* @apiName StatSync
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccess {Object} data The user object
|
||||
*/
|
||||
|
||||
api.statSync = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/stat-sync',
|
||||
async handler (req, res) {
|
||||
const { user } = res.locals;
|
||||
common.fns.updateStats(user, user.stats);
|
||||
await user.save();
|
||||
|
||||
res.respond(200, user);
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
||||
|
|
|
|||
Loading…
Reference in a new issue