diff --git a/build/main.js b/build/main.js index 6f55807..14d9e54 100644 --- a/build/main.js +++ b/build/main.js @@ -31995,6 +31995,7 @@ exports['default'] = function (state, action) { }; function changeTo(dir) { + dir = (0, _utils.normalize)(dir); (0, _apiFiles.children)(dir, true).then(function (files) { _store2['default'].dispatch((0, _actionsFilesView.listFiles)(files)); }, _utils.reportError); diff --git a/build/polyfill.js b/build/polyfill.js index f5fd5aa..8ed9267 100644 --- a/build/polyfill.js +++ b/build/polyfill.js @@ -41,24 +41,22 @@ function shimDirectory(directory) { return; } - var parts = this.result.name.replace('/sdcard/', '').split('/'); + var normalized = this.result.name.replace('/sdcard/', ''); + var parts = normalized.split('/'); // immediate children files if (parts.slice(0, -1).join('/') === current) { - console.log('constructing file'); var file = new File([this.result], parts[parts.length - 1], { type: this.result.type }); - console.log('defining path'); Object.defineProperty(file, 'path', { value: parts.slice(0, -1).join('/') + '/' }); children.push(file); // Directories - } else if (parts.slice(0, -2).join('/') === current) { - var path = parts.slice(0, -2).join('/') + '/'; - var name = parts[parts.length - 2]; + } else if (normalized.indexOf(current) === 0) { + var name = normalized.slice(current.length).replace(/^\//, '').split('/')[0]; var exists = children.some(function(child) { return child.name === name @@ -67,7 +65,7 @@ function shimDirectory(directory) { if (!exists) { var dir = Object.assign({}, directory); dir.name = name; - dir.path = path; + dir.path = current + '/'; children.push(dir); } } diff --git a/releases/hawk-1.0.0.zip b/releases/hawk-1.0.0.zip index 8e85e2a..399ed56 100644 Binary files a/releases/hawk-1.0.0.zip and b/releases/hawk-1.0.0.zip differ diff --git a/src/js/actions/changedir.js b/src/js/actions/changedir.js index d4c8935..a7e4356 100644 --- a/src/js/actions/changedir.js +++ b/src/js/actions/changedir.js @@ -5,5 +5,5 @@ export default function changedir(dir) { return { type: CHANGE_DIRECTORY, dir - }; + } } diff --git a/src/js/reducers/cwd.js b/src/js/reducers/cwd.js index a88d4bf..4016eb7 100644 --- a/src/js/reducers/cwd.js +++ b/src/js/reducers/cwd.js @@ -1,7 +1,7 @@ import { CHANGE_DIRECTORY, REFRESH, SETTINGS } from 'actions/types'; import { children, CACHE } from 'api/files'; import store from 'store'; -import { reportError } from 'utils'; +import { reportError, normalize } from 'utils'; import { listFiles } from 'actions/files-view'; export default function(state = '', action) { @@ -25,6 +25,7 @@ export default function(state = '', action) { } function changeTo(dir) { + dir = normalize(dir); children(dir, true).then(files => { store.dispatch(listFiles(files)); }, reportError) diff --git a/src/polyfill.js b/src/polyfill.js index f5fd5aa..8ed9267 100644 --- a/src/polyfill.js +++ b/src/polyfill.js @@ -41,24 +41,22 @@ function shimDirectory(directory) { return; } - var parts = this.result.name.replace('/sdcard/', '').split('/'); + var normalized = this.result.name.replace('/sdcard/', ''); + var parts = normalized.split('/'); // immediate children files if (parts.slice(0, -1).join('/') === current) { - console.log('constructing file'); var file = new File([this.result], parts[parts.length - 1], { type: this.result.type }); - console.log('defining path'); Object.defineProperty(file, 'path', { value: parts.slice(0, -1).join('/') + '/' }); children.push(file); // Directories - } else if (parts.slice(0, -2).join('/') === current) { - var path = parts.slice(0, -2).join('/') + '/'; - var name = parts[parts.length - 2]; + } else if (normalized.indexOf(current) === 0) { + var name = normalized.slice(current.length).replace(/^\//, '').split('/')[0]; var exists = children.some(function(child) { return child.name === name @@ -67,7 +65,7 @@ function shimDirectory(directory) { if (!exists) { var dir = Object.assign({}, directory); dir.name = name; - dir.path = path; + dir.path = current + '/'; children.push(dir); } }