Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14177084
Post.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
Post.swift
View Options
import
Foundation
import
WriteFreely
enum
PostStatus
{
case
local
case
edited
case
published
}
class
Post
:
Identifiable
,
ObservableObject
,
Hashable
{
@
Published
var
wfPost
:
WFPost
@
Published
var
status
:
PostStatus
@
Published
var
collection
:
WFACollection
?
@
Published
var
hasNewerRemoteCopy
:
Bool
=
false
let
id
=
UUID
()
init
(
title
:
String
=
"Title"
,
body
:
String
=
"Write your post here..."
,
createdDate
:
Date
=
Date
(),
status
:
PostStatus
=
.
draft
,
collection
:
WFACollection
?
=
nil
)
{
self
.
wfPost
=
WFPost
(
body
:
body
,
title
:
title
,
createdDate
:
createdDate
)
self
.
status
=
status
self
.
collection
=
collection
}
convenience
init
(
wfPost
:
WFPost
,
in
collection
:
WFACollection
?
=
nil
)
{
self
.
init
(
title
:
wfPost
.
title
??
""
,
body
:
wfPost
.
body
,
createdDate
:
wfPost
.
createdDate
??
Date
(),
status
:
.
published
,
collection
:
collection
)
self
.
wfPost
=
wfPost
}
}
extension
Post
{
static
func
==
(
lhs
:
Post
,
rhs
:
Post
)
->
Bool
{
return
lhs
.
id
==
rhs
.
id
}
func
hash
(
into
hasher
:
inout
Hasher
)
{
hasher
.
combine
(
id
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Thu, Apr 2, 5:40 AM (15 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3678483
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment