From 33c8bc8684b22ff421ac5af0e62512fc96941f8d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 21 Feb 2017 14:20:51 +0000 Subject: [PATCH] Support saving state to local storage. --- .../controllers/ReviewPanelController.coffee | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 07f429036f..7faf5d7243 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -4,7 +4,7 @@ define [ "ide/colors/ColorManager" "ide/review-panel/RangesTracker" ], (App, EventEmitter, ColorManager, RangesTracker) -> - App.controller "ReviewPanelController", ($scope, $element, ide, $timeout, $http, $modal, event_tracking) -> + App.controller "ReviewPanelController", ($scope, $element, ide, $timeout, $http, $modal, event_tracking, localStorage) -> $reviewPanelEl = $element.find "#review-panel" $scope.SubViews = @@ -28,6 +28,16 @@ define [ rendererData: {} loadingThreads: false + $scope.$on "project:joined", () -> + $scope.reviewPanel.overview.docsCollapsedState = JSON.parse(localStorage("docs_collapsed_state:#{$scope.project_id}")) or {} + + window.addEventListener "beforeunload", () -> + collapsedStates = {} + for doc, state of $scope.reviewPanel.overview.docsCollapsedState + collapsedStates[doc] = state if state is true + valToStore = if Object.keys(collapsedStates).length > 0 then JSON.stringify(collapsedStates) else null + localStorage("docs_collapsed_state:#{$scope.project_id}", valToStore) + $scope.$on "layout:pdf:linked", (event, state) -> $scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed) $scope.$broadcast "review-panel:layout"