From 286f9717cbde78a8102c20a27bb089faf4ef4fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 20 Nov 2024 12:03:06 +0800 Subject: [PATCH] Fix logs --- Library/Network/CommandClient.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Library/Network/CommandClient.swift b/Library/Network/CommandClient.swift index bf235f7..02b76c0 100644 --- a/Library/Network/CommandClient.swift +++ b/Library/Network/CommandClient.swift @@ -171,12 +171,14 @@ public class CommandClient: ObservableObject { return } DispatchQueue.main.async { [self] in - if commandClient.logList.count >= commandClient.logMaxLines { - commandClient.logList.removeFirst() - } + var newLogList = commandClient.logList while messageList.hasNext() { - commandClient.logList.append(messageList.next()) + newLogList.append(messageList.next()) } + if newLogList.count >= commandClient.logMaxLines { + newLogList.removeSubrange(0...newLogList.count-commandClient.logMaxLines) + } + commandClient.logList = newLogList } }