Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10387187
HelpCommands.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
HelpCommands.swift
View Options
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
Details
Attached
Mime Type
text/x-c
Expires
Mon, Nov 25, 1:53 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3106498
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment