mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
38948137b9
1 changed files with 6 additions and 2 deletions
|
@ -81,21 +81,25 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
@newEarnedAchievements.push ea
|
||||
@listenToOnce ea, 'sync', ->
|
||||
if _.all((ea.id for ea in @newEarnedAchievements))
|
||||
@newEarnedAchievementsResource.markLoaded()
|
||||
@listenToOnce me, 'sync', ->
|
||||
@readyToContinue = true
|
||||
@updateSavingProgressStatus()
|
||||
me.fetch cache: false unless me.loading
|
||||
|
||||
@readyToContinue = true if not @achievements.models.length
|
||||
|
||||
# have to use a something resource because addModelResource doesn't handle models being upserted/fetched via POST like we're doing here
|
||||
@newEarnedAchievementsResource = @supermodel.addSomethingResource('earned achievements') if @newEarnedAchievements.length
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.levelName = utils.i18n @level.attributes, 'name'
|
||||
earnedAchievementMap = _.indexBy(@earnedAchievements?.models or [], (ea) -> ea.get('achievement'))
|
||||
earnedAchievementMap = _.indexBy(@newEarnedAchievements or [], (ea) -> ea.get('achievement'))
|
||||
for achievement in @achievements.models
|
||||
earnedAchievement = earnedAchievementMap[achievement.id]
|
||||
if earnedAchievement
|
||||
achievement.completedAWhileAgo = new Date() - Date.parse(earnedAchievement.get('created')) > 30 * 1000
|
||||
achievement.completedAWhileAgo = new Date().getTime() - Date.parse(earnedAchievement.get('created')) > 30 * 1000
|
||||
achievement.worth = achievement.get 'worth', true
|
||||
achievement.gems = achievement.get('rewards')?.gems
|
||||
c.achievements = @achievements.models.slice()
|
||||
|
|
Loading…
Reference in a new issue