Moved store to session store.

This commit is contained in:
Martin Edenhofer 2015-11-04 10:25:55 +01:00
parent 01678787f3
commit 21de1e8bd8
5 changed files with 16 additions and 18 deletions

View file

@ -10,7 +10,7 @@ class App.DashboardActivityStream extends App.Controller
fetch: => fetch: =>
# use cache of first page # use cache of first page
cache = App.LocalStorage.get('activity_stream') cache = App.SessionStorage.get('activity_stream')
if cache if cache
@load(cache) @load(cache)
@ -30,7 +30,7 @@ class App.DashboardActivityStream extends App.Controller
load: (data) => load: (data) =>
App.LocalStorage.set('activity_stream', data) App.SessionStorage.set('activity_stream', data)
items = data.activity_stream items = data.activity_stream

View file

@ -11,7 +11,7 @@ class App.DashboardRss extends App.Controller
fetch: => fetch: =>
# get data from cache # get data from cache
cache = App.LocalStorage.get( 'dashboard_rss' ) cache = App.SessionStorage.get('dashboard_rss')
if cache if cache
cache.head = 'Heise ATOM' cache.head = 'Heise ATOM'
@render( cache ) @render( cache )
@ -34,7 +34,7 @@ class App.DashboardRss extends App.Controller
message: data.message message: data.message
) )
else else
App.LocalStorage.set( 'dashboard_rss', data ) App.SessionStorage.set('dashboard_rss', data)
data.head = 'Heise ATOM' data.head = 'Heise ATOM'
@render(data) @render(data)
error: => error: =>

View file

@ -32,7 +32,7 @@ class App.TicketZoom extends App.Controller
@overview_id = false @overview_id = false
@key = 'ticket::' + @ticket_id @key = 'ticket::' + @ticket_id
cache = App.LocalStorage.get(@key) cache = App.SessionStorage.get(@key)
if cache if cache
@load(cache) @load(cache)
update = => update = =>
@ -168,7 +168,7 @@ class App.TicketZoom extends App.Controller
@ticketUpdatedAtLastCall = newTicketRaw.updated_at @ticketUpdatedAtLastCall = newTicketRaw.updated_at
@load(data, force) @load(data, force)
App.LocalStorage(@key, data) App.SessionStorage(@key, data)
if !@doNotLog if !@doNotLog
@doNotLog = 1 @doNotLog = 1

View file

@ -19,7 +19,7 @@ class App.WidgetTag extends App.Controller
@render() @render()
return return
@tags = App.LocalStorage.get( @cacheKey ) || [] @tags = App.SessionStorage.get( @cacheKey ) || []
if !_.isEmpty(@tags) if !_.isEmpty(@tags)
@render() @render()
@delay( @delay(
@ -42,7 +42,7 @@ class App.WidgetTag extends App.Controller
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@tags = data.tags @tags = data.tags
App.LocalStorage.set( @cacheKey, @tags ) App.SessionStorage.set( @cacheKey, @tags )
@render() @render()
) )

View file

@ -6,15 +6,15 @@ class App.SessionStorage
_instance ?= new _storeSingleton _instance ?= new _storeSingleton
_instance.set(key, value) _instance.set(key, value)
@get: (args) -> @get: (key) ->
if _instance == undefined if _instance == undefined
_instance ?= new _storeSingleton _instance ?= new _storeSingleton
_instance.get(args) _instance.get(key)
@delete: (args) -> @delete: (key) ->
if _instance == undefined if _instance == undefined
_instance ?= new _storeSingleton _instance ?= new _storeSingleton
_instance.delete(args) _instance.delete(key)
@clear: -> @clear: ->
if _instance == undefined if _instance == undefined
@ -40,7 +40,7 @@ class _storeSingleton
catch e catch e
if e is QUOTA_EXCEEDED_ERR if e is QUOTA_EXCEEDED_ERR
# do something nice to notify your users # do something nice to notify your users
App.Log.error 'App.LocalStore', 'Local storage quote exceeded!' App.Log.error 'App.SessionStorage', 'Session storage quote exceeded!'
# get item # get item
get: (key) -> get: (key) ->
@ -58,6 +58,4 @@ class _storeSingleton
# return list of all keys # return list of all keys
list: -> list: ->
for key of window.sessionStorage window.sessionStorage
list.push key
list