necouchman commented on code in PR #1135:
URL: https://github.com/apache/guacamole-client/pull/1135#discussion_r2602359538
##########
guacamole/src/main/frontend/src/app/settings/services/preferenceService.js:
##########
@@ -200,7 +217,11 @@ angular.module('settings').provider('preferenceService',
['$injector',
* Persists the current values of all preferences, if possible.
*/
service.save = function save() {
- localStorageService.setItem(GUAC_PREFERENCES_STORAGE_KEY,
service.preferences);
+ // Save other preferences into localStorage
+ var prefsClone = angular.copy(service.preferences);
+ delete prefsClone.inputMethod;
+
+ localStorageService.setItem(GUAC_PREFERENCES_STORAGE_KEY,
prefsClone);
Review Comment:
Please re-align the indentation with the rest of the code.
##########
guacamole/src/main/frontend/src/app/settings/services/preferenceService.js:
##########
@@ -78,6 +78,15 @@ angular.module('settings').provider('preferenceService',
['$injector',
};
+ // ------------------------------------------------------------------
+ // Cookie helpers
+ // ------------------------------------------------------------------
+ function getCookie(name) {
+ var match = document.cookie.match(new RegExp("(^| )" + name +
"=([^;]+)"));
+ return match ? decodeURIComponent(match[2]) : null;
+ }
+ // ------------------------------------------------------------------
Review Comment:
No need to bracket this function with this empty comment line.
##########
guacamole/src/main/frontend/src/app/settings/services/preferenceService.js:
##########
@@ -78,6 +78,15 @@ angular.module('settings').provider('preferenceService',
['$injector',
};
+ // ------------------------------------------------------------------
+ // Cookie helpers
+ // ------------------------------------------------------------------
Review Comment:
Your comment styles should conform to the other styles used throughout the
code. In general we tend to use:
```
/**
* Some comment here.
*/
```
for multi-line comments.
##########
guacamole/src/main/frontend/src/app/settings/services/preferenceService.js:
##########
@@ -168,8 +177,16 @@ angular.module('settings').provider('preferenceService',
['$injector',
// Get stored preferences from localStorage
var storedPreferences =
localStorageServiceProvider.getItem(GUAC_PREFERENCES_STORAGE_KEY);
- if (storedPreferences)
+ if (storedPreferences) {
+ delete storedPreferences.inputMethod;
angular.extend(provider.preferences, storedPreferences);
+ }
+
+ // Load inputMethod from cookie - ONLY READ, DON'T WRITE
+ var cookieInputMethod = getCookie("GUAC_INPUT_METHOD");
+ if (cookieInputMethod) {
+ provider.preferences.inputMethod = cookieInputMethod;
+ }
Review Comment:
Please re-align the indentation with the rest of the code.
##########
guacamole/src/main/frontend/src/app/settings/services/preferenceService.js:
##########
@@ -133,7 +142,7 @@ angular.module('settings').provider('preferenceService',
['$injector',
*
* @type String
*/
- inputMethod : inputMethods.NONE,
+ inputMethod: inputMethods.TEXT,
Review Comment:
Why the extra indentation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]