Skip to content

Commit

Permalink
recover from doc not found when updating title
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiralucas committed Jan 2, 2025
1 parent f7e0c94 commit b3328ce
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions apps/api/src/yjs/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import prisma, {
Document,
ApiUser,
getDocument,
recoverFromNotFound,
} from '@briefer/database'
import { decoding, encoding } from 'lib0'
import { logger } from '../../logger.js'
Expand Down Expand Up @@ -750,14 +751,16 @@ export class WSSharedDocV2 {

try {
logger().trace({ docId: this.documentId }, 'Updating document title')
await prisma().document.update({
where: {
id: this.documentId,
},
data: {
title: nextTitle,
},
})
await recoverFromNotFound(
prisma().document.update({
where: {
id: this.documentId,
},
data: {
title: nextTitle,
},
})
)

return true
} catch (err) {
Expand Down Expand Up @@ -1096,7 +1099,7 @@ const setupWSConnection =
const doc = await getDocument(ydoc.documentId)
if (doc && doc.workspaceId === ydoc.workspaceId) {
const dbClock = isDataApp
? doc.userAppClock[user.id] ?? doc.appClock
? (doc.userAppClock[user.id] ?? doc.appClock)
: doc.clock

if (dbClock !== clock) {
Expand Down

0 comments on commit b3328ce

Please sign in to comment.