Skip to content

Commit

Permalink
feat(wp): dereference tables in postUpdatedHook sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed Jan 30, 2024
1 parent 888be3c commit ebba6ec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions baker/postUpdatedHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as wpdb from "../db/wpdb.js"
import * as db from "../db/db.js"
import {
buildReusableBlocksResolver,
buildTablePressResolver,
getLinksToAddAndRemoveForPost,
} from "../db/syncPostsToGrapher.js"
import { postsTable, select } from "../db/model/Post.js"
Expand Down Expand Up @@ -94,6 +95,7 @@ const syncPostToGrapher = async (
[postId, postId, postId, postId]
)
const dereferenceReusableBlocksFn = await buildReusableBlocksResolver()
const dereferenceTablePressFn = await buildTablePressResolver()

const matchingRows = await db.knexTable(postsTable).where({ id: postId })
const existsInGrapher = !!matchingRows.length
Expand Down Expand Up @@ -137,8 +139,8 @@ const syncPostToGrapher = async (
// Delete from grapher
await transaction.table(postsTable).where({ id: postId }).delete()
else if (postRow) {
const contentWithBlocksInlined = dereferenceReusableBlocksFn(
postRow.content
const contentWithBlocksInlined = dereferenceTablePressFn(
dereferenceReusableBlocksFn(postRow.content)
)
postRow.content = contentWithBlocksInlined

Expand Down

0 comments on commit ebba6ec

Please sign in to comment.