mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
updated addtohistory to fix stuff not adding or incrementing
remove format history
This commit is contained in:
@@ -51,24 +51,15 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addToHistory(_ host: Host) {
|
func addToHistory(_ host: Host) {
|
||||||
history.append(History(host: host, count: 1))
|
if history.last?.host == host {
|
||||||
formatHistory()
|
guard var lastOne = history.popLast() else { return }
|
||||||
saveHistory()
|
lastOne.count += 1
|
||||||
}
|
lastOne.lastConnect = .now
|
||||||
|
history.append(lastOne)
|
||||||
func formatHistory() {
|
} else {
|
||||||
var result: [History] = []
|
history.append(History(host: host, count: 1))
|
||||||
for item in history {
|
|
||||||
if result.last?.host == item.host {
|
|
||||||
guard var lastOne = result.popLast() else { continue }
|
|
||||||
lastOne.count += 1
|
|
||||||
lastOne.lastConnect = .now
|
|
||||||
result.append(lastOne)
|
|
||||||
} else {
|
|
||||||
result.append(History(host: item.host, count: 1))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
withAnimation { self.history = result }
|
saveHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveHistory() {
|
func saveHistory() {
|
||||||
|
|||||||
Reference in New Issue
Block a user