|
|
@ -12,7 +12,7 @@ function search_reducer(old_state, new_state, action){
|
|
|
|
new_state.search_term = action.search_term;
|
|
|
|
new_state.search_term = action.search_term;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(action.type === 'update-search-results'){
|
|
|
|
else if(action.type === 'update-search-results'){
|
|
|
|
new_state.notes = action.notes.map(note=>({is_editing: false, note}));
|
|
|
|
new_state.notes = action.notes.map(note=>({is_editing: false, temp_text: '', note}));
|
|
|
|
new_state.search_term = old_state.search_term;
|
|
|
|
new_state.search_term = old_state.search_term;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
@ -22,10 +22,10 @@ function search_reducer(old_state, new_state, action){
|
|
|
|
|
|
|
|
|
|
|
|
function notes_reducer(old_state, new_state, action){
|
|
|
|
function notes_reducer(old_state, new_state, action){
|
|
|
|
if(action.type === 'add-note'){
|
|
|
|
if(action.type === 'add-note'){
|
|
|
|
new_state.notes = old_state.notes.concat([{is_editing: true, note: {id: action.id, text: '', modified: Date.now()}}])
|
|
|
|
new_state.notes = ([{is_editing: true, note: {id: action.id, text: '', modified: Date.now()}}]).concat(old_state.notes)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(action.type === 'notes-loaded'){
|
|
|
|
else if(action.type === 'notes-loaded'){
|
|
|
|
new_state.notes = action.notes.map(note=>({is_editing: false, note}));
|
|
|
|
new_state.notes = action.notes.map(note=>({is_editing: false, temp_text: note.text, note}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(action.type === 'update-note-text'){
|
|
|
|
else if(action.type === 'update-note-text'){
|
|
|
|
const i = old_state.notes.findIndex(note_state => note_state.note.id === action.note_id);
|
|
|
|
const i = old_state.notes.findIndex(note_state => note_state.note.id === action.note_id);
|
|
|
@ -35,7 +35,7 @@ function notes_reducer(old_state, new_state, action){
|
|
|
|
else if(action.type === 'update-note-editing'){
|
|
|
|
else if(action.type === 'update-note-editing'){
|
|
|
|
const i = old_state.notes.findIndex(note_state => note_state.note.id === action.note_id);
|
|
|
|
const i = old_state.notes.findIndex(note_state => note_state.note.id === action.note_id);
|
|
|
|
new_state.notes = old_state.notes.slice();
|
|
|
|
new_state.notes = old_state.notes.slice();
|
|
|
|
new_state.notes[i] = {...new_state.notes[i], is_editing: action.is_editing};
|
|
|
|
new_state.notes[i] = {...new_state.notes[i], is_editing: action.is_editing, temp_text: new_state.notes[i].note.text};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
new_state.notes = old_state.notes;
|
|
|
|
new_state.notes = old_state.notes;
|
|
|
|