feat multiselection: select multiple files and act on them
fix breadcrumb: fixed breadcrumb history not working properly when clicking on "sdcard" fix dialogs/menus: fixed clicking out of menus and dialogs triggering actions other than hiding the dialog/event
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ACTIVE_FILE } from 'actions/types';
|
||||
|
||||
export default function(state = -1, action) {
|
||||
export default function(state = null, action) {
|
||||
if (action.type === ACTIVE_FILE) {
|
||||
return action.file;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import activeFile from './active-file';
|
||||
import menu from './menu';
|
||||
import dialog from './dialog';
|
||||
import settings from './settings';
|
||||
import selectView from './select-view';
|
||||
|
||||
export default function(state = new Immutable.Map(), action) {
|
||||
console.log('action', action);
|
||||
@@ -14,14 +15,16 @@ export default function(state = new Immutable.Map(), action) {
|
||||
lwd: lwd(state, action), // last working directory
|
||||
cwd: cwd(state.get('cwd'), action),
|
||||
files: files(state.get('files'), action),
|
||||
selectView: selectView(state.get('selectView'), action),
|
||||
activeFile: activeFile(state.get('activeFile'), action),
|
||||
navigation: navigation(state.get('navigation'), action),
|
||||
settings: settings(state.get('settings'), action),
|
||||
fileMenu: menu(state, action, 'fileMenu'),
|
||||
directoryMenu: menu(state, action, 'directoryMenu'),
|
||||
moreMenu: menu(state, action, 'moreMenu'),
|
||||
renameDialog: dialog(state, action, 'renameDialog'),
|
||||
deleteDialog: dialog(state, action, 'deleteDialog'),
|
||||
errorDialog: dialog(state, action, 'errorDialog'),
|
||||
createDialog: dialog(state, action, 'createDialog')
|
||||
createDialog: dialog(state, action, 'createDialog'),
|
||||
});
|
||||
}
|
||||
|
@@ -1,14 +1,30 @@
|
||||
import { LIST_FILES, RENAME_FILE, DELETE_FILE, CREATE_FILE } from 'actions/types';
|
||||
import { refresh } from 'actions/files-view';
|
||||
import { move, sdcard, createFile, createDirectory } from 'api/files';
|
||||
import { move, remove, sdcard, createFile, createDirectory } from 'api/files';
|
||||
import { show } from 'actions/dialog';
|
||||
import store, { bind } from 'store';
|
||||
import { reportError } from 'utils';
|
||||
import { reportError, type } from 'utils';
|
||||
|
||||
let boundRefresh = bind(refresh());
|
||||
|
||||
export default function(state = [], action) {
|
||||
if (action.type === LIST_FILES) {
|
||||
|
||||
let settings = store.getState().get('settings');
|
||||
|
||||
if (settings.showDirectoriesFirst) {
|
||||
action.files = action.files.sort((a, b) => {
|
||||
if (type(a) === 'Directory') return -1;
|
||||
if (type(a) === 'File') return 1;
|
||||
});
|
||||
}
|
||||
|
||||
if (!settings.showHiddenFiles) {
|
||||
action.files = action.files.filter(file => {
|
||||
return file.name[0] !== '.';
|
||||
})
|
||||
}
|
||||
|
||||
return action.files;
|
||||
}
|
||||
|
||||
@@ -28,13 +44,26 @@ export default function(state = [], action) {
|
||||
}
|
||||
|
||||
if (action.type === DELETE_FILE) {
|
||||
let file = state[action.file];
|
||||
|
||||
sdcard().delete((file.path || '') + '/' + file.name);
|
||||
let copy = state.slice(0);
|
||||
copy.splice(action.file, 1);
|
||||
|
||||
if (action.file.length) {
|
||||
for (let index of action.file) {
|
||||
del(state, index);
|
||||
}
|
||||
|
||||
copy = copy.filter((a, i) => action.file.indexOf(i) === -1);
|
||||
} else {
|
||||
del(state, action.file);
|
||||
copy.splice(action.file, 1);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function del(state, index) {
|
||||
let file = state[index];
|
||||
return remove((file.path || '') + '/' + file.name).catch(reportError);
|
||||
}
|
||||
|
9
src/js/reducers/select-view.js
Normal file
9
src/js/reducers/select-view.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { SELECT_VIEW } from 'actions/types';
|
||||
|
||||
export default function(state = false, action) {
|
||||
if (action.type === SELECT_VIEW) {
|
||||
return action.active === 'toggle' ? !state : action.active;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
Reference in New Issue
Block a user