| 808 | } |
| 809 | |
| 810 | updateConfig (callback, skipSessionSave) { |
| 811 | let left, left1, patchMe |
| 812 | if (debugInventory) { console.log('Inside updateConfig') } |
| 813 | const sessionHeroConfig = (left = this.options.session.get('heroConfig')) != null ? left : {} |
| 814 | const lastHeroConfig = (left1 = me.get('heroConfig')) != null ? left1 : {} |
| 815 | const inventory = this.getCurrentEquipmentConfig() |
| 816 | let patchSession = (patchMe = false) |
| 817 | if (!patchSession) { patchSession = !_.isEqual(inventory, sessionHeroConfig.inventory) } |
| 818 | sessionHeroConfig.inventory = inventory |
| 819 | const hero = this.selectedHero != null ? this.selectedHero.get('original') : undefined |
| 820 | if (hero) { |
| 821 | if (!patchSession) { patchSession = !_.isEqual(hero, sessionHeroConfig.thangType) } |
| 822 | sessionHeroConfig.thangType = hero |
| 823 | } |
| 824 | if (!patchMe) { patchMe = !_.isEqual(inventory, lastHeroConfig.inventory) } |
| 825 | lastHeroConfig.inventory = inventory |
| 826 | if (patchMe) { |
| 827 | if (debugInventory) { console.log('Inventory Modal: setting me.heroConfig to', JSON.stringify(lastHeroConfig)) } |
| 828 | me.set('heroConfig', lastHeroConfig) |
| 829 | me.patch() |
| 830 | } |
| 831 | if (patchSession) { |
| 832 | if (debugInventory) { console.log('Inventory Modal: setting session.heroConfig to', JSON.stringify(sessionHeroConfig)) } |
| 833 | this.options.session.set('heroConfig', sessionHeroConfig) |
| 834 | if (!skipSessionSave) { return this.options.session.patch({ success: callback }) } |
| 835 | } else { |
| 836 | return (typeof callback === 'function' ? callback() : undefined) |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | // - TODO: DRY this between PlayItemsModal and InventoryModal and PlayHeroesModal |
| 841 | |