summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/align/align.actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/views/align/align.actions.js')
-rw-r--r--animism-align/frontend/views/align/align.actions.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/animism-align/frontend/views/align/align.actions.js b/animism-align/frontend/views/align/align.actions.js
index 2e1c795..82e4799 100644
--- a/animism-align/frontend/views/align/align.actions.js
+++ b/animism-align/frontend/views/align/align.actions.js
@@ -24,3 +24,39 @@ export const throttledSetZoom = throttle(zoom => dispatch => {
export const setCursor = cursor_ts => dispatch => (
dispatch({ type: types.align.set_display_setting, key: 'cursor_ts', value: cursor_ts })
)
+
+export const showNewTimestampForm = (start_ts, text) => dispatch => {
+ let croppedText;
+ if (store.getState().align.annotation.start_ts) {
+ croppedText = store.getState().align.annotation.text
+ } else {
+ croppedText = cutFirstSentence(text)
+ }
+ console.log(croppedText)
+ dispatch({
+ type: types.align.set_temporary_annotation,
+ data: {
+ id: 'new',
+ start_ts,
+ text: croppedText,
+ type: 'sentence',
+ }
+ })
+}
+
+const cutFirstSentence = text => {
+ const textToCrop = text.trim().replace("\n", " ").split("\n")[0]
+ let cropIndex = textToCrop.indexOf('. ') + 1
+ if (!cropIndex) cropIndex = textToCrop.length
+ const croppedText = textToCrop.substr(0, cropIndex).trim()
+ const updatedText = text.trim().replace(croppedText, '').trim()
+ actions.site.updateText(updatedText)
+ return croppedText
+}
+
+export const hideTimestampForm = () => dispatch => {
+ dispatch({
+ type: types.align.set_temporary_annotation,
+ data: {}
+ })
+}