From 4e2146651d67c7ae622d2eb2f8b0326216b424e8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 6 Aug 2017 00:13:23 +0400 Subject: [PATCH 1/2] fix tree in offline mode --- plugins/c9.fs/fs.cache.xml.js | 19 +++++++++---------- .../c9.vfs.standalone/www/ide.offline.html | 7 ++++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/plugins/c9.fs/fs.cache.xml.js b/plugins/c9.fs/fs.cache.xml.js index 60f0480a..aac5ba76 100644 --- a/plugins/c9.fs/fs.cache.xml.js +++ b/plugins/c9.fs/fs.cache.xml.js @@ -227,6 +227,11 @@ define(function(require, exports, module) { // Modify + function confirmStatus(node) { + if (node.status === "predicted") + node.status = node.isFolder ? "pending" : "loaded"; + } + function afterHandler(e) { if (e.error) e.undo && e.undo(); else e.confirm && e.confirm(); @@ -261,8 +266,7 @@ define(function(require, exports, module) { }); }; e.confirm = function () { - if (node.status === "predicted") - node.status = isFolder ? "pending" : "loaded"; + confirmStatus(node); }; node.status = "predicted"; } @@ -355,9 +359,7 @@ define(function(require, exports, module) { createNode(newPath, null, node); // Move node recurPathUpdate(node, oldPath, newPath); } - - if (node.status === "predicted") - node.status = "pending"; + confirmStatus(node); }; node.status = "predicted"; }, plugin); @@ -390,8 +392,7 @@ define(function(require, exports, module) { }); }; e.confirm = function() { - if (node.status === "predicted") - node.status = "pending"; + confirmStatus(node); }; node.status = "predicted"; }, plugin); @@ -430,10 +431,8 @@ define(function(require, exports, module) { removeSingleNode({ path: to }); }; e.confirm = function() { - if (toNode.status === "predicted") - toNode.status = e.status; + confirmStatus(node); }; - e._status = node.status == "predicted" ? "pending" : e.status; toNode.status = "predicted"; } diff --git a/plugins/c9.vfs.standalone/www/ide.offline.html b/plugins/c9.vfs.standalone/www/ide.offline.html index 18d7dc92..711aec9f 100644 --- a/plugins/c9.vfs.standalone/www/ide.offline.html +++ b/plugins/c9.vfs.standalone/www/ide.offline.html @@ -251,8 +251,10 @@ var parts = ("/.c9/metadata" + path).split("/") var name = "!" + parts.pop(); var parent = findNode(parts.join("/"), true); - if (sync) + if (sync) { parent[name] = JSON.stringify(value); + return cb(); + } setTimeout(function() { parent[name] = JSON.stringify(value); cb(); @@ -405,6 +407,9 @@