2022-08-08 11:06:29 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-08-08 11:06:29 +00:00
|
|
|
export interface IEtherpadState {
|
|
|
|
documentUrl?: string;
|
|
|
|
editing: boolean;
|
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
|
|
|
* Reduces the Redux actions of the feature features/etherpad.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IEtherpadState>(
|
2019-04-17 15:05:32 +00:00
|
|
|
'features/etherpad',
|
2022-09-05 09:05:07 +00:00
|
|
|
(state = DEFAULT_STATE, action): IEtherpadState => {
|
2019-04-17 15:05:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|