@@ -34,17 +34,19 @@ struct WriteFreely_MultiPlatformApp: App {
3434 WindowGroup {
3535 ContentView ( )
3636 . onAppear ( perform: {
37- // if model.editor.showAllPostsFlag {
38- // DispatchQueue.main.async {
39- // self.model.selectedCollection = nil
40- // self.model.showAllPosts = true
41- // }
42- // } else {
43- // DispatchQueue.main.async {
44- // self.model.selectedCollection = model.editor.fetchSelectedCollectionFromAppStorage()
45- // self.model.showAllPosts = false
46- // }
47- // }
37+ if model. editor. showAllPostsFlag {
38+ DispatchQueue . main. async {
39+ self . model. selectedCollection = nil
40+ self . model. showAllPosts = true
41+ showLastDraftOrCreateNewLocalPost ( )
42+ }
43+ } else {
44+ DispatchQueue . main. async {
45+ self . model. selectedCollection = model. editor. fetchSelectedCollectionFromAppStorage ( )
46+ self . model. showAllPosts = false
47+ showLastDraftOrCreateNewLocalPost ( )
48+ }
49+ }
4850// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
4951// if model.editor.lastDraftURL != nil {
5052// self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
@@ -128,6 +130,14 @@ struct WriteFreely_MultiPlatformApp: App {
128130 #endif
129131 }
130132
133+ private func showLastDraftOrCreateNewLocalPost( ) {
134+ if model. editor. lastDraftURL != nil {
135+ self . model. selectedPost = model. editor. fetchLastDraftFromAppStorage ( )
136+ } else {
137+ createNewLocalPost ( )
138+ }
139+ }
140+
131141 private func createNewLocalPost( ) {
132142 withAnimation {
133143 // Un-set the currently selected post
0 commit comments