Эх сурвалжийг харах

Added desktop auto refresh for file operation that involved desktop path

TC pushbot 5 4 жил өмнө
parent
commit
2fb45199a5

+ 19 - 9
web/SystemAO/file_system/file_operation.html

@@ -630,17 +630,11 @@ mainloop:
                                 windowObject.contentWindow.eval(operationConfig.callbackFunction);
                             }
 
-                            //If the target is desktop, refresh desktop as well
-                            var filteredDest = operationConfig.dest;
-                            if (filteredDest.substr(filteredDest.length - 1) == "/"){
-                                filteredDest = filteredDest.substr(0, filteredDest.length - 1);
-                            }
-                            var dirChunk = filteredDest.split("/");
-                            console.log(dirChunk);
-                            if (dirChunk.length == 2 && dirChunk[0].toLowerCase() == "user:" && dirChunk[1].toLowerCase() == "desktop"){
-                                //This is a direct access desktop file
+                            //If the target or src is desktop, refresh desktop as well
+                            if(pathIsOnDesktop(operationConfig.dest) || pathIsOnDesktop(operationConfig.src[0])){
                                 parent.refresh(undefined, true);
                             }
+
                             ao_module_close();
                         }, 1000);
                     }else if (opr == "download"){
@@ -663,6 +657,22 @@ mainloop:
                 console.log(data);
             }
 
+            function pathIsOnDesktop(path){
+                var filteredDest = path;
+                if (filteredDest.substr(filteredDest.length - 1) == "/"){
+                    filteredDest = filteredDest.substr(0, filteredDest.length - 1);
+                }
+                var dirChunk = filteredDest.split("/");
+                console.log(dirChunk);
+                if (dirChunk.length == 2 || dirChunk.length == 3){
+                    if (dirChunk[0].toLowerCase() == "user:" && dirChunk[1].toLowerCase() == "desktop"){
+                        //This is a direct access desktop file
+                        return true;
+                    }
+                }
+                return false;
+            }
+
             function requestCSRFToken(callback){
                 $.ajax({
                     url: "../../system/csrf/new",