Skip to content

Commit e20a92c

Browse files
committed
fix: yjs 서비스에서 redis 사용하게 수정
1 parent ffc5ea0 commit e20a92c

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

apps/backend/src/yjs/yjs.service.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ export class YjsService
6767
const editorDoc = doc.getXmlFragment('default');
6868
const customDoc = editorDoc.doc as CustomDoc;
6969

70-
if (customDoc.name === 'users') {
71-
return;
72-
}
73-
7470
// document name이 flow-room이라면 모든 노드들을 볼 수 있는 화면입니다.
7571
// 노드를 클릭해 페이지를 열었을 때만 해당 페이지 값을 가져와서 초기 데이터로 세팅해줍니다.
7672
if (customDoc.name?.startsWith('document-')) {
@@ -113,18 +109,18 @@ export class YjsService
113109
editorDoc.observeDeep(() => {
114110
const document = editorDoc.doc as CustomDoc;
115111
const pageId = parseInt(document.name.split('-')[1]);
116-
this.pageService.updatePage(
117-
pageId,
118-
JSON.parse(
119-
JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
120-
),
121-
);
122-
123-
// this.redisService.setField(
124-
// pageId.toString(),
125-
// 'content',
126-
// JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
112+
// this.pageService.updatePage(
113+
// pageId,
114+
// JSON.parse(
115+
// JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
116+
// ),
127117
// );
118+
119+
this.redisService.setField(
120+
pageId.toString(),
121+
'content',
122+
JSON.stringify(yXmlFragmentToProsemirrorJSON(editorDoc)),
123+
);
128124
// this.redisService.get(pageId.toString()).then((data) => {
129125
// console.log(data);
130126
// });
@@ -158,17 +154,17 @@ export class YjsService
158154
title.observeDeep(async (event) => {
159155
// path가 존재할 때만 페이지 갱신
160156
event[0].path.toString().split('_')[1] &&
161-
this.pageService.updatePage(
162-
parseInt(event[0].path.toString().split('_')[1]),
163-
{
164-
title: event[0].target.toString(),
165-
},
157+
// this.pageService.updatePage(
158+
// parseInt(event[0].path.toString().split('_')[1]),
159+
// {
160+
// title: event[0].target.toString(),
161+
// },
162+
// );
163+
this.redisService.setField(
164+
event[0].path.toString().split('_')[1],
165+
'title',
166+
event[0].target.toString(),
166167
);
167-
// this.redisService.setField(
168-
// event[0].path.toString().split('_')[1],
169-
// 'title',
170-
// event[0].target.toString(),
171-
// );
172168
});
173169
emoji.observeDeep((event) => {
174170
// path가 존재할 때만 페이지 갱신

0 commit comments

Comments
 (0)