You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-05 22:57:29 +02:00
All: Allow sorting notes by various fields
This commit is contained in:
@@ -19,19 +19,24 @@ const defaultState = {
|
||||
showSideMenu: false,
|
||||
screens: {},
|
||||
historyCanGoBack: false,
|
||||
notesOrder: [
|
||||
{ by: 'user_updated_time', dir: 'DESC' },
|
||||
],
|
||||
syncStarted: false,
|
||||
syncReport: {},
|
||||
searchQuery: '',
|
||||
settings: {},
|
||||
appState: 'starting',
|
||||
//windowContentSize: { width: 0, height: 0 },
|
||||
hasDisabledSyncItems: false,
|
||||
newNote: null,
|
||||
};
|
||||
|
||||
const stateUtils = {};
|
||||
|
||||
stateUtils.notesOrder = function(stateSettings) {
|
||||
return [{
|
||||
by: stateSettings['notes.sortOrder.field'],
|
||||
dir: stateSettings['notes.sortOrder.reverse'] ? 'DESC' : 'ASC',
|
||||
}];
|
||||
}
|
||||
|
||||
function arrayHasEncryptedItems(array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!!array[i].encryption_applied) return true;
|
||||
@@ -90,8 +95,6 @@ function handleItemDelete(state, action) {
|
||||
}
|
||||
|
||||
function updateOneItem(state, action) {
|
||||
// let newItems = action.type === 'TAG_UPDATE_ONE' ? state.tags.splice(0) : state.folders.splice(0);
|
||||
// let item = action.type === 'TAG_UPDATE_ONE' ? action.tag : action.folder;
|
||||
let itemsKey = null;
|
||||
if (action.type === 'TAG_UPDATE_ONE') itemsKey = 'tags';
|
||||
if (action.type === 'FOLDER_UPDATE_ONE') itemsKey = 'folders';
|
||||
@@ -116,12 +119,6 @@ function updateOneItem(state, action) {
|
||||
|
||||
newState[itemsKey] = newItems;
|
||||
|
||||
// if (action.type === 'TAG_UPDATE_ONE') {
|
||||
// newState.tags = newItems;
|
||||
// } else {
|
||||
// newState.folders = newItems;
|
||||
// }
|
||||
|
||||
return newState;
|
||||
}
|
||||
|
||||
@@ -316,7 +313,8 @@ const reducer = (state = defaultState, action) => {
|
||||
}
|
||||
}
|
||||
|
||||
newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
||||
//newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
||||
newNotes = Note.sortNotes(newNotes, stateUtils.notesOrder(state.settings), newState.settings.uncompletedTodosOnTop);
|
||||
newState = Object.assign({}, state);
|
||||
newState.notes = newNotes;
|
||||
|
||||
@@ -481,4 +479,4 @@ const reducer = (state = defaultState, action) => {
|
||||
return newState;
|
||||
}
|
||||
|
||||
module.exports = { reducer, defaultState };
|
||||
module.exports = { reducer, defaultState, stateUtils };
|
||||
Reference in New Issue
Block a user