Check local storage on load; use explicit condition syntax.

This commit is contained in:
Paulo Reis 2017-02-21 14:43:05 +00:00
parent 2e8f917318
commit 7f6941677d

View file

@ -19,7 +19,7 @@ define [
openSubView: $scope.SubViews.CUR_FILE openSubView: $scope.SubViews.CUR_FILE
overview: overview:
loading: false loading: false
docsCollapsedState: {} docsCollapsedState: JSON.parse(localStorage("docs_collapsed_state:#{$scope.project_id}")) or {}
dropdown: dropdown:
loading: false loading: false
commentThreads: {} commentThreads: {}
@ -28,13 +28,11 @@ define [
rendererData: {} rendererData: {}
loadingThreads: false loadingThreads: false
$scope.$on "project:joined", () ->
$scope.reviewPanel.overview.docsCollapsedState = JSON.parse(localStorage("docs_collapsed_state:#{$scope.project_id}")) or {}
window.addEventListener "beforeunload", () -> window.addEventListener "beforeunload", () ->
collapsedStates = {} collapsedStates = {}
for doc, state of $scope.reviewPanel.overview.docsCollapsedState for doc, state of $scope.reviewPanel.overview.docsCollapsedState
collapsedStates[doc] = state if state is true if state
collapsedStates[doc] = state
valToStore = if Object.keys(collapsedStates).length > 0 then JSON.stringify(collapsedStates) else null valToStore = if Object.keys(collapsedStates).length > 0 then JSON.stringify(collapsedStates) else null
localStorage("docs_collapsed_state:#{$scope.project_id}", valToStore) localStorage("docs_collapsed_state:#{$scope.project_id}", valToStore)