Extract PostStatus enum to own file and add raw Int32 values

This commit is contained in:
Angelo Stavrow 2020-09-08 11:27:57 -04:00
parent 5436764e4f
commit 169e3684a6
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
5 changed files with 15 additions and 8 deletions

View File

@ -1,12 +1,6 @@
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

View File

@ -0,0 +1,7 @@
import Foundation
enum PostStatus: Int32 {
case local = 0
case edited = 1
case published = 2
}

View File

@ -235,7 +235,7 @@ private extension WriteFreelyModel {
managedPost.title = fetchedPost.title
managedPost.body = fetchedPost.body
managedPost.collectionAlias = fetchedPost.collectionAlias
managedPost.status = 2 // 0 = local, 1 = edited, 2 = published
managedPost.status = PostStatus.published.rawValue // 0 = local, 1 = edited, 2 = published
}
DispatchQueue.main.async {
self.store.updateStore(with: fetchedPostsArray)

View File

@ -139,7 +139,7 @@ struct PostListView: View {
managedPost.createdDate = post.wfPost.createdDate
managedPost.title = post.wfPost.title
managedPost.body = post.wfPost.body
managedPost.status = 0
managedPost.status = PostStatus.local.rawValue
DispatchQueue.main.async {
model.store.add(post)
PersistenceManager().saveContext()

View File

@ -56,6 +56,8 @@
17B996D92502D23E0017B536 /* WFAPost+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B996D62502D23E0017B536 /* WFAPost+CoreDataClass.swift */; };
17B996DA2502D23E0017B536 /* WFAPost+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B996D72502D23E0017B536 /* WFAPost+CoreDataProperties.swift */; };
17B996DB2502D23E0017B536 /* WFAPost+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B996D72502D23E0017B536 /* WFAPost+CoreDataProperties.swift */; };
17C42E622507D8E600072984 /* PostStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C42E612507D8E600072984 /* PostStatus.swift */; };
17C42E632507D8E600072984 /* PostStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C42E612507D8E600072984 /* PostStatus.swift */; };
17D435E824E3128F0036B539 /* PreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D435E724E3128F0036B539 /* PreferencesModel.swift */; };
17D435E924E3128F0036B539 /* PreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D435E724E3128F0036B539 /* PreferencesModel.swift */; };
17DF329D24C87D3500BCE2E3 /* Tests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF329C24C87D3500BCE2E3 /* Tests_iOS.swift */; };
@ -117,6 +119,7 @@
17A5389124DDED0000DEFF9A /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = "<group>"; };
17B996D62502D23E0017B536 /* WFAPost+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WFAPost+CoreDataClass.swift"; sourceTree = SOURCE_ROOT; };
17B996D72502D23E0017B536 /* WFAPost+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WFAPost+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
17C42E612507D8E600072984 /* PostStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostStatus.swift; sourceTree = "<group>"; };
17D435E724E3128F0036B539 /* PreferencesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesModel.swift; sourceTree = "<group>"; };
17DF328124C87D3300BCE2E3 /* WriteFreely_MultiPlatformApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WriteFreely_MultiPlatformApp.swift; sourceTree = "<group>"; };
17DF328224C87D3300BCE2E3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -209,6 +212,7 @@
17B996D72502D23E0017B536 /* WFAPost+CoreDataProperties.swift */,
1756AE6A24CB1E4B00FD7257 /* Post.swift */,
171BFDF624D49FD400888236 /* PostCollection.swift */,
17C42E612507D8E600072984 /* PostStatus.swift */,
1756AE6D24CB255B00FD7257 /* PostStore.swift */,
174D313124EC2831006CA9EE /* WriteFreelyModel.swift */,
1756DBB524FED3A400207AB8 /* LocalStorageModel.xcdatamodeld */,
@ -570,6 +574,7 @@
buildActionMask = 2147483647;
files = (
17DF32AC24C87D3500BCE2E3 /* ContentView.swift in Sources */,
17C42E622507D8E600072984 /* PostStatus.swift in Sources */,
1756DBBA24FED45500207AB8 /* PersistenceManager.swift in Sources */,
1756AE8124CB844500FD7257 /* View+Keyboard.swift in Sources */,
17120DAC24E1B99F002B9F6C /* AccountLoginView.swift in Sources */,
@ -633,6 +638,7 @@
17A5388F24DDEC7400DEFF9A /* AccountView.swift in Sources */,
1756AE7524CB26FA00FD7257 /* PostCellView.swift in Sources */,
17A5388824DDA31F00DEFF9A /* MacAccountView.swift in Sources */,
17C42E632507D8E600072984 /* PostStatus.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};