fix compatibility: fix getting an empty error due to corrupted path
properties
fix compatibility: switch navigation drawer to `display: block` if there is no flexbox support
This commit is contained in:
parent
8a3c5de65d
commit
ceb8cd3b21
@ -29951,7 +29951,7 @@ exports.sdcard = sdcard;
|
|||||||
var root = _asyncToGenerator(function* () {
|
var root = _asyncToGenerator(function* () {
|
||||||
if (ROOT_CACHE) return ROOT_CACHE;
|
if (ROOT_CACHE) return ROOT_CACHE;
|
||||||
|
|
||||||
ROOT_CACHE = yield sdcard().getRoot();
|
ROOT_CACHE = shimDirectory((yield sdcard().getRoot()));
|
||||||
window.root = ROOT_CACHE;
|
window.root = ROOT_CACHE;
|
||||||
return ROOT_CACHE;
|
return ROOT_CACHE;
|
||||||
});
|
});
|
||||||
@ -29972,6 +29972,9 @@ exports.getFile = getFile;
|
|||||||
|
|
||||||
var children = _asyncToGenerator(function* (dir, gatherInfo) {
|
var children = _asyncToGenerator(function* (dir, gatherInfo) {
|
||||||
var parent = shimDirectory((yield getFile(dir)));
|
var parent = shimDirectory((yield getFile(dir)));
|
||||||
|
if (!parent.path) {
|
||||||
|
parent.path = dir.slice(0, dir.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
var childs = yield parent.getFilesAndDirectories();
|
var childs = yield parent.getFilesAndDirectories();
|
||||||
|
|
||||||
if (gatherInfo) {
|
if (gatherInfo) {
|
||||||
@ -29986,7 +29989,7 @@ var children = _asyncToGenerator(function* (dir, gatherInfo) {
|
|||||||
if ((0, _utils.type)(child) === 'Directory') {
|
if ((0, _utils.type)(child) === 'Directory') {
|
||||||
var subchildren = undefined;
|
var subchildren = undefined;
|
||||||
try {
|
try {
|
||||||
subchildren = yield child.getFilesAndDirectories();
|
subchildren = yield shimDirectory(child).getFilesAndDirectories();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
subchildren = [];
|
subchildren = [];
|
||||||
}
|
}
|
||||||
@ -30047,9 +30050,15 @@ var createFile = _asyncToGenerator(function* () {
|
|||||||
exports.createFile = createFile;
|
exports.createFile = createFile;
|
||||||
|
|
||||||
var createDirectory = _asyncToGenerator(function* () {
|
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();
|
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;
|
exports.createDirectory = createDirectory;
|
||||||
@ -30083,7 +30092,7 @@ var copy = _asyncToGenerator(function* (file, newPath) {
|
|||||||
|
|
||||||
if ((0, _utils.type)(target) === 'Directory') {
|
if ((0, _utils.type)(target) === 'Directory') {
|
||||||
yield parent.createDirectory(newPath);
|
yield parent.createDirectory(newPath);
|
||||||
var childs = yield target.getFilesAndDirectories();
|
var childs = yield shimDirectory(target).getFilesAndDirectories();
|
||||||
|
|
||||||
var _iteratorNormalCompletion2 = true;
|
var _iteratorNormalCompletion2 = true;
|
||||||
var _didIteratorError2 = false;
|
var _didIteratorError2 = false;
|
||||||
@ -30094,7 +30103,9 @@ var copy = _asyncToGenerator(function* (file, newPath) {
|
|||||||
var child = _step2.value;
|
var child = _step2.value;
|
||||||
|
|
||||||
if ((0, _utils.type)(child) === 'File') {
|
if ((0, _utils.type)(child) === 'File') {
|
||||||
child.path = oldPath + '/';
|
Object.defineProperty(child, 'path', {
|
||||||
|
value: oldPath + '/'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
yield copy(child, newPath + '/' + child.name);
|
yield copy(child, newPath + '/' + child.name);
|
||||||
@ -30442,7 +30453,7 @@ var Directory = (function (_Component) {
|
|||||||
value: function peek() {
|
value: function peek() {
|
||||||
var file = _store2['default'].getState().get('files')[this.props.index];
|
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() {
|
value: function render() {
|
||||||
var settings = this.props.settings;
|
var settings = this.props.settings;
|
||||||
|
|
||||||
|
var noFlex = typeof getComputedStyle(document.body)['flex-flow'] === 'undefined';
|
||||||
|
|
||||||
|
var style = noFlex ? { display: 'block' } : {};
|
||||||
|
|
||||||
return _react2['default'].createElement(
|
return _react2['default'].createElement(
|
||||||
'nav',
|
'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('i', { onTouchStart: this.hide }),
|
||||||
_react2['default'].createElement(
|
_react2['default'].createElement(
|
||||||
'p',
|
'p',
|
||||||
@ -31537,7 +31554,8 @@ exports['default'] = {
|
|||||||
var input = _react2['default'].findDOMNode(this.refs.input);
|
var input = _react2['default'].findDOMNode(this.refs.input);
|
||||||
|
|
||||||
var cwd = _store2['default'].getState().get('cwd');
|
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(action);
|
||||||
this.props.dispatch((0, _actionsDialog.hideAll)());
|
this.props.dispatch((0, _actionsDialog.hideAll)());
|
||||||
this.props.dispatch((0, _actionsFile.active)());
|
this.props.dispatch((0, _actionsFile.active)());
|
||||||
@ -31548,7 +31566,8 @@ exports['default'] = {
|
|||||||
var input = _react2['default'].findDOMNode(this.refs.input);
|
var input = _react2['default'].findDOMNode(this.refs.input);
|
||||||
|
|
||||||
var cwd = _store2['default'].getState().get('cwd');
|
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(action);
|
||||||
this.props.dispatch((0, _actionsDialog.hideAll)());
|
this.props.dispatch((0, _actionsDialog.hideAll)());
|
||||||
this.props.dispatch((0, _actionsFile.active)());
|
this.props.dispatch((0, _actionsFile.active)());
|
||||||
|
@ -26,32 +26,35 @@ function shimDirectory(directory) {
|
|||||||
directory.toString = function() { return '[object Directory]' };
|
directory.toString = function() { return '[object Directory]' };
|
||||||
directory.getFilesAndDirectories = function getFilesAndDirectories() {
|
directory.getFilesAndDirectories = function getFilesAndDirectories() {
|
||||||
var current = (this.path || '') + this.name;
|
var current = (this.path || '') + this.name;
|
||||||
|
console.log('gettingFilesAndDirectories of', this);
|
||||||
var children = [];
|
var children = [];
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
|
||||||
var request = sdcard.enumerate(current);
|
var request = sdcard.enumerate(current);
|
||||||
request.onsuccess = function() {
|
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('/');
|
var parts = this.result.name.replace('/sdcard/', '').split('/');
|
||||||
|
|
||||||
// immediate children files
|
// immediate children files
|
||||||
if (parts.slice(0, -1).join('/') === current) {
|
if (parts.slice(0, -1).join('/') === current) {
|
||||||
|
console.log('constructing file');
|
||||||
var file = new File([this.result], parts[parts.length - 1], {
|
var file = new File([this.result], parts[parts.length - 1], {
|
||||||
type: this.result.type
|
type: this.result.type
|
||||||
});
|
});
|
||||||
|
console.log('defining path');
|
||||||
Object.defineProperty(file, 'path', {
|
Object.defineProperty(file, 'path', {
|
||||||
value: parts.slice(0, -1).join('/') + '/'
|
value: parts.slice(0, -1).join('/') + '/'
|
||||||
});
|
});
|
||||||
children.push(file);
|
children.push(file);
|
||||||
|
|
||||||
return this.continue();
|
// Directories
|
||||||
}
|
} else if (parts.slice(0, -2).join('/') === current) {
|
||||||
|
var path = parts.slice(0, -2).join('/') + '/';
|
||||||
// directories
|
|
||||||
if (parts.slice(0, -2).join('/') === current) {
|
|
||||||
var path = parts.slice(0, -2).join('');
|
|
||||||
var name = parts[parts.length - 2];
|
var name = parts[parts.length - 2];
|
||||||
|
|
||||||
var exists = children.some(function(child) {
|
var exists = children.some(function(child) {
|
||||||
@ -63,11 +66,13 @@ function shimDirectory(directory) {
|
|||||||
dir.name = name;
|
dir.name = name;
|
||||||
dir.path = path;
|
dir.path = path;
|
||||||
children.push(dir);
|
children.push(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.continue();
|
if (this.done) return resolve(children);
|
||||||
}
|
else this.continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
request.onerror = reject;
|
request.onerror = reject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ let ROOT_CACHE;
|
|||||||
export async function root() {
|
export async function root() {
|
||||||
if (ROOT_CACHE) return ROOT_CACHE;
|
if (ROOT_CACHE) return ROOT_CACHE;
|
||||||
|
|
||||||
ROOT_CACHE = await sdcard().getRoot();
|
ROOT_CACHE = shimDirectory(await sdcard().getRoot());
|
||||||
window.root = ROOT_CACHE;
|
window.root = ROOT_CACHE;
|
||||||
return ROOT_CACHE;
|
return ROOT_CACHE;
|
||||||
}
|
}
|
||||||
@ -32,6 +32,9 @@ export async function getFile(dir = '/') {
|
|||||||
|
|
||||||
export async function children(dir, gatherInfo) {
|
export async function children(dir, gatherInfo) {
|
||||||
let parent = shimDirectory(await getFile(dir));
|
let parent = shimDirectory(await getFile(dir));
|
||||||
|
if (!parent.path) {
|
||||||
|
parent.path = dir.slice(0, dir.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
let childs = await parent.getFilesAndDirectories();
|
let childs = await parent.getFilesAndDirectories();
|
||||||
|
|
||||||
if (gatherInfo) {
|
if (gatherInfo) {
|
||||||
@ -39,7 +42,7 @@ export async function children(dir, gatherInfo) {
|
|||||||
if (type(child) === 'Directory') {
|
if (type(child) === 'Directory') {
|
||||||
let subchildren;
|
let subchildren;
|
||||||
try {
|
try {
|
||||||
subchildren = await child.getFilesAndDirectories();
|
subchildren = await shimDirectory(child).getFilesAndDirectories();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
subchildren = [];
|
subchildren = [];
|
||||||
}
|
}
|
||||||
@ -80,7 +83,9 @@ export async function createFile(...args) {
|
|||||||
export async function createDirectory(...args) {
|
export async function createDirectory(...args) {
|
||||||
let parent = await root();
|
let parent = await root();
|
||||||
|
|
||||||
return parent.createDirectory(...args);
|
return parent.createDirectory(...args).then(() => {
|
||||||
|
return createFile(args[0] + '/.empty');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove(file, deep) {
|
export async function remove(file, deep) {
|
||||||
@ -108,11 +113,13 @@ export async function copy(file, newPath) {
|
|||||||
|
|
||||||
if (type(target) === 'Directory') {
|
if (type(target) === 'Directory') {
|
||||||
await parent.createDirectory(newPath);
|
await parent.createDirectory(newPath);
|
||||||
let childs = await target.getFilesAndDirectories();
|
let childs = await shimDirectory(target).getFilesAndDirectories();
|
||||||
|
|
||||||
for (let child of childs) {
|
for (let child of childs) {
|
||||||
if (type(child) === 'File') {
|
if (type(child) === 'File') {
|
||||||
child.path = oldPath + '/';
|
Object.defineProperty(child, 'path', {
|
||||||
|
value: oldPath + '/'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await copy(child, newPath + '/' + child.name);
|
await copy(child, newPath + '/' + child.name);
|
||||||
|
@ -39,6 +39,6 @@ export default class Directory extends Component {
|
|||||||
peek() {
|
peek() {
|
||||||
let file = store.getState().get('files')[this.props.index];
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,14 @@ export default class Navigation extends Component {
|
|||||||
render() {
|
render() {
|
||||||
let { settings } = this.props;
|
let { settings } = this.props;
|
||||||
|
|
||||||
|
let noFlex = typeof getComputedStyle(document.body)['flex-flow'] === 'undefined';
|
||||||
|
|
||||||
|
let style = noFlex ? {display: 'block'} : {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={this.props.active ? 'active' : ''} onChange={this.onChange.bind(this)}>
|
<nav className={this.props.active ? 'active' : ''}
|
||||||
|
onChange={this.onChange.bind(this)}
|
||||||
|
style={style}>
|
||||||
<i onTouchStart={this.hide} />
|
<i onTouchStart={this.hide} />
|
||||||
|
|
||||||
<p>Filter</p>
|
<p>Filter</p>
|
||||||
|
@ -16,7 +16,8 @@ export default {
|
|||||||
let input = React.findDOMNode(this.refs.input);
|
let input = React.findDOMNode(this.refs.input);
|
||||||
|
|
||||||
let cwd = store.getState().get('cwd');
|
let cwd = store.getState().get('cwd');
|
||||||
let action = create(cwd + '/' + input.value);
|
let path = cwd + '/' + input.value;
|
||||||
|
let action = create(path.replace(/^\//, ''));
|
||||||
this.props.dispatch(action);
|
this.props.dispatch(action);
|
||||||
this.props.dispatch(hideAll());
|
this.props.dispatch(hideAll());
|
||||||
this.props.dispatch(active());
|
this.props.dispatch(active());
|
||||||
@ -28,7 +29,8 @@ export default {
|
|||||||
let input = React.findDOMNode(this.refs.input);
|
let input = React.findDOMNode(this.refs.input);
|
||||||
|
|
||||||
let cwd = store.getState().get('cwd');
|
let cwd = store.getState().get('cwd');
|
||||||
let action = create(cwd + '/' + input.value, true);
|
let path = cwd + '/' + input.value;
|
||||||
|
let action = create(path.replace(/^\//, ''), true);
|
||||||
this.props.dispatch(action);
|
this.props.dispatch(action);
|
||||||
this.props.dispatch(hideAll());
|
this.props.dispatch(hideAll());
|
||||||
this.props.dispatch(active());
|
this.props.dispatch(active());
|
||||||
|
@ -26,32 +26,35 @@ function shimDirectory(directory) {
|
|||||||
directory.toString = function() { return '[object Directory]' };
|
directory.toString = function() { return '[object Directory]' };
|
||||||
directory.getFilesAndDirectories = function getFilesAndDirectories() {
|
directory.getFilesAndDirectories = function getFilesAndDirectories() {
|
||||||
var current = (this.path || '') + this.name;
|
var current = (this.path || '') + this.name;
|
||||||
|
console.log('gettingFilesAndDirectories of', this);
|
||||||
var children = [];
|
var children = [];
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
|
||||||
var request = sdcard.enumerate(current);
|
var request = sdcard.enumerate(current);
|
||||||
request.onsuccess = function() {
|
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('/');
|
var parts = this.result.name.replace('/sdcard/', '').split('/');
|
||||||
|
|
||||||
// immediate children files
|
// immediate children files
|
||||||
if (parts.slice(0, -1).join('/') === current) {
|
if (parts.slice(0, -1).join('/') === current) {
|
||||||
|
console.log('constructing file');
|
||||||
var file = new File([this.result], parts[parts.length - 1], {
|
var file = new File([this.result], parts[parts.length - 1], {
|
||||||
type: this.result.type
|
type: this.result.type
|
||||||
});
|
});
|
||||||
|
console.log('defining path');
|
||||||
Object.defineProperty(file, 'path', {
|
Object.defineProperty(file, 'path', {
|
||||||
value: parts.slice(0, -1).join('/') + '/'
|
value: parts.slice(0, -1).join('/') + '/'
|
||||||
});
|
});
|
||||||
children.push(file);
|
children.push(file);
|
||||||
|
|
||||||
return this.continue();
|
// Directories
|
||||||
}
|
} else if (parts.slice(0, -2).join('/') === current) {
|
||||||
|
var path = parts.slice(0, -2).join('/') + '/';
|
||||||
// directories
|
|
||||||
if (parts.slice(0, -2).join('/') === current) {
|
|
||||||
var path = parts.slice(0, -2).join('');
|
|
||||||
var name = parts[parts.length - 2];
|
var name = parts[parts.length - 2];
|
||||||
|
|
||||||
var exists = children.some(function(child) {
|
var exists = children.some(function(child) {
|
||||||
@ -63,11 +66,13 @@ function shimDirectory(directory) {
|
|||||||
dir.name = name;
|
dir.name = name;
|
||||||
dir.path = path;
|
dir.path = path;
|
||||||
children.push(dir);
|
children.push(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.continue();
|
if (this.done) return resolve(children);
|
||||||
}
|
else this.continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
request.onerror = reject;
|
request.onerror = reject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user