Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions KMReader/Features/Settings/SettingsLogsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,25 @@ struct SettingsLogsView: View {
.refreshable {
await loadLogs()
}
#if os(iOS)
#if os(iOS) || os(macOS)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ShareLink(item: exportLogs()) {
Label(String(localized: "Share"), systemImage: "square.and.arrow.up")
Menu {
ShareLink(item: exportLogs()) {
Label(String(localized: "Share"), systemImage: "square.and.arrow.up")
}

Divider()

Button(role: .destructive) {
Task {
await clearLogs()
}
} label: {
Label(String(localized: "Clear All"), systemImage: "trash")
}
} label: {
Image(systemName: "ellipsis")
}
}
}
Expand Down Expand Up @@ -254,6 +268,11 @@ struct SettingsLogsView: View {
pagination.items.map { formatEntry($0) }.joined(separator: "\n")
}

private func clearLogs() async {
await LogStore.shared.clear()
await loadLogs()
}

private func formatEntry(_ entry: LogStore.LogEntry) -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
Expand Down