Some fixes for loading iPad gem products.

This commit is contained in:
Nick Winter 2014-11-12 20:21:14 -08:00
parent ed8285248f
commit 4fe6fd3020

View file

@ -6,7 +6,7 @@ module.exports = class BuyGemsModal extends ModalView
template: template
plain: true
products: [
originalProducts: [
{ price: '$4.99', gems: 5000, id: 'gems_5', i18n: 'buy_gems.few_gems' }
{ price: '$9.99', gems: 11000, id: 'gems_10', i18n: 'buy_gems.pile_gems' }
{ price: '$19.99', gems: 25000, id: 'gems_20', i18n: 'buy_gems.chest_gems' }
@ -24,6 +24,8 @@ module.exports = class BuyGemsModal extends ModalView
if application.isIPadApp
@products = []
Backbone.Mediator.publish 'buy-gems-modal:update-products'
else
@products = @originalProducts
getRenderData: ->
c = super()
@ -33,11 +35,11 @@ module.exports = class BuyGemsModal extends ModalView
onIPadProducts: (e) ->
newProducts = []
for iapProduct in e.products
localProduct = _.find @products, { id: iapProduct.id }
localProduct = _.find @originalProducts, { id: iapProduct.id }
continue unless localProduct
localProduct.price = iapProduct.price
newProducts.push localProduct
@products = newProducts
@products = _.sortBy newProducts, 'gems'
@render()
onClickProductButton: (e) ->