From 896b857fc45b07bdbc1a81b1ba362863b5d2747f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Fri, 25 Oct 2024 22:22:12 +0200 Subject: [PATCH] fix(gui): hide lists with [object Object] in advanced settings (#9743) As discussed in https://github.com/syncthing/syncthing/pull/9175#discussion_r1730431703, entries in advanced settings are unusable if they are comprised of a list of objects. It just displays `[object Object], [object Object], [object Object]`, e.g. for the devices a folder is shared with. Filter out these config elements by detecting an array whose members are not all strings or numbers, and setting them to `skip` type. Fix some unnecessary repetition in calling `inputTypeFor()`, since it is already cached in the `ng-init` directive. --- gui/default/syncthing/core/syncthingController.js | 5 +++++ .../syncthing/settings/advancedSettingsModalView.html | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 517663d94..6f11e81e3 100644 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -3343,6 +3343,11 @@ angular.module('syncthing.core') return 'checkbox'; } if (value instanceof Array) { + if (value.some(function (element) { + return typeof element !== 'number' && typeof element !== 'string'; + })) { + return 'skip'; + } return 'list'; } if (typeof value === 'object') { diff --git a/gui/default/syncthing/settings/advancedSettingsModalView.html b/gui/default/syncthing/settings/advancedSettingsModalView.html index 37312e053..ae92c0150 100644 --- a/gui/default/syncthing/settings/advancedSettingsModalView.html +++ b/gui/default/syncthing/settings/advancedSettingsModalView.html @@ -18,8 +18,8 @@
- - + +