Repository: syncthing/syncthing (language: go)

Issue:
Shared With list ends with comma on 1 device
## Versions

- Syncthing v1.23.6, macOS (64-bit ARM)
- Chrome 114.0.5735.198
 
## 2 old possibly related issues:

- https://github.com/syncthing/syncthing/issues/2626
- https://github.com/syncthing/syncthing/issues/362

I don't think this necessarily _began_ with 1.23.6 but I happened to notice it this morning when I upgraded my 2 systems. The "Shared With" line on my main computer has the name of the other Mac, but ends with a lone comma:

<img width="570" alt="screenshot_gEuS0Fdx_gh" src="https://github.com/syncthing/syncthing/assets/1992842/65577ed9-2048-41b8-97fa-16aaf562f21e">

I checked the config.xml and nothing jumped out at me as being incorrect / duplicate etc. I even diff'ed it against the other peer, and aside from the machine IDs, they are identical. Strangely, the other machine does not display this comma. Could it have to do with the hyphen in the computer name?



Discussion / hints:
This is probably caused by https://github.com/syncthing/syncthing/pull/8923.

I've managed to reproduce the following way:

1. Add a new folder on Device 1 and share it with Device 2.
2. On Device 2, accept the folder.
3. The "shared with" list now displays a trailing comma on Device 2 (but not on Device 1).
Yeah... When iterating over the list, if the last device ID is the local device, there'll be a spurious comma.

Fix patch:
diff --git a/gui/default/index.html b/gui/default/index.html
index e5c7db1f2b7..57cd558a794 100644
--- a/gui/default/index.html
+++ b/gui/default/index.html
@@ -555,8 +555,8 @@ <h4 class="panel-title">
                       <tr>
                         <th><span class="fas fa-fw fa-share-alt"></span>&nbsp;<span translate>Shared With</span></th>
                         <td class="text-right no-overflow-ellipse word-break-all">
-                          <span ng-repeat="device in folder.devices">
-                            <span ng-if="device.deviceID != myID" ng-switch="completion[device.deviceID][folder.id].remoteState">
+                          <span ng-repeat="device in otherDevices(folder.devices)">
+                            <span ng-switch="completion[device.deviceID][folder.id].remoteState">
                               <span ng-switch-when="notSharing" data-original-title="{{'The remote device has not accepted sharing this folder.' | translate}}" tooltip>{{deviceName(devices[device.deviceID])}}<sup>1</sup><span ng-if="!$last">,</span></span>
                               <span ng-switch-when="paused" data-original-title="{{'The remote device has paused this folder.' | translate}}" tooltip>{{deviceName(devices[device.deviceID])}}<sup>2</sup><span ng-if="!$last">,</span></span>
                               <span ng-switch-default>{{deviceName(devices[device.deviceID])}}<span ng-if="!$last">,</span></span>
diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js
index 208cb5617f4..6a77e514ecc 100755
--- a/gui/default/syncthing/core/syncthingController.js
+++ b/gui/default/syncthing/core/syncthingController.js
@@ -1892,8 +1892,11 @@ angular.module('syncthing.core')
             }
         };
 
-        $scope.otherDevices = function () {
-            return $scope.deviceList().filter(function (n) {
+        $scope.otherDevices = function (devices) {
+            if (devices === undefined) {
+                devices = $scope.deviceList();
+            }
+            return devices.filter(function (n) {
                 return n.deviceID !== $scope.myID;
             });
         };


Test patch: