fix: suppress local create watcher conflict
This commit is contained in:
@@ -1425,6 +1425,22 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
|
||||
}
|
||||
};
|
||||
|
||||
const shouldSuppressLocalFolderSelfChange = (documentId, eventKind) => {
|
||||
const doc = String(documentId || '').trim();
|
||||
if (!doc) return false;
|
||||
const kind = String(eventKind || '');
|
||||
if (!kind.includes('Create') && !kind.includes('Metadata')) return false;
|
||||
const suppressions = window.__mnoteLocalFolderSelfChangeSuppressions;
|
||||
if (!suppressions || typeof suppressions.get !== 'function') return false;
|
||||
const expiresAt = Number(suppressions.get(doc) || 0);
|
||||
if (!Number.isFinite(expiresAt) || expiresAt <= 0) return false;
|
||||
if (Date.now() > expiresAt) {
|
||||
if (typeof suppressions.delete === 'function') suppressions.delete(doc);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const normalizeSessionSourceKind = (bootstrap) => {
|
||||
const value = typeof bootstrap?.sourceKind === 'string' ? bootstrap.sourceKind.trim() : '';
|
||||
return value || 'convex_workspace';
|
||||
@@ -2249,6 +2265,11 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
|
||||
const mayAffectMissingDocument = eventKind.includes('Remove') || eventKind.includes('Name');
|
||||
const targetsCurrentDocument = Boolean(documentId && documentId === targetSession.documentId);
|
||||
if (documentId && !targetsCurrentDocument && !mayAffectMissingDocument) return;
|
||||
if (targetsCurrentDocument && shouldSuppressLocalFolderSelfChange(documentId, eventKind)) {
|
||||
targetSession.externalChangePending = false;
|
||||
targetSession.lastSelfSaveSignalAt = Date.now();
|
||||
return;
|
||||
}
|
||||
if (targetsCurrentDocument && targetSession.saving) {
|
||||
targetSession.externalChangePending = false;
|
||||
targetSession.lastSelfSaveSignalAt = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user