You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pastebin/nginx/public_html/handlers/Note.js

23 lines
916 B
JavaScript

import api from '../api.js';
const edit_handler = function(note_state, dispatch){
dispatch('update-note-editing', {id: note_state.note_id, is_editing: true});
};
const cancel_handler = function(state, note_state, dispatch){
// TODO: this `if` may cause glitches; keep in mind
if(note_state.is_new===true){
dispatch('immediately-cancel-note', note_state.note_id);
}
else{
dispatch('update-note-editing', {id: note_state.note_id, is_editing: false});
}
};
const text_change_handler = function(note_state, dispatch, e){
note_state.temp_text = e.target.value;
};
const save_handler = function(note_state, dispatch){
dispatch('save-note-edit', {id: note_state.note_id, text: note_state.temp_text});
api.post('/save', {bin_id: note_state.bin_id, note_id: note_state.note_id, text: note_state.temp_text})
};
export { edit_handler, cancel_handler, text_change_handler, save_handler };