@jupyter/docprovider 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ydrive.js +22 -6
- package/package.json +2 -2
package/lib/ydrive.js
CHANGED
|
@@ -73,19 +73,24 @@ export class RtcContentProvider {
|
|
|
73
73
|
if (!oldPath || !newPath) {
|
|
74
74
|
// This is expected when shared model initializes and the path is first populated
|
|
75
75
|
console.debug('New or old path not given', pathChange);
|
|
76
|
-
return;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
// A rename can be reported by both the drive and the shared model.
|
|
79
|
+
// Do not process the second notification again.
|
|
80
|
+
if (oldPath !== path && newPath === path) {
|
|
81
|
+
return false;
|
|
77
82
|
}
|
|
78
83
|
const oldKey = `${options.format}:${options.contentType}:${oldPath}`;
|
|
79
84
|
if (oldKey !== key) {
|
|
80
85
|
console.error('The computed old provider key is different from the current key');
|
|
81
|
-
return;
|
|
86
|
+
return false;
|
|
82
87
|
}
|
|
83
88
|
const newKey = `${options.format}:${options.contentType}:${newPath}`;
|
|
84
89
|
// Check if the provider is still registered (it may have been disposed if document was closed)
|
|
85
90
|
const provider = this._providers.get(oldKey);
|
|
86
91
|
if (!provider) {
|
|
87
92
|
console.warn(`Could not find a provider to update after rename ${oldKey}, ${newKey}`);
|
|
88
|
-
return;
|
|
93
|
+
return false;
|
|
89
94
|
}
|
|
90
95
|
// Re-register the provider under the new key
|
|
91
96
|
this._providers.set(newKey, provider);
|
|
@@ -102,6 +107,16 @@ export class RtcContentProvider {
|
|
|
102
107
|
documents.push(newPath);
|
|
103
108
|
(_b = this._globalAwareness) === null || _b === void 0 ? void 0 : _b.setLocalStateField('documents', documents);
|
|
104
109
|
}
|
|
110
|
+
// Notify the ContentsManager/DocumentContext regardless of whether
|
|
111
|
+
// the rename was first reported by the drive or the shared model.
|
|
112
|
+
// Emitting this also feeds back into the drive signal, but the path
|
|
113
|
+
// check above makes that notification idempotent.
|
|
114
|
+
this._providerFileChanged.emit({
|
|
115
|
+
type: 'rename',
|
|
116
|
+
oldValue: { path: oldPath },
|
|
117
|
+
newValue: { path: newPath }
|
|
118
|
+
});
|
|
119
|
+
return true;
|
|
105
120
|
};
|
|
106
121
|
// The information about file being renamed can come from two places:
|
|
107
122
|
// - from the sharedModel via changed signal with documentChange
|
|
@@ -129,7 +144,6 @@ export class RtcContentProvider {
|
|
|
129
144
|
};
|
|
130
145
|
(_c = this._driveFileChanged) === null || _c === void 0 ? void 0 : _c.connect(handleFileChangedSignal);
|
|
131
146
|
sharedModel.changed.connect(async (_, change) => {
|
|
132
|
-
var _a;
|
|
133
147
|
if (!change.stateChange) {
|
|
134
148
|
return;
|
|
135
149
|
}
|
|
@@ -148,8 +162,10 @@ export class RtcContentProvider {
|
|
|
148
162
|
// A change in hash signifies that a save occurred on the server-side
|
|
149
163
|
// (e.g. a collaborator performed the save) - we want to notify the
|
|
150
164
|
// observers about this change so that they can store the new hash value.
|
|
151
|
-
|
|
152
|
-
|
|
165
|
+
// Use the path tracked by the provider. During a rename transaction,
|
|
166
|
+
// the state accessor may still expose the old path even though the
|
|
167
|
+
// path state change above has already been processed.
|
|
168
|
+
const model = await this.get(path, { content: false });
|
|
153
169
|
this._providerFileChanged.emit({
|
|
154
170
|
type: 'save',
|
|
155
171
|
newValue: { ...model, hash: hashChange.newValue },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter/docprovider",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "JupyterLab - Document Provider",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyter-collaboration",
|
|
6
6
|
"bugs": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"watch": "tsc -b --watch"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@jupyter/collaborative-drive": "^5.0.
|
|
44
|
+
"@jupyter/collaborative-drive": "^5.0.2",
|
|
45
45
|
"@jupyter/ydoc": "^4.0.0",
|
|
46
46
|
"@jupyterlab/apputils": "^4.7.0",
|
|
47
47
|
"@jupyterlab/cells": "^4.6.0",
|