]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Tunnel detail: Account for status section in peer index calculations
authorRoopesh Chander <roop@roopc.net>
Fri, 26 Oct 2018 13:30:19 +0000 (19:00 +0530)
committerRoopesh Chander <roop@roopc.net>
Sat, 27 Oct 2018 13:37:16 +0000 (19:07 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift

index f5a6936ca195f6f2c4fc264dac04e08a34f3c11d..c24828b2debc7e8e87704cc814c1dedb62776ffe 100644 (file)
@@ -103,9 +103,9 @@ extension TunnelDetailTableViewController {
             return interfaceData.filterFieldsWithValueOrControl(interfaceFields: interfaceFieldsBySection[section - 1]).count
         } else if ((numberOfPeers > 0) && (section < (1 + numberOfInterfaceSections + numberOfPeers * numberOfPeerSections))) {
             // Peer
-            let peerIndex = Int((section - numberOfInterfaceSections) / numberOfPeerSections)
+            let peerIndex = Int((section - 1 - numberOfInterfaceSections) / numberOfPeerSections)
             let peerData = tunnelViewModel.peersData[peerIndex]
-            let peerSectionIndex = (section - numberOfInterfaceSections) % numberOfPeerSections
+            let peerSectionIndex = (section - 1 - numberOfInterfaceSections) % numberOfPeerSections
             return peerData.filterFieldsWithValueOrControl(peerFields: peerFieldsBySection[peerSectionIndex]).count
         } else {
             // Delete tunnel