Skip to content

Commit

Permalink
fix: yjs 서비스 develop 브랜치 버전으로 롤백
Browse files Browse the repository at this point in the history
  • Loading branch information
djk01281 committed Dec 1, 2024
1 parent e20a92c commit 3038887
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions apps/backend/src/yjs/yjs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class YjsService
const editorDoc = doc.getXmlFragment('default');
const customDoc = editorDoc.doc as CustomDoc;

if (customDoc.name === 'users') {
return;
}

// document name이 flow-room이라면 모든 노드들을 볼 수 있는 화면입니다.
// 노드를 클릭해 페이지를 열었을 때만 해당 페이지 값을 가져와서 초기 데이터로 세팅해줍니다.
if (customDoc.name?.startsWith('document-')) {
Expand Down Expand Up @@ -109,18 +113,18 @@ export class YjsService
editorDoc.observeDeep(() => {
const document = editorDoc.doc as CustomDoc;
const pageId = parseInt(document.name.split('-')[1]);
// this.pageService.updatePage(
// pageId,
// JSON.parse(
// JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
// ),
// );

this.redisService.setField(
pageId.toString(),
'content',
JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
this.pageService.updatePage(
pageId,
JSON.parse(
JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
),
);

// this.redisService.setField(
// pageId.toString(),
// 'content',
// JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
// );
// this.redisService.get(pageId.toString()).then((data) => {
// console.log(data);
// });
Expand Down Expand Up @@ -154,17 +158,17 @@ export class YjsService
title.observeDeep(async (event) => {
// path가 존재할 때만 페이지 갱신
event[0].path.toString().split('_')[1] &&
// this.pageService.updatePage(
// parseInt(event[0].path.toString().split('_')[1]),
// {
// title: event[0].target.toString(),
// },
// );
this.redisService.setField(
event[0].path.toString().split('_')[1],
'title',
event[0].target.toString(),
this.pageService.updatePage(
parseInt(event[0].path.toString().split('_')[1]),
{
title: event[0].target.toString(),
},
);
// this.redisService.setField(
// event[0].path.toString().split('_')[1],
// 'title',
// event[0].target.toString(),
// );
});
emoji.observeDeep((event) => {
// path가 존재할 때만 페이지 갱신
Expand Down

0 comments on commit 3038887

Please sign in to comment.