mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-278: Simply do not track connection history if localStorage unavailable.
This commit is contained in:
		| @@ -86,6 +86,10 @@ GuacamoleHistory = new (function() { | |||||||
|      */ |      */ | ||||||
|     this.update = function(id, thumbnail) { |     this.update = function(id, thumbnail) { | ||||||
|  |  | ||||||
|  |         /* Do nothing if localStorage not present */ | ||||||
|  |         if (!localStorage) | ||||||
|  |             return; | ||||||
|  |  | ||||||
|         // Create updated entry |         // Create updated entry | ||||||
|         var entry = new GuacamoleHistory.Entry( |         var entry = new GuacamoleHistory.Entry( | ||||||
|             id, |             id, | ||||||
| @@ -97,8 +101,11 @@ GuacamoleHistory = new (function() { | |||||||
|         history[id] = entry; |         history[id] = entry; | ||||||
|         truncate(); |         truncate(); | ||||||
|  |  | ||||||
|         // Save updated history |         // Save updated history, ignore inability to use localStorage | ||||||
|  |         try { | ||||||
|             localStorage.setItem("GUAC_HISTORY", JSON.stringify(history)); |             localStorage.setItem("GUAC_HISTORY", JSON.stringify(history)); | ||||||
|  |         } | ||||||
|  |         catch (ignore) {} | ||||||
|  |  | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
| @@ -107,9 +114,18 @@ GuacamoleHistory = new (function() { | |||||||
|      */ |      */ | ||||||
|     this.reload = function() { |     this.reload = function() { | ||||||
|  |  | ||||||
|         // Get old and new for comparison |         /* Do nothing if localStorage not present */ | ||||||
|  |         if (!localStorage) | ||||||
|  |             return; | ||||||
|  |  | ||||||
|  |         // Get old and new for comparison, ignore inability to use localStorage | ||||||
|         var old_history = history; |         var old_history = history; | ||||||
|  |         try { | ||||||
|             var new_history = JSON.parse(localStorage.getItem("GUAC_HISTORY") || "{}"); |             var new_history = JSON.parse(localStorage.getItem("GUAC_HISTORY") || "{}"); | ||||||
|  |         } | ||||||
|  |         catch (ignore) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // Update history |         // Update history | ||||||
|         history = new_history; |         history = new_history; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user