2018-03-07 00:28:19 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { ReducerRegistry } from '../base/redux';
|
|
|
|
|
2019-10-08 12:27:35 +00:00
|
|
|
import { SET_DOCUMENT_EDITING_STATUS, SET_DOCUMENT_URL } from './actionTypes';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2019-04-17 15:05:32 +00:00
|
|
|
const DEFAULT_STATE = {
|
|
|
|
|
2019-10-04 15:10:19 +00:00
|
|
|
/**
|
|
|
|
* URL for the shared document.
|
|
|
|
*/
|
|
|
|
documentUrl: undefined,
|
|
|
|
|
2019-04-17 15:05:32 +00:00
|
|
|
/**
|
|
|
|
* Whether or not Etherpad is currently open.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2019-10-08 12:27:35 +00:00
|
|
|
editing: false
|
2019-04-17 15:05:32 +00:00
|
|
|
};
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
|
|
|
* Reduces the Redux actions of the feature features/etherpad.
|
|
|
|
*/
|
2019-04-17 15:05:32 +00:00
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/etherpad',
|
|
|
|
(state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case SET_DOCUMENT_EDITING_STATUS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editing: action.editing
|
|
|
|
};
|
|
|
|
|
2019-10-04 15:10:19 +00:00
|
|
|
case SET_DOCUMENT_URL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentUrl: action.documentUrl
|
|
|
|
};
|
|
|
|
|
2019-04-17 15:05:32 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|