You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/04/20 09:13:18 UTC
[2/5] guacamole-client git commit: GUACAMOLE-549: Migrate recent
connection history to localStorageService.
GUACAMOLE-549: Migrate recent connection history to localStorageService.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/831e4e09
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/831e4e09
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/831e4e09
Branch: refs/heads/master
Commit: 831e4e0989a96f304d848f67de2fb178e8d736f6
Parents: 11d356a
Author: Michael Jumper <mj...@apache.org>
Authored: Wed Apr 18 20:43:04 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Apr 19 12:45:43 2018 -0700
----------------------------------------------------------------------
.../main/webapp/app/history/historyModule.js | 4 ++-
.../webapp/app/history/services/guacHistory.js | 33 +++++++++-----------
2 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/831e4e09/guacamole/src/main/webapp/app/history/historyModule.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/history/historyModule.js b/guacamole/src/main/webapp/app/history/historyModule.js
index ce2ab73..c7ec7e1 100644
--- a/guacamole/src/main/webapp/app/history/historyModule.js
+++ b/guacamole/src/main/webapp/app/history/historyModule.js
@@ -20,4 +20,6 @@
/**
* The module for code relating to connection history.
*/
-angular.module('history', []);
+angular.module('history', [
+ 'storage'
+]);
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/831e4e09/guacamole/src/main/webapp/app/history/services/guacHistory.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/history/services/guacHistory.js b/guacamole/src/main/webapp/app/history/services/guacHistory.js
index b47f9f5..74046ef 100644
--- a/guacamole/src/main/webapp/app/history/services/guacHistory.js
+++ b/guacamole/src/main/webapp/app/history/services/guacHistory.js
@@ -20,7 +20,14 @@
/**
* A service for reading and manipulating the Guacamole connection history.
*/
-angular.module('history').factory('guacHistory', ['HistoryEntry', function guacHistory(HistoryEntry) {
+angular.module('history').factory('guacHistory', ['$injector',
+ function guacHistory($injector) {
+
+ // Required types
+ var HistoryEntry = $injector.get('HistoryEntry');
+
+ // Required services
+ var localStorageService = $injector.get('localStorageService');
var service = {};
@@ -73,27 +80,15 @@ angular.module('history').factory('guacHistory', ['HistoryEntry', function guacH
if (service.recentConnections.length > IDEAL_LENGTH)
service.recentConnections.length = IDEAL_LENGTH;
- // Save updated history, ignore inability to use localStorage
- try {
- if (localStorage)
- localStorage.setItem(GUAC_HISTORY_STORAGE_KEY, JSON.stringify(service.recentConnections));
- }
- catch (ignore) {}
+ // Save updated history
+ localStorageService.setItem(GUAC_HISTORY_STORAGE_KEY, service.recentConnections);
};
- // Get stored connection history, ignore inability to use localStorage
- try {
-
- if (localStorage) {
- var storedHistory = JSON.parse(localStorage.getItem(GUAC_HISTORY_STORAGE_KEY) || "[]");
- if (storedHistory instanceof Array)
- service.recentConnections = storedHistory;
-
- }
-
- }
- catch (ignore) {}
+ // Init stored connection history from localStorage
+ var storedHistory = localStorageService.getItem(GUAC_HISTORY_STORAGE_KEY) || [];
+ if (storedHistory instanceof Array)
+ service.recentConnections = storedHistory;
return service;