Use storage service instead of Travis.storage

This commit is contained in:
Piotr Sarnacki 2015-11-09 14:06:42 +01:00
parent 1843d8cb54
commit ab0b0cbebc
2 changed files with 5 additions and 4 deletions

View File

@ -6,6 +6,7 @@ Controller = Ember.Controller.extend
userBinding: 'auth.currentUser'
store: Ember.inject.service()
storage: Ember.inject.service()
currentUserBinding: 'auth.currentUser'
userName: (->
@ -38,7 +39,7 @@ Controller = Ember.Controller.extend
options.type = 'GET'
options.headers = { Authorization: "token #{@auth.token()}" }
seenBroadcasts = Travis.storage.getItem('travis.seen_broadcasts')
seenBroadcasts = @get('storage').getItem('travis.seen_broadcasts')
if seenBroadcasts
seenBroadcasts = JSON.parse(seenBroadcasts)
else
@ -72,13 +73,13 @@ Controller = Ember.Controller.extend
markBroadcastAsSeen: (broadcast) ->
id = broadcast.get('id').toString()
seenBroadcasts = Travis.storage.getItem('travis.seen_broadcasts')
seenBroadcasts = @get('storage').getItem('travis.seen_broadcasts')
if seenBroadcasts
seenBroadcasts = JSON.parse(seenBroadcasts)
else
seenBroadcasts = []
seenBroadcasts.push(id)
Travis.storage.setItem('travis.seen_broadcasts', JSON.stringify(seenBroadcasts))
@get('storage').setItem('travis.seen_broadcasts', JSON.stringify(seenBroadcasts))
@get('broadcasts.content').removeObject(broadcast)
@set('broadcasts.lastBroadcastStatus', @defineTowerColor(@get('broadcasts.content')))
return false

View File

@ -18,7 +18,7 @@ Broadcast = Model.extend
Broadcast.reopenClass
seen: (->
seenBroadcasts = Travis.storage.getItem('travis.seen_broadcasts')
seenBroadcasts = Travis.lookup('service:storage').getItem('travis.seen_broadcasts')
seenBroadcasts = JSON.parse(seenBroadcasts) if seenBroadcasts?
Ember.A(seenBroadcasts || [])
).property()