@@ -37,7 +37,6 @@ def __init__(
37
37
self ._room_id : str = room_id
38
38
self ._file_format : str = file_format
39
39
self ._file_type : str = file_type
40
- self ._last_modified : Any = None
41
40
self ._file : FileLoader = file
42
41
self ._document = YDOCS .get (self ._file_type , YFILE )(self .ydoc )
43
42
@@ -145,7 +144,7 @@ async def initialize(self) -> None:
145
144
if self .ystore :
146
145
await self .ystore .encode_state_as_update (self .ydoc )
147
146
148
- self ._last_modified = model ["last_modified" ]
147
+ self ._file . last_modified = model ["last_modified" ]
149
148
self ._document .dirty = False
150
149
self .ready = True
151
150
self ._emit (LogLevel .INFO , "initialize" , "Room initialized" )
@@ -189,7 +188,7 @@ async def _on_content_change(self, event: str, args: dict[str, Any]) -> None:
189
188
args (dict): A dictionary with format, type, last_modified.
190
189
"""
191
190
if event == "metadata" and (
192
- self ._last_modified is None or self ._last_modified < args ["last_modified" ]
191
+ self ._file . last_modified is None or self ._file . last_modified < args ["last_modified" ]
193
192
):
194
193
self .log .info ("Out-of-band changes. Overwriting the content in room %s" , self ._room_id )
195
194
self ._emit (LogLevel .INFO , "overwrite" , "Out-of-band changes. Overwriting the room." )
@@ -204,7 +203,7 @@ async def _on_content_change(self, event: str, args: dict[str, Any]) -> None:
204
203
205
204
async with self ._update_lock :
206
205
self ._document .source = model ["content" ]
207
- self ._last_modified = model ["last_modified" ]
206
+ self ._file . last_modified = model ["last_modified" ]
208
207
self ._document .dirty = False
209
208
210
209
def _on_document_change (self , target : str , event : Any ) -> None :
@@ -249,15 +248,13 @@ async def _maybe_save_document(self) -> None:
249
248
250
249
try :
251
250
self .log .info ("Saving the content from room %s" , self ._room_id )
252
- model = await self ._file .maybe_save_content (
251
+ await self ._file .maybe_save_content (
253
252
{
254
253
"format" : self ._file_format ,
255
254
"type" : self ._file_type ,
256
- "last_modified" : self ._last_modified ,
257
255
"content" : self ._document .source ,
258
256
}
259
257
)
260
- self ._last_modified = model ["last_modified" ]
261
258
async with self ._update_lock :
262
259
self ._document .dirty = False
263
260
@@ -275,7 +272,7 @@ async def _maybe_save_document(self) -> None:
275
272
276
273
async with self ._update_lock :
277
274
self ._document .source = model ["content" ]
278
- self ._last_modified = model ["last_modified" ]
275
+ self ._file . last_modified = model ["last_modified" ]
279
276
self ._document .dirty = False
280
277
281
278
self ._emit (LogLevel .INFO , "overwrite" , "Out-of-band changes while saving." )
0 commit comments