Page MenuHomeMusing Studio

HelpCommands.swift
No OneTemporary

HelpCommands.swift

import SwiftUI
struct HelpCommands: Commands {
@ObservedObject var model: WriteFreelyModel
private let logger = Logging(for: String(describing: PostCommands.self))
var body: some Commands {
CommandGroup(replacing: .help) {
Button("Visit Support Forum") {
NSWorkspace().open(model.helpURL)
}
Button(action: createLogsPost, label: { Text("Generate Log for Support") })
}
}
private func createLogsPost() {
logger.log("Generating local log post...")
// Show the spinner going in the post list
model.isProcessingRequest = true
DispatchQueue.main.asyncAfter(deadline: .now()) {
// Unset selected post and collection and navigate to local drafts.
self.model.selectedPost = nil
self.model.selectedCollection = nil
self.model.showAllPosts = false
// Create the new log post.
let newLogPost = model.editor.generateNewLocalPost(withFont: 2)
newLogPost.title = "Logs For Support"
var postBody: [String] = [
"WriteFreely-Multiplatform v\(Bundle.main.appMarketingVersion) (\(Bundle.main.appBuildVersion))",
"Generated \(Date())",
""
]
postBody.append(contentsOf: logger.fetchLogs())
newLogPost.body = postBody.joined(separator: "\n")
// Hide the spinner in the post list and set the log post as active
self.model.isProcessingRequest = false
self.model.selectedPost = newLogPost
logger.log("Generated local log post.")
}
}
}

File Metadata

Mime Type
text/x-c
Expires
Mon, Nov 25, 1:53 AM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3106498

Event Timeline