推进资源工具与本地优先兼容链收口
This commit is contained in:
@@ -8072,6 +8072,15 @@ const TREE_LIVE_CONTROLLER_JS: &str = r##"
|
||||
}
|
||||
}
|
||||
|
||||
function liveDeltaNeedsResync(payload) {
|
||||
var data = payload && (payload.data || payload.delta || payload);
|
||||
var op = data && typeof data.op === 'string' ? String(data.op).trim() : '';
|
||||
if (!op || op === 'noop') return false;
|
||||
if (op === 'resync_required') return true;
|
||||
if (data && data.requiresResync === true) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function startWithSse(bootstrap, workspaceId, url) {
|
||||
var failures = 0;
|
||||
var source = new EventSource(url.toString());
|
||||
@@ -8144,8 +8153,7 @@ const TREE_LIVE_CONTROLLER_JS: &str = r##"
|
||||
} else if (kind === 'delta') {
|
||||
document.documentElement.setAttribute('data-mnote-tree-live-revision', String(revision));
|
||||
dispatchTreeEvent('tree:delta', { payload: payload, revision: revision, bootstrap: bootstrap });
|
||||
// Delta indicates something changed; request fresh resync from server
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
if (liveDeltaNeedsResync(payload) && ws.readyState === WebSocket.OPEN) {
|
||||
ws.send('resync');
|
||||
}
|
||||
} else if (kind === 'resync') {
|
||||
@@ -8738,7 +8746,10 @@ mod tests {
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("tree:snapshot"));
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("tree:delta"));
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("tree:resync"));
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("liveDeltaNeedsResync(payload)"));
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("op === 'resync_required'"));
|
||||
assert!(!TREE_LIVE_CONTROLLER_JS.contains("resyncEndpoint"));
|
||||
assert!(!TREE_LIVE_CONTROLLER_JS.contains("tree:resync-requested"));
|
||||
assert!(!TREE_LIVE_CONTROLLER_JS.contains("Delta indicates something changed"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user