-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Custom Posts: Show "Post updated" notice #25576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -231,6 +231,10 @@ private extension CustomPostEditorViewController { | |||||
| guard let self else { return } | ||||||
| switch result { | ||||||
| case .published: | ||||||
| let postTitle = editorService.post?.title?.raw | ||||||
| let subtitle = (postTitle?.isEmpty == false) ? postTitle : nil | ||||||
| Notice(title: Strings.CustomPostNotice.postPublished, message: subtitle, feedbackType: .success) | ||||||
| .post() | ||||||
| completion() | ||||||
| case .cancelled: | ||||||
| break | ||||||
|
|
@@ -251,6 +255,12 @@ private extension CustomPostEditorViewController { | |||||
| func save(publish: Bool) async { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we only ever pass
Suggested change
|
||||||
| SVProgressHUD.show() | ||||||
|
|
||||||
| // Capture whether this is a brand-new post (not yet on the server) so the | ||||||
| // notice can distinguish "Draft saved" (just created) from "Post updated" | ||||||
| // (edited an existing post). Any save of an already-existing post — draft | ||||||
| // or published — reads as an update from the user's perspective. | ||||||
| let isNewPost = post == nil | ||||||
|
|
||||||
| do { | ||||||
| let data = try await editorViewController.getTitleAndContent() | ||||||
| try await editorService.save( | ||||||
|
|
@@ -260,6 +270,17 @@ private extension CustomPostEditorViewController { | |||||
|
|
||||||
| dismissHUDWithSuccess() | ||||||
|
|
||||||
| let title: String | ||||||
| if publish { | ||||||
| title = Strings.CustomPostNotice.postPublished | ||||||
| } else if isNewPost { | ||||||
| title = Strings.CustomPostNotice.draftSaved | ||||||
| } else { | ||||||
| title = Strings.CustomPostNotice.postUpdated | ||||||
| } | ||||||
| let subtitle = data.title.isEmpty ? nil : data.title | ||||||
| Notice(title: title, message: subtitle, feedbackType: .success).post() | ||||||
|
|
||||||
| if publish { | ||||||
| completion() | ||||||
| } | ||||||
|
|
@@ -280,3 +301,26 @@ extension CustomPostEditorViewController: CustomPostEditorServiceDelegate { | |||||
| return EditorContent(title: result.title, content: result.content) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private enum Strings { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a duplicate of the ViewModel strings? WDYT about extracting them into a higher-level shared |
||||||
| /// Localized titles for the success notices emitted when a custom post is | ||||||
| /// persisted to the server. Shared between the editor and the standalone | ||||||
| /// settings sheet (from the Custom Posts list). | ||||||
| enum CustomPostNotice { | ||||||
| static let draftSaved = NSLocalizedString( | ||||||
| "customPost.notice.draftSaved", | ||||||
| value: "Draft saved", | ||||||
| comment: "Success notice shown after a new draft custom post is created on the server." | ||||||
| ) | ||||||
| static let postUpdated = NSLocalizedString( | ||||||
| "customPost.notice.postUpdated", | ||||||
| value: "Post updated", | ||||||
| comment: "Success notice shown after an existing custom post is updated on the server." | ||||||
| ) | ||||||
| static let postPublished = NSLocalizedString( | ||||||
| "customPost.notice.postPublished", | ||||||
| value: "Post published", | ||||||
| comment: "Success notice shown after a custom post is published on the server." | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We repeat this pattern a bunch – I wonder if we could extract it to a helper? Could be the enum you use to consolidate the strings?