mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Handle errors updating elastic when saving pages
This commit is contained in:
parent
7fe3fc75c0
commit
85cbd4e9d0
2 changed files with 37 additions and 10 deletions
8
apple/OmnivoreKit/Sources/Views/SyncingIcon.swift
Normal file
8
apple/OmnivoreKit/Sources/Views/SyncingIcon.swift
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
//
|
||||||
|
// File.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Jackson Harper on 6/5/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
import { PubsubClient } from '../datalayer/pubsub'
|
import { PubsubClient } from '../datalayer/pubsub'
|
||||||
import { homePageURL } from '../env'
|
import { homePageURL } from '../env'
|
||||||
import { Maybe, SavePageInput, SaveResult } from '../generated/graphql'
|
import {
|
||||||
|
Maybe,
|
||||||
|
SaveErrorCode,
|
||||||
|
SavePageInput,
|
||||||
|
SaveResult,
|
||||||
|
} from '../generated/graphql'
|
||||||
import { DataModels } from '../resolvers/types'
|
import { DataModels } from '../resolvers/types'
|
||||||
import { generateSlug, stringToHash, validatedDate } from '../utils/helpers'
|
import { generateSlug, stringToHash, validatedDate } from '../utils/helpers'
|
||||||
import { parsePreparedContent } from '../utils/parser'
|
import { parsePreparedContent } from '../utils/parser'
|
||||||
|
|
@ -102,14 +107,22 @@ export const savePage = async (
|
||||||
state: ArticleSavingRequestStatus.Succeeded,
|
state: ArticleSavingRequestStatus.Succeeded,
|
||||||
})
|
})
|
||||||
if (existingPage) {
|
if (existingPage) {
|
||||||
await updatePage(
|
if (
|
||||||
existingPage.id,
|
!(await updatePage(
|
||||||
{
|
existingPage.id,
|
||||||
savedAt: new Date(),
|
{
|
||||||
archivedAt: undefined,
|
savedAt: new Date(),
|
||||||
},
|
archivedAt: undefined,
|
||||||
ctx
|
},
|
||||||
)
|
ctx
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
console.log('FAILED TO UPDATE EXISTING PAGE WITH', input)
|
||||||
|
return {
|
||||||
|
errorCodes: [SaveErrorCode.Unknown],
|
||||||
|
message: 'Failed to update existing page',
|
||||||
|
}
|
||||||
|
}
|
||||||
input.clientRequestId = existingPage.id
|
input.clientRequestId = existingPage.id
|
||||||
} else if (shouldParseInBackend(input)) {
|
} else if (shouldParseInBackend(input)) {
|
||||||
await createPageSaveRequest(
|
await createPageSaveRequest(
|
||||||
|
|
@ -120,7 +133,13 @@ export const savePage = async (
|
||||||
input.clientRequestId
|
input.clientRequestId
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
await createPage(articleToSave, ctx)
|
if (!(await createPage(articleToSave, ctx))) {
|
||||||
|
console.log('FAILED TO CREATE PAGE WITH INPUT', input)
|
||||||
|
return {
|
||||||
|
errorCodes: [SaveErrorCode.Unknown],
|
||||||
|
message: 'Failed to create new page',
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue