swiftui-multiplatform/macOS/Navigation/ActivePostToolbarView.swift

153 lines
6.8 KiB
Swift
Raw Permalink Normal View History

import SwiftUI
struct ActivePostToolbarView: View {
@EnvironmentObject var model: WriteFreelyModel
@ObservedObject var activePost: WFAPost
@State private var isPresentingSharingServicePicker: Bool = false
@State private var selectedCollection: WFACollection?
@FetchRequest(
entity: WFACollection.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \WFACollection.title, ascending: true)]
) var collections: FetchedResults<WFACollection>
var body: some View {
HStack {
if model.account.isLoggedIn &&
activePost.status != PostStatus.local.rawValue &&
!(activePost.wasDeletedFromServer || activePost.hasNewerRemoteCopy) {
Section(header: Text("Move To:")) {
Picker(selection: $selectedCollection, label: Text("Move To…"), content: {
Text("\(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")")
.tag(nil as WFACollection?)
Divider()
ForEach(collections) { collection in
Text("\(collection.title)").tag(collection as WFACollection?)
}
})
}
}
PostEditorStatusToolbarView(post: activePost)
.frame(minWidth: 50, alignment: .center)
.layoutPriority(1)
.padding(.horizontal)
2023-07-23 11:19:52 +00:00
if activePost.status == PostStatus.edited.rawValue {
Button(action: {
model.editor.postToUpdate = activePost
model.updateFromServer(post: activePost)
model.selectedPost = nil
}, label: {
Image(systemName: "clock.arrow.circlepath")
.accessibilityLabel(Text("Revert post"))
.accessibilityHint(Text("Replace the edited post with the published version from the server"))
})
}
if activePost.status == PostStatus.local.rawValue {
Menu(content: {
Label("Publish To:", systemImage: "paperplane")
Divider()
Button(action: {
if model.account.isLoggedIn {
withAnimation {
activePost.collectionAlias = nil
publishPost(activePost)
}
} else {
openSettingsWindow()
}
}, label: {
Text("\(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")")
})
ForEach(collections) { collection in
Button(action: {
if model.account.isLoggedIn {
withAnimation {
activePost.collectionAlias = collection.alias
publishPost(activePost)
}
} else {
openSettingsWindow()
}
}, label: {
Text("\(collection.title)")
})
}
}, label: {
Label("Publish…", systemImage: "paperplane")
})
.disabled(model.selectedPost?.body.isEmpty ?? true)
.help("Publish the post to the web.\(model.account.isLoggedIn ? "" : " You must be logged in to do this.")") // swiftlint:disable:this line_length
} else {
HStack(spacing: 4) {
Button(
action: {
self.isPresentingSharingServicePicker = true
},
label: { Image(systemName: "square.and.arrow.up") }
)
.disabled(activePost.status == PostStatus.local.rawValue)
.help("Copy the post's URL to your Mac's pasteboard.")
Fix sharing picker and prep for v1.0 release of Mac app (#242) * Present sharing menu in background, not popover * Write logs to new post (#236) * Set the post editor font in the updateUIView method (#237) * Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method * Bump build number and update change log * Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log * Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. * Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. * Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Update change log * Set the post editor font in the updateUIView method commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Squashed commit of the following: commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method Also, wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Fix crash-on-launch when post list is empty (#241) * Apply a quarter-second delay to the dispatched call * Update change log * Fix nav-back bug when launching to last draft * Improve keyboard present/dismiss animations * Update change log and bump build number * Update change log and bump build number * Adjust initial frame size * Bump minimum version to macOS 12 * Bump version and build number * Bump build number * Bump build number (again?) * Undo initial sizing of settings window * Bump build number * Improve share button services Adds two useful services to which the user can share a post: copy-URL-to-pasteboard (custom), and add-to-reading-list (system-provided). * Improve initial layout of window
2023-02-12 16:14:26 +00:00
.background(
PostEditorSharingPicker(
isPresented: $isPresentingSharingServicePicker,
sharingItems: createPostUrl()
)
Fix sharing picker and prep for v1.0 release of Mac app (#242) * Present sharing menu in background, not popover * Write logs to new post (#236) * Set the post editor font in the updateUIView method (#237) * Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method * Bump build number and update change log * Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log * Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. * Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. * Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Update change log * Set the post editor font in the updateUIView method commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Squashed commit of the following: commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method Also, wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Fix crash-on-launch when post list is empty (#241) * Apply a quarter-second delay to the dispatched call * Update change log * Fix nav-back bug when launching to last draft * Improve keyboard present/dismiss animations * Update change log and bump build number * Update change log and bump build number * Adjust initial frame size * Bump minimum version to macOS 12 * Bump version and build number * Bump build number * Bump build number (again?) * Undo initial sizing of settings window * Bump build number * Improve share button services Adds two useful services to which the user can share a post: copy-URL-to-pasteboard (custom), and add-to-reading-list (system-provided). * Improve initial layout of window
2023-02-12 16:14:26 +00:00
)
Button(action: { publishPost(activePost) }, label: { Image(systemName: "paperplane") })
.disabled(activePost.body.isEmpty || activePost.status == PostStatus.published.rawValue)
.help("Publish the post to the web.\(model.account.isLoggedIn ? "" : " You must be logged in to do this.")") // swiftlint:disable:this line_length
}
}
}
.onAppear(perform: {
self.selectedCollection = collections.first { $0.alias == activePost.collectionAlias }
})
.onChange(of: selectedCollection, perform: { [selectedCollection] newCollection in
if activePost.collectionAlias == newCollection?.alias {
return
} else {
withAnimation {
activePost.collectionAlias = newCollection?.alias
model.move(post: activePost, from: selectedCollection, to: newCollection)
}
}
})
}
Fix sharing picker and prep for v1.0 release of Mac app (#242) * Present sharing menu in background, not popover * Write logs to new post (#236) * Set the post editor font in the updateUIView method (#237) * Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method * Bump build number and update change log * Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log * Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. * Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. * Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Update change log * Set the post editor font in the updateUIView method commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Squashed commit of the following: commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method Also, wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Fix crash-on-launch when post list is empty (#241) * Apply a quarter-second delay to the dispatched call * Update change log * Fix nav-back bug when launching to last draft * Improve keyboard present/dismiss animations * Update change log and bump build number * Update change log and bump build number * Adjust initial frame size * Bump minimum version to macOS 12 * Bump version and build number * Bump build number * Bump build number (again?) * Undo initial sizing of settings window * Bump build number * Improve share button services Adds two useful services to which the user can share a post: copy-URL-to-pasteboard (custom), and add-to-reading-list (system-provided). * Improve initial layout of window
2023-02-12 16:14:26 +00:00
private func createPostUrl() -> [NSURL] {
guard let postId = model.selectedPost?.postId else { return [] }
var urlString: String
if let postSlug = model.selectedPost?.slug,
let postCollectionAlias = model.selectedPost?.collectionAlias {
// This post is in a collection, so share the URL as baseURL/postSlug
let urls = collections.filter { $0.alias == postCollectionAlias }
let baseURL = urls.first?.url ?? "\(model.account.server)/\(postCollectionAlias)/"
urlString = "\(baseURL)\(postSlug)"
} else {
Fix sharing picker and prep for v1.0 release of Mac app (#242) * Present sharing menu in background, not popover * Write logs to new post (#236) * Set the post editor font in the updateUIView method (#237) * Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method * Bump build number and update change log * Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log * Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. * Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. * Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Update change log * Set the post editor font in the updateUIView method commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Squashed commit of the following: commit f9f94b48d3465f9bcfc47ea5e478cc1d66da9a4d Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 10:05:03 2022 -0500 Fix missed changes in change log commit 593cc8f1fa83feec923905a5004b885fa68e3003 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:46:36 2022 -0500 Bump patch version and build number commit e0f752e6a4828c3d09649da8f9fe5a1902a2f137 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 2f7163dff4ca9d3279c553190b78d2d47277a03e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:43:00 2022 -0500 Update change log commit e42436676d2ce2e70e96a18364cb8127a5921cb5 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:40:27 2022 -0500 Squashed commit of the following: commit 804255b1da2820d9c5a8850d31ae80e556afccd5 Merge: a799fd6 d46eb63 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 15:28:10 2022 -0500 Merge branch 'main' into fix-crash-on-launch-tmp-no-nav commit a799fd62102f327d928b138c90a6fd5b7862d5b6 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:34 2022 -0500 Bump build number and update change log commit b81276d6293560f7a6d02e5f80197c04949106df Author: Angelo Stavrow <angelo@droppedbits.com> Date: Sun Dec 18 08:16:16 2022 -0500 Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. commit d7c03b9d2d1165a9b34d96a4e5350214211c1643 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:26:18 2022 -0500 Revert "Set the post editor font in the updateUIView method (#237)" (#240) This reverts commit d46eb639addb4aa9fb4bcbe267a633ef988d2862. commit 43b53c6e456d7b59e7363d1591363c58a246b4be Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:25:36 2022 -0500 Revert "Don't navigate to new/last draft on launch (#238)" (#239) This reverts commit f4ba5f9a901e37b7f47d620f88fc43ca49a90abe. commit 34546f994efaa77d21ff51aad84201f2dbbffd3e Author: Angelo Stavrow <angelo@droppedbits.com> Date: Thu Dec 29 09:06:31 2022 -0500 Don't navigate to new/last draft on launch (#238) * Only navigate to new/last draft on launch on macOS This is causing the app to crash on launch when there are no existing posts, so we’re going to remove it for now while we investigate. * Bump build number and update change log commit bc3bc23308ec3deeb78530715e2b6ef745ec93f2 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:47:37 2022 -0500 Bump build number and update change log commit 7703e925b77bd8eac38d1bdcbe45ff6f1a5e0f23 Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:41 2022 -0500 Set the font in the updateUIView method commit 6e60e0ded5d9f1ffe48a3dd0201f41371ddff5ff Author: Angelo Stavrow <angelo@droppedbits.com> Date: Mon Dec 12 07:40:11 2022 -0500 Wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Set the font in the updateUIView method Also, wrap becomeFirstResponder in async dispatch This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects. * Fix crash-on-launch when post list is empty (#241) * Apply a quarter-second delay to the dispatched call * Update change log * Fix nav-back bug when launching to last draft * Improve keyboard present/dismiss animations * Update change log and bump build number * Update change log and bump build number * Adjust initial frame size * Bump minimum version to macOS 12 * Bump version and build number * Bump build number * Bump build number (again?) * Undo initial sizing of settings window * Bump build number * Improve share button services Adds two useful services to which the user can share a post: copy-URL-to-pasteboard (custom), and add-to-reading-list (system-provided). * Improve initial layout of window
2023-02-12 16:14:26 +00:00
// This is a draft post, so share the URL as server/postID
urlString = "\(model.account.server)/\(postId)"
}
guard let data = URL(string: urlString) else { return [] }
return [data as NSURL]
}
private func publishPost(_ post: WFAPost) {
if post != model.selectedPost {
return
}
DispatchQueue.main.async {
LocalStorageManager.standard.saveContext()
model.publish(post: post)
}
2023-07-23 11:19:52 +00:00
model.editor.setInitialValues(for: post)
}
private func openSettingsWindow() {
guard let menuItem = NSApplication.shared.mainMenu?.item(at: 0)?.submenu?.item(at: 2) else { return }
NSApplication.shared.sendAction(menuItem.action!, to: menuItem.target, from: nil)
}
}