Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set shared document file_id #368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/yjs/fps_yjs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ async def serve(self, websocket: YWebsocket, permissions) -> None:
file_path = await self.contents.file_id_manager.get_path(file_id)
logger.info(f"Opening collaboration room: {websocket.path} ({file_path})")
document = YDOCS.get(file_type, YFILE)(room.ydoc)
document.file_id = file_id
self.documents[websocket.path] = document
async with self.lock:
model = await self.contents.read_content(file_path, True, file_format)
Expand Down
8 changes: 8 additions & 0 deletions plugins/yjs/fps_yjs/ydocs/ybasedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def path(self) -> Optional[str]:
def path(self, value: str) -> None:
self._ystate["path"] = value

@property
def file_id(self) -> Optional[str]:
return self._ystate.get("file_id")

@file_id.setter
def file_id(self, value: str) -> None:
self._ystate["file_id"] = value

@abstractmethod
def get(self) -> Any:
...
Expand Down
2 changes: 1 addition & 1 deletion plugins/yjs/fps_yjs/ydocs/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def set(self, value: Dict) -> None:
# clear document
self._ymeta.clear()
self._ycells.clear()
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path")]:
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path", "file_id")]:
del self._ystate[key]

# initialize document
Expand Down
Loading