Add Scheduled Posts

This commit is contained in:
Otavio Cordeiro 2023-04-05 16:05:45 +02:00
parent 604cdb4fc0
commit 872043d4fc
2 changed files with 21 additions and 3 deletions

View File

@ -9,7 +9,8 @@ export interface NetworkRequestFactoryInterface {
content: string,
tags: string,
visibility: string,
blogID: string
blogID: string,
scheduledDate: string
): NetworkRequest
// Builds the configuration request, network request used to "log in"
@ -36,7 +37,8 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
content: string,
tags: string,
visibility: string,
blogID: string
blogID: string,
scheduledDate: string
): NetworkRequest {
const parameters = new URLSearchParams([
['h', 'entry'],
@ -52,6 +54,10 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
parameters.append('mp-destination', blogID)
}
if (scheduledDate.length > 0) {
parameters.append('published', scheduledDate)
}
tags
.split(",")
.forEach(value => {

View File

@ -152,7 +152,8 @@ export class PublishViewModel implements TagSuggestionDelegate {
this.content,
this.tags,
this.visibility,
this.selectedBlogID
this.selectedBlogID,
this.formattedScheduledDate().trim()
)
const result = await this.networkClient.run<PublishResponse>(
@ -209,6 +210,17 @@ export class PublishViewModel implements TagSuggestionDelegate {
return true
}
private formattedScheduledDate(): string {
const scheduledDate = new Date(this.scheduledDateWrappedValue)
const isInvalidDate = isNaN(scheduledDate.getTime())
if (isInvalidDate) {
return ''
}
return scheduledDate.toISOString()
}
// TagSuggestionDelegate
public tagSuggestionDidSelectTag(category: string) {