Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14174429
PostCommands.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
994 B
Subscribers
None
PostCommands.swift
View Options
import
SwiftUI
struct
PostCommands
:
Commands
{
@
ObservedObject
var
model
:
WriteFreelyModel
var
body
:
some
Commands
{
CommandMenu
(
"Post"
)
{
Group
{
Button
(
action
:
sendPostUrlToPasteboard
,
label
:
{
Text
(
"Copy Link To Published Post"
)
})
.
disabled
(
model
.
selectedPost
?.
status
==
PostStatus
.
local
.
rawValue
)
}
.
disabled
(
model
.
selectedPost
==
nil
||
!
model
.
account
.
isLoggedIn
)
}
}
private
func
sendPostUrlToPasteboard
()
{
guard
let
activePost
=
model
.
selectedPost
else
{
return
}
guard
let
postId
=
activePost
.
postId
else
{
return
}
guard
let
urlString
=
activePost
.
slug
!=
nil
?
"
\(
model
.
account
.
server
)
/
\((
activePost
.
collectionAlias
)
!
)
/
\((
activePost
.
slug
)
!
)
"
:
"
\(
model
.
account
.
server
)
/
\((
postId
))
"
else
{
return
}
NSPasteboard
.
general
.
clearContents
()
NSPasteboard
.
general
.
setString
(
urlString
,
forType
:
.
string
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Apr 2, 4:13 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3673131
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment