mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
UBERF-4831 Fix duplicate issue descriptions (#4305)
Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
parent
a2a956bbda
commit
4defb38ff5
@ -102,7 +102,15 @@ export class StorageExtension implements Extension {
|
||||
if (initialContentId !== undefined && initialContentId.length > 0) {
|
||||
console.log('load document initial content', initialContentId)
|
||||
try {
|
||||
return await adapter.loadDocument(initialContentId, context)
|
||||
const ydoc = await adapter.loadDocument(initialContentId, context)
|
||||
|
||||
// if document was loaded from the initial content we need to save
|
||||
// it to ensure the next time we load ydoc document
|
||||
if (ydoc !== undefined) {
|
||||
await adapter.saveDocument(documentId, ydoc, context)
|
||||
}
|
||||
|
||||
return ydoc
|
||||
} catch (err) {
|
||||
console.error('failed to load document', initialContentId, err)
|
||||
}
|
||||
|
@ -13,13 +13,12 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Document } from '@hocuspocus/server'
|
||||
import { Doc as YDoc } from 'yjs'
|
||||
import { Context } from '../context'
|
||||
|
||||
export interface StorageAdapter {
|
||||
loadDocument: (documentId: string, context: Context) => Promise<YDoc | undefined>
|
||||
saveDocument: (documentId: string, document: Document, context: Context) => Promise<void>
|
||||
saveDocument: (documentId: string, document: YDoc, context: Context) => Promise<void>
|
||||
}
|
||||
|
||||
export type StorageAdapters = Record<string, StorageAdapter>
|
||||
|
@ -16,7 +16,6 @@
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import { MeasureContext, Ref } from '@hcengineering/core'
|
||||
import { MinioService } from '@hcengineering/minio'
|
||||
import { Document } from '@hocuspocus/server'
|
||||
import { Doc as YDoc, applyUpdate, encodeStateAsUpdate } from 'yjs'
|
||||
|
||||
import { Context } from '../context'
|
||||
@ -69,7 +68,7 @@ export class MinioStorageAdapter implements StorageAdapter {
|
||||
})
|
||||
}
|
||||
|
||||
async saveDocument (documentId: string, document: Document, context: Context): Promise<void> {
|
||||
async saveDocument (documentId: string, document: YDoc, context: Context): Promise<void> {
|
||||
const { decodedToken, token } = context
|
||||
|
||||
await this.ctx.with('save-document', {}, async (ctx) => {
|
||||
|
@ -14,7 +14,6 @@
|
||||
//
|
||||
|
||||
import { MeasureContext, toWorkspaceString } from '@hcengineering/core'
|
||||
import { Document } from '@hocuspocus/server'
|
||||
import { Transformer } from '@hocuspocus/transformer'
|
||||
import { MongoClient } from 'mongodb'
|
||||
import { Doc as YDoc } from 'yjs'
|
||||
@ -72,7 +71,7 @@ export class MongodbStorageAdapter implements StorageAdapter {
|
||||
})
|
||||
}
|
||||
|
||||
async saveDocument (_documentId: string, _document: Document, _context: Context): Promise<void> {
|
||||
async saveDocument (_documentId: string, _document: YDoc, _context: Context): Promise<void> {
|
||||
// do nothing, not supported
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
//
|
||||
|
||||
import { Class, Doc, MeasureContext, Ref } from '@hcengineering/core'
|
||||
import { Document } from '@hocuspocus/server'
|
||||
import { Transformer } from '@hocuspocus/transformer'
|
||||
import { Doc as YDoc } from 'yjs'
|
||||
|
||||
@ -82,7 +81,7 @@ export class PlatformStorageAdapter implements StorageAdapter {
|
||||
})
|
||||
}
|
||||
|
||||
async saveDocument (documentId: string, document: Document, context: Context): Promise<void> {
|
||||
async saveDocument (documentId: string, document: YDoc, context: Context): Promise<void> {
|
||||
const { decodedToken, token } = context
|
||||
const { objectId, objectClass, objectAttr } = parseDocumentId(documentId)
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Document } from '@hocuspocus/server'
|
||||
import { Doc as YDoc } from 'yjs'
|
||||
|
||||
import { Context } from '../context'
|
||||
@ -45,7 +44,7 @@ export class RouterStorageAdapter implements StorageAdapter {
|
||||
return await adapter?.loadDocument?.(documentName, context)
|
||||
}
|
||||
|
||||
async saveDocument (documentId: string, document: Document, context: Context): Promise<void> {
|
||||
async saveDocument (documentId: string, document: YDoc, context: Context): Promise<void> {
|
||||
const { schema, documentName } = parseDocumentName(documentId)
|
||||
const adapter = this.getStorageAdapter(schema)
|
||||
await adapter?.saveDocument?.(documentName, document, context)
|
||||
|
Loading…
Reference in New Issue
Block a user