Slide 34
Slide 34 text
Blob
export function toggleTopicFollow(topicId: number): Dispatchable {
return function(dispatch: Dispatch, getState: Function, api: any): void {
const { currentUser } = getState();
if (isFollowingTopic(currentUser, id)) {
api.topics.followers.delete({ topicId });
dispatch({ type: UNFOLLOW_TOPIC, payload: { topicId } });
} else {
api.topics.followers.create({ topicId });
dispatch({ type: FOLLOW_TOPIC, payload: { topicId } });
}
};
}