dubdiff/src/common/reducers.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-11-23 22:58:48 +01:00
2016-11-28 18:47:47 +01:00
export function input (state, action ) {
2016-11-23 22:58:48 +01:00
switch (action.type) {
case 'UPDATE_ORIGINAL_INPUT':
return Object.assign({}, state, {original:action.data})
2016-11-28 18:47:47 +01:00
case 'UPDATE_FINAL_INPUT':
return Object.assign({}, state, {final:action.data})
case 'CLEAR_INPUT':
2016-11-28 18:47:47 +01:00
return {original:'', final:''}
2016-11-23 22:58:48 +01:00
default:
2016-11-28 18:47:47 +01:00
return state || {original:'', final:''}
2016-11-23 22:58:48 +01:00
}
}
export function compare (state, action ) {
switch (action.type) {
case 'UPDATE_ORIGINAL_COMPARE':
return Object.assign({}, state, {original:action.data})
case 'UPDATE_FINAL_COMPARE':
return Object.assign({}, state, {final:action.data})
case 'CLEAR_COMPARE':
return {original:'', final:''}
default:
return state || {original:'', final:''}
}
}
2016-11-28 18:47:47 +01:00
export const Format = {
PLAINTEXT: 'PLAINTEXT',
MARKDOWN: 'MARKDOWN'
2016-11-23 22:58:48 +01:00
}
2016-11-28 18:47:47 +01:00
export function format (state, action) {
2016-11-23 22:58:48 +01:00
switch (action.type) {
2016-11-28 18:47:47 +01:00
case 'SET_PLAINTEXT_FORMAT':
return Format.PLAINTEXT
case 'SET_MARKDOWN_FORMAT':
return Format.MARKDOWN
2016-11-23 22:58:48 +01:00
default:
2016-11-28 18:47:47 +01:00
return state || Format.PLAINTEXT
2016-11-23 22:58:48 +01:00
}
2016-11-28 18:47:47 +01:00
}
export const Show = {
ORIGINAL:'ORIGINAL',
FINAL:'FINAL',
DIFFERENCE:'DIFFERENCE'
2016-11-23 22:58:48 +01:00
}
2016-11-28 18:47:47 +01:00
export function show (state, action) {
2016-11-23 22:58:48 +01:00
switch (action.type) {
2016-11-28 18:47:47 +01:00
case 'SHOW_ORIGINAL':
return Show.ORIGINAL
case 'SHOW_FINAL':
return Show.FINAL
case 'SHOW_DIFFERENCE':
return Show.DIFFERENCE
2016-11-23 22:58:48 +01:00
default:
2016-11-28 18:47:47 +01:00
return state || Show.DIFFERENCE
2016-11-23 22:58:48 +01:00
}
2016-11-28 18:47:47 +01:00
}