mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
fix crash when deleting a recent
make history ordered correctly
This commit is contained in:
@@ -51,6 +51,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
||||
}
|
||||
|
||||
func addToHistory(_ host: Host) {
|
||||
history = [History(host: host, count: 1)] + history
|
||||
history.append(History(host: host, count: 1))
|
||||
formatHistory()
|
||||
saveHistory()
|
||||
|
||||
@@ -13,11 +13,12 @@ struct RecentsView: View {
|
||||
|
||||
@State var historyCount: Int = 1
|
||||
|
||||
// @State var displayedHistory: [History] = []
|
||||
|
||||
var body: some View {
|
||||
if !hostsManager.history.isEmpty {
|
||||
Section("Recents") {
|
||||
ForEach(0..<historyCount, id: \.self) { index in
|
||||
let history = hostsManager.history[index]
|
||||
ForEach(hostsManager.history.reversed().prefix(historyCount)) { history in
|
||||
NavigationLink() {
|
||||
ConnectionView(
|
||||
handler: SSHHandler(
|
||||
@@ -47,7 +48,7 @@ struct RecentsView: View {
|
||||
.tint(.red)
|
||||
}
|
||||
}
|
||||
if historyCount <= hostsManager.history.count {
|
||||
// if historyCount <= hostsManager.history.count {
|
||||
HStack(alignment: .center) {
|
||||
Button() {
|
||||
var increment = 2
|
||||
@@ -86,7 +87,7 @@ struct RecentsView: View {
|
||||
.buttonStyle(.plain)
|
||||
.disabled(historyCount == 0)
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
.transition(.opacity)
|
||||
|
||||
Reference in New Issue
Block a user