Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit d138417

Browse files
Cristian TraversoRoberto Ciccone
authored andcommitted
DESIGNER-1845 improve code style
1 parent 47e16da commit d138417

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

app/scripts/services/local-storage-file-system.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@
304304
// }
305305
//move all child items
306306
localStorageHelper.forEach(function (entry) {
307-
if (entry.path.toLowerCase() !== source.toLowerCase() &&
308-
entry.path.indexOf(source) === 0) {
307+
if (entry.path.toLowerCase() !== destination.toLowerCase() &&
308+
entry.path.indexOf(source + '/') === 0) {
309309
var newPath = destination + entry.path.substring(source.length);
310310
localStorageHelper.remove(entry.path);
311311
entry.path = newPath;

app/scripts/services/raml-repository.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939

4040
function metaFile(file) {
41-
return file.path.slice(-5) === '.meta';
41+
return !notMetaFile(file);
4242
}
4343

4444
function handleErrorFor(file) {
@@ -176,36 +176,28 @@
176176
return this.metaChildren.filter(function(t) { return !t.isDirectory; });
177177
};
178178

179-
RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) {
179+
RamlDirectory.prototype.forEachItemDo = function forEachItemDo(action, isMetaChildren) {
180180
// BFS
181-
var queue = this.children.slice();
181+
var queue = isMetaChildren ? this.metaChildren.slice() : this.children.slice();
182182
var current;
183183

184184
while (queue.length > 0) {
185185
current = queue.shift();
186186

187187
if (current.isDirectory) {
188-
queue = queue.concat(current.children);
188+
queue = queue.concat((isMetaChildren) ? current.metaChildren : current.children);
189189
}
190190

191191
action.call(current, current);
192192
}
193193
};
194194

195-
RamlDirectory.prototype.forEachMetaChildDo = function forEachMetaChildDo(action) {
196-
// BFS
197-
var queue = this.metaChildren.slice();
198-
var current;
199-
200-
while (queue.length > 0) {
201-
current = queue.shift();
202-
203-
if (current.isDirectory) {
204-
queue = queue.concat(current.metaChildren);
205-
}
195+
RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) {
196+
this.forEachItemDo(action, false);
197+
};
206198

207-
action.call(current, current);
208-
}
199+
RamlDirectory.prototype.forEachMetaChildDo = function forEachChildDo(action) {
200+
this.forEachItemDo(action, true);
209201
};
210202

211203
RamlDirectory.prototype.sortChildren = function sortChildren() {
@@ -277,8 +269,8 @@
277269
// and collect all promises into an array
278270
var promises = [];
279271
directory.getDirectories().forEach(function(dir) { promises.push(service.removeDirectory(dir)); });
280-
directory.getFiles().forEach(function(file) { promises.push(service.removeFile(file)); });
281-
directory.getMetaFiles().forEach(function(file) { promises.push(service.removeFile(file)); });
272+
directory.getFiles().concat(directory.getMetaFiles())
273+
.forEach(function(file) { promises.push(service.removeFile(file)); });
282274

283275
// remove this directory object from parent's children list
284276
var parent = service.getParent(directory);

0 commit comments

Comments
 (0)