2018-12-07 18:59:16 +02:00
|
|
|
import {
|
|
|
|
START_LOADING_ALL_TOPICS,
|
|
|
|
LOADED_ALL_TOPICS,
|
|
|
|
START_LOADING_RANDOM_TOPIC,
|
|
|
|
LOADED_RANDOM_TOPIC
|
|
|
|
} from '../actions/action_types';
|
|
|
|
|
|
|
|
export default function(state={}, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
|
|
|
|
case START_LOADING_ALL_TOPICS:
|
|
|
|
return Object.assign({}, state, { loadingAllTopics: true });
|
|
|
|
|
|
|
|
case LOADED_ALL_TOPICS:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
loadingAllTopics: false,
|
|
|
|
allTopics: action.payload
|
|
|
|
});
|
|
|
|
|
|
|
|
case START_LOADING_RANDOM_TOPIC:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
loadingRandomTopic: true
|
|
|
|
});
|
|
|
|
|
|
|
|
case LOADED_RANDOM_TOPIC:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
loadingRandomTopic: false,
|
2018-12-07 19:37:57 +02:00
|
|
|
randomTopic: action.payload.topic.name,
|
|
|
|
randomTopicCount: action.payload.topic.items,
|
2018-12-07 18:59:16 +02:00
|
|
|
randomTopicVideos: action.payload.videos
|
|
|
|
});
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|