starred maps display as starred without refreshing

This commit is contained in:
Connor Turland 2016-08-30 15:05:23 -04:00
parent 0fdb38b0a5
commit 7824477d10

View file

@ -160,6 +160,7 @@ Metamaps.Map = {
if (!Metamaps.Active.Map) return if (!Metamaps.Active.Map) return
$.post('/maps/' + Metamaps.Active.Map.id + '/star') $.post('/maps/' + Metamaps.Active.Map.id + '/star')
Metamaps.Stars.push({ user_id: Metamaps.Active.Mapper.id, map_id: Metamaps.Active.Map.id }) Metamaps.Stars.push({ user_id: Metamaps.Active.Mapper.id, map_id: Metamaps.Active.Map.id })
Metamaps.Maps.Starred.add(Metamaps.Active.Map)
self.updateStar() self.updateStar()
}, },
unstar: function () { unstar: function () {
@ -168,7 +169,8 @@ Metamaps.Map = {
if (!Metamaps.Active.Map) return if (!Metamaps.Active.Map) return
$.post('/maps/' + Metamaps.Active.Map.id + '/unstar') $.post('/maps/' + Metamaps.Active.Map.id + '/unstar')
Metamaps.Stars = Metamaps.Stars.filter(function (s) { return s.user_id != Metamaps.Active.Mapper.id }) Metamaps.Stars = Metamaps.Stars.filter(function (s) { return s.user_id != Metamaps.Active.Mapper.id })
self.updateStar() Metamaps.Maps.Starred.remove(Metamaps.Active.Map)
self.updateStar()
}, },
fork: function () { fork: function () {
Metamaps.GlobalUI.openLightbox('forkmap') Metamaps.GlobalUI.openLightbox('forkmap')