Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14177137
PostStore.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
657 B
Subscribers
None
PostStore.swift
View Options
import
Foundation
struct
PostStore
{
var
posts
:
[
Post
]
init
(
posts
:
[
Post
]
=
[])
{
self
.
posts
=
posts
}
mutating
func
add
(
_
post
:
Post
)
{
posts
.
append
(
post
)
}
mutating
func
purgeAllPosts
()
{
posts
=
[]
}
mutating
func
update
(
_
post
:
Post
)
{
// Find the local copy in the store
let
localCopy
=
posts
.
first
(
where
:
{
$0
.
id
==
post
.
id
})
// If there's a local copy, update the updatedDate property of its WFPost
if
let
localCopy
=
localCopy
{
localCopy
.
wfPost
.
updatedDate
=
Date
()
}
else
{
print
(
"local copy not found"
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Apr 2, 5:41 AM (10 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3679319
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment