mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Re-enable launch-to-last-draft policy
This commit is contained in:
parent
3c1e04e3bf
commit
ff7e7c3c0e
@ -49,7 +49,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
#else
|
||||
PostListView(selectedCollection: nil, showAllPosts: false)
|
||||
PostListView(selectedCollection: model.selectedCollection, showAllPosts: model.showAllPosts)
|
||||
#endif
|
||||
|
||||
Text("Select a post, or create a new local draft.")
|
||||
|
@ -125,6 +125,10 @@ struct PostListView: View {
|
||||
.overlay(Divider(), alignment: .top)
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.onAppear {
|
||||
model.selectedCollection = selectedCollection
|
||||
model.showAllPosts = showAllPosts
|
||||
}
|
||||
#else
|
||||
PostListFilteredView(
|
||||
collection: selectedCollection,
|
||||
|
@ -34,17 +34,19 @@ struct WriteFreely_MultiPlatformApp: App {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.onAppear(perform: {
|
||||
// if model.editor.showAllPostsFlag {
|
||||
// DispatchQueue.main.async {
|
||||
// self.model.selectedCollection = nil
|
||||
// self.model.showAllPosts = true
|
||||
// }
|
||||
// } else {
|
||||
// DispatchQueue.main.async {
|
||||
// self.model.selectedCollection = model.editor.fetchSelectedCollectionFromAppStorage()
|
||||
// self.model.showAllPosts = false
|
||||
// }
|
||||
// }
|
||||
if model.editor.showAllPostsFlag {
|
||||
DispatchQueue.main.async {
|
||||
self.model.selectedCollection = nil
|
||||
self.model.showAllPosts = true
|
||||
showLastDraftOrCreateNewLocalPost()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.model.selectedCollection = model.editor.fetchSelectedCollectionFromAppStorage()
|
||||
self.model.showAllPosts = false
|
||||
showLastDraftOrCreateNewLocalPost()
|
||||
}
|
||||
}
|
||||
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
// if model.editor.lastDraftURL != nil {
|
||||
// self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
|
||||
@ -128,6 +130,14 @@ struct WriteFreely_MultiPlatformApp: App {
|
||||
#endif
|
||||
}
|
||||
|
||||
private func showLastDraftOrCreateNewLocalPost() {
|
||||
if model.editor.lastDraftURL != nil {
|
||||
self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
|
||||
} else {
|
||||
createNewLocalPost()
|
||||
}
|
||||
}
|
||||
|
||||
private func createNewLocalPost() {
|
||||
withAnimation {
|
||||
// Un-set the currently selected post
|
||||
|
Loading…
Reference in New Issue
Block a user