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

feat(tiptap): save updates to db + invalidate queries #367

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

seaerchin
Copy link
Contributor

@seaerchin seaerchin commented Jul 25, 2024

Problem

Previously, Prose wasn't saving to db. When uat added the save to db, there wasnt the query invalidation portion. This PR adds both functionality in

Solution

  • use the updatePageBlob hook in TiptapComponent.
  • invalidate queries on save so that we see the new state

Screenshots and video

Screen.Recording.2024-07-25.at.5.51.55.PM.mov

wire save through to db
refactor so props correctness handled otuside
invalidate on update
now requires db
update db on save + invalidate old queries
@seaerchin seaerchin requested a review from a team as a code owner July 25, 2024 09:52
Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 5:48am

Comment on lines +94 to +97
content: JSON.stringify({
...pageContent,
content: previewPageState,
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having to fetch page content just to stringify here isn't ideal and i'll refactor when all our "content updating" features are in

@@ -193,7 +193,7 @@ export const pageRouter = router({
.mutation(async ({ input }) => {
// @ts-expect-error we need this because we sanitise as a string
// but this accepts a nested JSON object
await updateBlobById({ ...input, pageId: input.pageId })
await updateBlobById(db, { ...input, pageId: input.pageId })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error wasn't caught previously due to @ts-expect-error .______.

@seaerchin seaerchin merged commit 3281001 into feat/optimistic-loading Jul 29, 2024
14 checks passed
@seaerchin seaerchin deleted the feat/save-updates branch July 29, 2024 06:35
seaerchin added a commit that referenced this pull request Jul 30, 2024
* chore: convert

add script

* refactor: resource

use 2 queries cos inner join + update in same query doesn't work

* refactor: component selector

update typings

* feat: editor drawer context

add curr active idx

* feat: editpagedrawer

update so data is dynamic

* chore: componentselector

only paragraph uses component selector

* chore: update convert function

1. add zod validation
2. simplify the function

* chore: component selector

* chore: components selector

update to correct names

* chore: constants

update default prose block

* feat: convert

add convert functions

* chore: typings

* chore: next state

compute next state from block

* feat: update

update UI on save click

* feat: update

update pages automatically

* chore: rename editorstate

* chore: utils

delete obsolete function

* chore: menubar

remove title cos we don't want them to set h1

* chore: remove unused imports

* chore: remove json schema setting

* fix: tiptap

update typings + validation

* chore: componentselector

update to remove unsafe cast

* fix: add snapshot

* chore: remove extra memo

* chore: fix type errors

* chore: remove saving

* chore: style

run lint + format

* chore: fix type errors

* chore: style

run lint + format

* feat: re-order

* feat: optimistic loading

* feat: page router

* fix: run formatter

* chore: prose

add format

* fix: use ref for isomer components schema

* fix: prose

add format

* chore: fix rebase errors

* chore: style

* chore: rebase fixes

* fix: rebase

* chore: style

* chore: typings

* chore: comments

* chore: use siteID

* chore: style

lint fix + style fix

* chore: root state drawer

use query parse

* chore: memo ondragend

* chore: update imports

* chore: componentselector

pas stuff as props to selector

* chore: style

* chore: onerror

shift from inside mutate function to hook

* fix: page schema

min 0

* fix: page id

obtain page id correctly

* fix: resource service

add forUpdate

* fix: blob id conditional

* fix: transaction

put stuff in tx and use safe kysely type

* chore: remove extra dep

* chore: component selector

remove unused props

* ref: db

pass db as explicit arg

* feat(tiptap): save updates to db + invalidate queries (#367)

* fix: complex editor

wire save through to db

* refactor: complex editor state drawer

refactor so props correctness handled otuside

* fix: update page

invalidate on update

* fix: updatePageBlob

now requires db

* feat: tiptap component

update db on save + invalidate old queries

* chore: use exported schema

* fix: rebase

* fix: lint

update lint

---------

Co-authored-by: Kar Rui Lau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants