Skip to content
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

Fix remote post update params diff #770

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions Sources/WordPressKit/Models/RemotePostParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ extension RemotePostCreateParameters {
if previous.authorID != authorID {
changes.authorID = authorID
}
if previous.title != title {
changes.title = title
if (previous.title ?? "") != (title ?? "") {
changes.title = (title ?? "")
}
if previous.content != content {
changes.content = content
if (previous.content ?? "") != (content ?? "") {
changes.content = (content ?? "")
}
if previous.password != password {
changes.password = password
}
if previous.excerpt != excerpt {
changes.excerpt = excerpt
if (previous.excerpt ?? "") != (excerpt ?? "") {
changes.excerpt = (excerpt ?? "")
}
if previous.slug != slug {
changes.slug = slug
if (previous.slug ?? "") != (slug ?? "") {
changes.slug = (slug ?? "")
}
if previous.featuredImageID != featuredImageID {
changes.featuredImageID = featuredImageID
Expand Down Expand Up @@ -227,7 +227,14 @@ struct RemotePostUpdateParametersWordPressComEncoder: Encodable {
try container.encodeIfPresent(parameters.password, forKey: .password)
try container.encodeIfPresent(parameters.excerpt, forKey: .excerpt)
try container.encodeIfPresent(parameters.slug, forKey: .slug)
try container.encodeIfPresent(parameters.featuredImageID, forKey: .featuredImageID)
if let value = parameters.featuredImageID {
if let featuredImageID = value {
try container.encode(parameters.featuredImageID, forKey: .featuredImageID)
} else {
// Passing `null` doesn't work.
try container.encode("", forKey: .featuredImageID)
}
}

// Pages
if let parentPageID = parameters.parentPageID {
Expand Down Expand Up @@ -316,7 +323,14 @@ struct RemotePostUpdateParametersXMLRPCEncoder: Encodable {
try container.encodeIfPresent(parameters.password, forKey: .password)
try container.encodeIfPresent(parameters.excerpt, forKey: .excerpt)
try container.encodeIfPresent(parameters.slug, forKey: .slug)
try container.encodeIfPresent(parameters.featuredImageID, forKey: .featuredImageID)
if let value = parameters.featuredImageID {
if let featuredImageID = value {
try container.encode(parameters.featuredImageID, forKey: .featuredImageID)
} else {
// Passing `null` doesn't work.
try container.encode("", forKey: .featuredImageID)
}
}

// Pages
if let parentPageID = parameters.parentPageID {
Expand Down