diff options
Diffstat (limited to 'animism-align/frontend/views/align/align.actions.js')
| -rw-r--r-- | animism-align/frontend/views/align/align.actions.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/animism-align/frontend/views/align/align.actions.js b/animism-align/frontend/views/align/align.actions.js index 351b826..6d01fc0 100644 --- a/animism-align/frontend/views/align/align.actions.js +++ b/animism-align/frontend/views/align/align.actions.js @@ -4,6 +4,7 @@ import { api, post, pad, preloadImage } from '../../util' import actions from '../../actions' import { session } from '../../session' import throttle from 'lodash.throttle' +import debounce from 'lodash.debounce' import { ZOOM_STEPS } from './constants' import { getFirstPunctuationMarkIndex, cutFirstSentence } from './align.util' @@ -25,12 +26,21 @@ export const setCursor = cursor_ts => dispatch => ( dispatch({ type: types.align.set_display_setting, key: 'cursor_ts', value: cursor_ts }) ) -export const setSelectedAnnotation = annotation_id => dispatch => { - dispatch({ type: types.align.set_display_setting, key: 'selected_annotation_id', value: annotation_id }) +export const setSelectedAnnotation = annotation => dispatch => { + dispatch({ type: types.align.set_selected_annotation, data: annotation }) } -export const clearSelectedAnnotation = annotation_id => dispatch => { - dispatch({ type: types.align.set_display_setting, key: 'selected_annotation_id', value: -1 }) +export const clearSelectedAnnotation = () => dispatch => { + dispatch({ type: types.align.clear_selected_annotation, }) } +export const updateSelectedAnnotation = annotation => dispatch => { + dispatch({ type: types.align.set_selected_annotation, data: { ...annotation } }) + debouncedUpdateAnnotation(annotation) +} +export const debouncedUpdateAnnotation = debounce(annotation => { + console.log('updating annotation', annotation) + actions.annotation.update(annotation) +}, 2000, { leading: false, trailing: true }) + export const setSelectedParagraph = paragraph_id => dispatch => { dispatch({ type: types.align.set_display_setting, key: 'selected_paragraph_id', value: paragraph_id }) @@ -46,7 +56,7 @@ export const showNewAnnotationForm = (start_ts, text) => dispatch => { } else { croppedText = cutFirstSentence(text) } - console.log(croppedText) + // console.log(croppedText) dispatch({ type: types.align.set_temporary_annotation, data: { @@ -73,7 +83,6 @@ export const updateAnnotationSettings = (key, value) => dispatch => { dispatch({ type: types.align.update_temporary_annotation_settings, key, value }) } - export const hideAnnotationForm = () => dispatch => { dispatch({ type: types.align.set_temporary_annotation, |
