fix compatibility: polyfill device storage "getFilesAndDirectories" method

This commit is contained in:
Mahdi Dibaiee 2015-09-14 00:59:58 +04:30
parent 2b51a7df09
commit d925dfb082
7 changed files with 173 additions and 9 deletions

View File

@ -99,7 +99,7 @@ module.exports = function(grunt) {
tasks: ['browserify:dev']
},
assets: {
files: ['src/index.html', 'src/manifest.webapp',
files: ['src/index.html', 'src/manifest.webapp', 'src/polyfill.js',
'src/fonts/**', 'src/img/**', 'src/data/**'],
tasks: ['copy']
}

View File

@ -29971,7 +29971,7 @@ var getFile = _asyncToGenerator(function* () {
exports.getFile = getFile;
var children = _asyncToGenerator(function* (dir, gatherInfo) {
var parent = yield getFile(dir);
var parent = shimDirectory((yield getFile(dir)));
var childs = yield parent.getFilesAndDirectories();
if (gatherInfo) {
@ -29993,7 +29993,9 @@ var children = _asyncToGenerator(function* (dir, gatherInfo) {
child.children = subchildren.length;
} else {
child.path = dir + '/';
if (typeof child.path === 'undefined') {
child.path = dir + '/';
}
}
}
} catch (err) {
@ -30139,19 +30141,25 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a
var _utils = require('utils');
var _actionsFilesView = require('actions/files-view');
var _store = require('store');
var SD_CACHE = undefined;
function sdcard() {
if (SD_CACHE) return SD_CACHE;
SD_CACHE = navigator.getDeviceStorage('sdcard');
SD_CACHE.onchange = (0, _store.bind)((0, _actionsFilesView.refresh)());
window.sdcard = SD_CACHE;
return SD_CACHE;
}
var ROOT_CACHE = undefined;
},{"utils":"utils"}],229:[function(require,module,exports){
},{"actions/files-view":220,"store":"store","utils":"utils"}],229:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, '__esModule', {
@ -32584,7 +32592,7 @@ var _store2 = _interopRequireDefault(_store);
var _actionsDialog = require('actions/dialog');
function type(obj) {
return Object.prototype.toString.call(obj).slice(8, -1);
return obj.toString().slice(8, -1);
}
function template(string, props) {
@ -32610,6 +32618,7 @@ function getKey(object, key) {
}
function reportError(err) {
console.error(err);
var action = (0, _actionsDialog.show)('errorDialog', { description: err.message });
_store2['default'].dispatch(action);
}

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,15 @@
import { type } from 'utils';
import { refresh } from 'actions/files-view';
import { bind } from 'store';
let SD_CACHE;
export function sdcard() {
if (SD_CACHE) return SD_CACHE;
SD_CACHE = navigator.getDeviceStorage('sdcard');
SD_CACHE.onchange = bind(refresh());
window.sdcard = SD_CACHE;
return SD_CACHE;
}
@ -27,7 +31,7 @@ export async function getFile(dir = '/') {
}
export async function children(dir, gatherInfo) {
let parent = await getFile(dir);
let parent = shimDirectory(await getFile(dir));
let childs = await parent.getFilesAndDirectories();
if (gatherInfo) {
@ -42,7 +46,9 @@ export async function children(dir, gatherInfo) {
child.children = subchildren.length;
} else {
child.path = dir + '/';
if (typeof child.path === 'undefined') {
child.path = dir + '/';
}
}
};
}

View File

@ -23,5 +23,5 @@ export default function(state = '', action) {
function changeTo(dir) {
children(dir, true).then(files => {
store.dispatch(listFiles(files));
}, reportError);
}, reportError)
}

View File

@ -2,7 +2,7 @@ import store from 'store';
import { show } from 'actions/dialog';
export function type(obj) {
return Object.prototype.toString.call(obj).slice(8, -1);
return obj.toString().slice(8, -1);
}
export function template(string, props) {
@ -26,6 +26,7 @@ export function getKey(object = store.getState().toJS(), key) {
}
export function reportError(err) {
console.error(err);
let action = show('errorDialog', {description: err.message});
store.dispatch(action);
}

File diff suppressed because one or more lines are too long