mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
On launch, either restore lastDraft or go to new blank post
This commit is contained in:
parent
9daf553391
commit
bc77fa14af
@ -57,6 +57,32 @@ class WriteFreelyModel: ObservableObject {
|
||||
self.fetchUserCollections()
|
||||
self.fetchUserPosts()
|
||||
}
|
||||
|
||||
if let lastDraft = self.editor.fetchLastDraft() {
|
||||
self.selectedPost = lastDraft
|
||||
} else {
|
||||
let managedPost = WFAPost(context: LocalStorageManager.persistentContainer.viewContext)
|
||||
managedPost.createdDate = Date()
|
||||
managedPost.title = ""
|
||||
managedPost.body = ""
|
||||
managedPost.status = PostStatus.local.rawValue
|
||||
switch self.preferences.font {
|
||||
case 1:
|
||||
managedPost.appearance = "sans"
|
||||
case 2:
|
||||
managedPost.appearance = "wrap"
|
||||
default:
|
||||
managedPost.appearance = "serif"
|
||||
}
|
||||
if let languageCode = Locale.current.languageCode {
|
||||
managedPost.language = languageCode
|
||||
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
LocalStorageManager().saveContext()
|
||||
}
|
||||
self.selectedPost = managedPost
|
||||
}
|
||||
}
|
||||
|
||||
monitor.pathUpdateHandler = { path in
|
||||
|
@ -7,12 +7,12 @@
|
||||
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
Loading…
Reference in New Issue
Block a user