You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Implemented search and fixed Redux update loop
This commit is contained in:
@ -6,9 +6,11 @@ const defaultState = {
|
||||
notesParentType: null,
|
||||
folders: [],
|
||||
tags: [],
|
||||
searches: [],
|
||||
selectedNoteId: null,
|
||||
selectedFolderId: null,
|
||||
selectedTagId: null,
|
||||
selectedSearchId: null,
|
||||
selectedItemType: 'note',
|
||||
showSideMenu: false,
|
||||
screens: {},
|
||||
@ -362,6 +364,39 @@ const reducer = (state = defaultState, action) => {
|
||||
newState.searchQuery = action.query.trim();
|
||||
break;
|
||||
|
||||
case 'SEARCH_ADD':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
let searches = newState.searches.slice();
|
||||
searches.push(action.search);
|
||||
newState.searches = searches;
|
||||
break;
|
||||
|
||||
case 'SEARCH_REMOVE':
|
||||
|
||||
let foundIndex = -1;
|
||||
for (let i = 0; i < state.searches.length; i++) {
|
||||
if (state.searches[i].id === action.searchId) {
|
||||
foundIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundIndex >= 0) {
|
||||
newState = Object.assign({}, state);
|
||||
let newSearches = newState.searches.slice();
|
||||
newSearches.splice(foundIndex, 1);
|
||||
newState.searches = newSearches;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'SEARCH_SELECT':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
newState.selectedSearchId = action.searchId;
|
||||
newState.notesParentType = 'Search';
|
||||
break;
|
||||
|
||||
case 'SET_APP_STATE':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
|
Reference in New Issue
Block a user