2022-08-08 11:06:29 +00:00
|
|
|
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
|
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2018-08-15 19:51:51 +00:00
|
|
|
|
|
|
|
import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux subtree of this feature.
|
|
|
|
*/
|
|
|
|
const STORE_NAME = 'features/dropbox';
|
|
|
|
|
2022-08-08 11:06:29 +00:00
|
|
|
export interface IDropboxState {
|
|
|
|
expireDate?: number;
|
|
|
|
rToken?: string;
|
|
|
|
token?: string;
|
|
|
|
}
|
|
|
|
|
2018-08-15 19:51:51 +00:00
|
|
|
/**
|
|
|
|
* Sets up the persistence of the feature {@code dropbox}.
|
|
|
|
*/
|
|
|
|
PersistenceRegistry.register(STORE_NAME);
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IDropboxState>(STORE_NAME, (state = {}, action): IDropboxState => {
|
2018-08-15 19:51:51 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case UPDATE_DROPBOX_TOKEN:
|
|
|
|
return {
|
|
|
|
...state,
|
2021-08-30 14:43:17 +00:00
|
|
|
token: action.token,
|
|
|
|
rToken: action.rToken,
|
|
|
|
expireDate: action.expireDate
|
2018-08-15 19:51:51 +00:00
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|