diff --git a/build/main.js b/build/main.js index cac27ec..bf7ca28 100644 --- a/build/main.js +++ b/build/main.js @@ -29951,7 +29951,7 @@ exports.sdcard = sdcard; var root = _asyncToGenerator(function* () { if (ROOT_CACHE) return ROOT_CACHE; - ROOT_CACHE = yield sdcard().getRoot(); + ROOT_CACHE = shimDirectory((yield sdcard().getRoot())); window.root = ROOT_CACHE; return ROOT_CACHE; }); @@ -29972,6 +29972,9 @@ exports.getFile = getFile; var children = _asyncToGenerator(function* (dir, gatherInfo) { var parent = shimDirectory((yield getFile(dir))); + if (!parent.path) { + parent.path = dir.slice(0, dir.lastIndexOf('/') + 1); + } var childs = yield parent.getFilesAndDirectories(); if (gatherInfo) { @@ -29986,7 +29989,7 @@ var children = _asyncToGenerator(function* (dir, gatherInfo) { if ((0, _utils.type)(child) === 'Directory') { var subchildren = undefined; try { - subchildren = yield child.getFilesAndDirectories(); + subchildren = yield shimDirectory(child).getFilesAndDirectories(); } catch (e) { subchildren = []; } @@ -30047,9 +30050,15 @@ var createFile = _asyncToGenerator(function* () { exports.createFile = createFile; var createDirectory = _asyncToGenerator(function* () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var parent = yield root(); - return parent.createDirectory.apply(parent, arguments); + return parent.createDirectory.apply(parent, args).then(function () { + return createFile(args[0] + '/.empty'); + }); }); exports.createDirectory = createDirectory; @@ -30083,7 +30092,7 @@ var copy = _asyncToGenerator(function* (file, newPath) { if ((0, _utils.type)(target) === 'Directory') { yield parent.createDirectory(newPath); - var childs = yield target.getFilesAndDirectories(); + var childs = yield shimDirectory(target).getFilesAndDirectories(); var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; @@ -30094,7 +30103,9 @@ var copy = _asyncToGenerator(function* (file, newPath) { var child = _step2.value; if ((0, _utils.type)(child) === 'File') { - child.path = oldPath + '/'; + Object.defineProperty(child, 'path', { + value: oldPath + '/' + }); } yield copy(child, newPath + '/' + child.name); @@ -30442,7 +30453,7 @@ var Directory = (function (_Component) { value: function peek() { var file = _store2['default'].getState().get('files')[this.props.index]; - _store2['default'].dispatch((0, _actionsChangedir2['default'])(file.path.slice(1) + file.name)); + _store2['default'].dispatch((0, _actionsChangedir2['default'])(file.path.replace(/^\//, '') + file.name)); } }]); @@ -30944,9 +30955,15 @@ var Navigation = (function (_Component) { value: function render() { var settings = this.props.settings; + var noFlex = typeof getComputedStyle(document.body)['flex-flow'] === 'undefined'; + + var style = noFlex ? { display: 'block' } : {}; + return _react2['default'].createElement( 'nav', - { className: this.props.active ? 'active' : '', onChange: this.onChange.bind(this) }, + { className: this.props.active ? 'active' : '', + onChange: this.onChange.bind(this), + style: style }, _react2['default'].createElement('i', { onTouchStart: this.hide }), _react2['default'].createElement( 'p', @@ -31537,7 +31554,8 @@ exports['default'] = { var input = _react2['default'].findDOMNode(this.refs.input); var cwd = _store2['default'].getState().get('cwd'); - var action = (0, _actionsFile.create)(cwd + '/' + input.value); + var path = cwd + '/' + input.value; + var action = (0, _actionsFile.create)(path.replace(/^\//, '')); this.props.dispatch(action); this.props.dispatch((0, _actionsDialog.hideAll)()); this.props.dispatch((0, _actionsFile.active)()); @@ -31548,7 +31566,8 @@ exports['default'] = { var input = _react2['default'].findDOMNode(this.refs.input); var cwd = _store2['default'].getState().get('cwd'); - var action = (0, _actionsFile.create)(cwd + '/' + input.value, true); + var path = cwd + '/' + input.value; + var action = (0, _actionsFile.create)(path.replace(/^\//, ''), true); this.props.dispatch(action); this.props.dispatch((0, _actionsDialog.hideAll)()); this.props.dispatch((0, _actionsFile.active)()); diff --git a/build/polyfill.js b/build/polyfill.js index 6a6c9a9..1a2bdab 100644 --- a/build/polyfill.js +++ b/build/polyfill.js @@ -26,32 +26,35 @@ function shimDirectory(directory) { directory.toString = function() { return '[object Directory]' }; directory.getFilesAndDirectories = function getFilesAndDirectories() { var current = (this.path || '') + this.name; + console.log('gettingFilesAndDirectories of', this); var children = []; return new Promise(function(resolve, reject) { - var request = sdcard.enumerate(current); request.onsuccess = function() { - if (!this.result) return resolve(children); + if (!this.result) { + if (this.done) resolve(children); + else this.continue(); + return; + } var parts = this.result.name.replace('/sdcard/', '').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); - return this.continue(); - } - - // directories - if (parts.slice(0, -2).join('/') === current) { - var path = parts.slice(0, -2).join(''); + // Directories + } else if (parts.slice(0, -2).join('/') === current) { + var path = parts.slice(0, -2).join('/') + '/'; var name = parts[parts.length - 2]; var exists = children.some(function(child) { @@ -64,10 +67,12 @@ function shimDirectory(directory) { dir.path = path; children.push(dir); } - - return this.continue(); } + + if (this.done) return resolve(children); + else this.continue(); } + request.onerror = reject; }); } diff --git a/src/js/api/files.js b/src/js/api/files.js index c04909e..b7a8b31 100644 --- a/src/js/api/files.js +++ b/src/js/api/files.js @@ -17,7 +17,7 @@ let ROOT_CACHE; export async function root() { if (ROOT_CACHE) return ROOT_CACHE; - ROOT_CACHE = await sdcard().getRoot(); + ROOT_CACHE = shimDirectory(await sdcard().getRoot()); window.root = ROOT_CACHE; return ROOT_CACHE; } @@ -32,6 +32,9 @@ export async function getFile(dir = '/') { export async function children(dir, gatherInfo) { let parent = shimDirectory(await getFile(dir)); + if (!parent.path) { + parent.path = dir.slice(0, dir.lastIndexOf('/') + 1); + } let childs = await parent.getFilesAndDirectories(); if (gatherInfo) { @@ -39,7 +42,7 @@ export async function children(dir, gatherInfo) { if (type(child) === 'Directory') { let subchildren; try { - subchildren = await child.getFilesAndDirectories(); + subchildren = await shimDirectory(child).getFilesAndDirectories(); } catch(e) { subchildren = []; } @@ -80,7 +83,9 @@ export async function createFile(...args) { export async function createDirectory(...args) { let parent = await root(); - return parent.createDirectory(...args); + return parent.createDirectory(...args).then(() => { + return createFile(args[0] + '/.empty'); + }); } export async function remove(file, deep) { @@ -108,11 +113,13 @@ export async function copy(file, newPath) { if (type(target) === 'Directory') { await parent.createDirectory(newPath); - let childs = await target.getFilesAndDirectories(); + let childs = await shimDirectory(target).getFilesAndDirectories(); for (let child of childs) { if (type(child) === 'File') { - child.path = oldPath + '/'; + Object.defineProperty(child, 'path', { + value: oldPath + '/' + }); } await copy(child, newPath + '/' + child.name); diff --git a/src/js/components/directory.js b/src/js/components/directory.js index 046eca9..81d48bf 100644 --- a/src/js/components/directory.js +++ b/src/js/components/directory.js @@ -39,6 +39,6 @@ export default class Directory extends Component { peek() { let file = store.getState().get('files')[this.props.index]; - store.dispatch(changedir(file.path.slice(1) + file.name)); + store.dispatch(changedir(file.path.replace(/^\//, '') + file.name)); } } diff --git a/src/js/components/navigation.js b/src/js/components/navigation.js index f037509..3c97ba0 100644 --- a/src/js/components/navigation.js +++ b/src/js/components/navigation.js @@ -10,8 +10,14 @@ export default class Navigation extends Component { render() { let { settings } = this.props; + let noFlex = typeof getComputedStyle(document.body)['flex-flow'] === 'undefined'; + + let style = noFlex ? {display: 'block'} : {}; + return ( -