Skip to content

Commit 97a857c

Browse files
committed
Set shared document file_id
1 parent d8629b4 commit 97a857c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

plugins/yjs/fps_yjs/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ async def serve(self, websocket: YWebsocket, permissions) -> None:
178178
file_path = await self.contents.file_id_manager.get_path(file_id)
179179
logger.info(f"Opening collaboration room: {websocket.path} ({file_path})")
180180
document = YDOCS.get(file_type, YFILE)(room.ydoc)
181+
document.file_id = file_id
181182
self.documents[websocket.path] = document
182183
async with self.lock:
183184
model = await self.contents.read_content(file_path, True, file_format)

plugins/yjs/fps_yjs/ydocs/ybasedoc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def path(self) -> Optional[str]:
5151
def path(self, value: str) -> None:
5252
self._ystate["path"] = value
5353

54+
@property
55+
def file_id(self) -> Optional[str]:
56+
return self._ystate.get("file_id")
57+
58+
@file_id.setter
59+
def file_id(self, value: str) -> None:
60+
self._ystate["file_id"] = value
61+
5462
@abstractmethod
5563
def get(self) -> Any:
5664
...

plugins/yjs/fps_yjs/ydocs/ynotebook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def set(self, value: Dict) -> None:
123123
# clear document
124124
self._ymeta.clear()
125125
self._ycells.clear()
126-
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path")]:
126+
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path", "file_id")]:
127127
del self._ystate[key]
128128

129129
# initialize document

0 commit comments

Comments
 (0)