mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
misc: connections tableview select
This commit is contained in:
@@ -214,6 +214,15 @@ struct ConnectionsTableView<Item: Hashable>: NSViewRepresentable {
|
|||||||
connHistorys[$0.id] = ($0.download, $0.upload)
|
connHistorys[$0.id] = ($0.download, $0.upload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selectedID: String? = {
|
||||||
|
let selectedRow = tableView.selectedRow
|
||||||
|
guard selectedRow >= 0, selectedRow < self.conns.count else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return self.conns[selectedRow].id
|
||||||
|
}()
|
||||||
|
|
||||||
|
|
||||||
guard let partialChanges = self.conns.applying(changes) else {
|
guard let partialChanges = self.conns.applying(changes) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -224,6 +233,10 @@ struct ConnectionsTableView<Item: Hashable>: NSViewRepresentable {
|
|||||||
})
|
})
|
||||||
|
|
||||||
tableView.reloadData(changes, indexs: indicesToReload)
|
tableView.reloadData(changes, indexs: indicesToReload)
|
||||||
|
|
||||||
|
if let index = self.conns.firstIndex(where: { $0.id == selectedID }) {
|
||||||
|
tableView.selectRowIndexes(.init(integer: index), byExtendingSelection: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user