Skip to content

Commit a0c6d20

Browse files
committed
Use a clean solution which requires a change in JupyterLab
1 parent bf3561e commit a0c6d20

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

packages/docprovider/src/ydrive.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export class YDrive extends Drive implements ICollaborativeDrive {
174174
this._providers.set(key, provider);
175175

176176
sharedModel.changed.connect(async (_, change) => {
177-
// TODO: make use of the hash
178177
if (!change.stateChange) {
179178
return;
180179
}
@@ -192,29 +191,16 @@ export class YDrive extends Drive implements ICollaborativeDrive {
192191
const hashChange = hashChanges[0];
193192

194193
// A change in hash signifies that a save occurred on the server-side
195-
// (e.g. a collaborator performed the save) - we want notify the observers
196-
// about this change so that they can store the new hash value.
197-
194+
// (e.g. a collaborator performed the save) - we want to notify the
195+
// observers about this change so that they can store the new hash value.
198196
const model = await this.get(options.path, { content: false });
199-
/*
197+
200198
this._ydriveFileChanged.emit({
201-
type: 'server-side-save',
202-
newValue: {...model, hash: hashChange.newValue},
199+
type: 'save',
200+
newValue: { ...model, hash: hashChange.newValue },
203201
// we do not have the old model because it was discarded when server made the change,
204202
// we only have the old hash here (which may be empty if the file was newly created!)
205-
oldValue: {hash: hashChange.oldValue}
206-
});
207-
*/
208-
// TODO: add handler for `server-side-save` in
209-
// https://github.com/jupyterlab/jupyterlab/blob/dca1ec376c66038b8df7001d32cf058c70fcd717/packages/docregistry/src/context.ts#L410-L444
210-
// For now, fake it:
211-
// it happens that "rename" will perform the update of context's internal
212-
// contentsModel (which we desire to solve the spurious "File Changed" dialog)
213-
// even if file path has not changed.
214-
this._ydriveFileChanged.emit({
215-
type: 'rename',
216-
newValue: { ...model, hash: hashChange.newValue },
217-
oldValue: { ...model, hash: hashChange.oldValue }
203+
oldValue: { hash: hashChange.oldValue }
218204
});
219205
});
220206

0 commit comments

Comments
 (0)