You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Mobile: Allow selecting, deleting and moving multiple notes
This commit is contained in:
@@ -81,6 +81,7 @@ const appDefaultState = Object.assign({}, defaultState, {
|
||||
routeName: 'Welcome',
|
||||
params: {},
|
||||
},
|
||||
noteSelectionEnabled: false,
|
||||
});
|
||||
|
||||
const appReducer = (state = appDefaultState, action) => {
|
||||
@@ -187,6 +188,41 @@ const appReducer = (state = appDefaultState, action) => {
|
||||
newState.sideMenuOpenPercent = action.value;
|
||||
break;
|
||||
|
||||
case 'NOTE_SELECTION_TOGGLE':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
|
||||
const noteId = action.id;
|
||||
const newSelectedNoteIds = state.selectedNoteIds.slice();
|
||||
const existingIndex = state.selectedNoteIds.indexOf(noteId);
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
newSelectedNoteIds.splice(existingIndex, 1);
|
||||
} else {
|
||||
newSelectedNoteIds.push(noteId);
|
||||
}
|
||||
|
||||
newState.selectedNoteIds = newSelectedNoteIds;
|
||||
newState.noteSelectionEnabled = !!newSelectedNoteIds.length;
|
||||
break;
|
||||
|
||||
case 'NOTE_SELECTION_START':
|
||||
|
||||
if (!state.noteSelectionEnabled) {
|
||||
newState = Object.assign({}, state);
|
||||
newState.noteSelectionEnabled = true;
|
||||
newState.selectedNoteIds = [action.id];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NOTE_SELECTION_END':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
newState.noteSelectionEnabled = false;
|
||||
newState.selectedNoteIds = [];
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
error.message = 'In reducer: ' + error.message + ' Action: ' + JSON.stringify(action);
|
||||
@@ -344,6 +380,11 @@ class AppComponent extends React.Component {
|
||||
}
|
||||
|
||||
async backButtonHandler() {
|
||||
if (this.props.noteSelectionEnabled) {
|
||||
this.props.dispatch({ type: 'NOTE_SELECTION_END' });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.props.showSideMenu) {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
return true;
|
||||
@@ -414,6 +455,7 @@ const mapStateToProps = (state) => {
|
||||
showSideMenu: state.showSideMenu,
|
||||
syncStarted: state.syncStarted,
|
||||
appState: state.appState,
|
||||
noteSelectionEnabled: state.noteSelectionEnabled,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user