import { push } from 'react-router-redux'
import {playlistService} from "nexshop-web-store";
import {contentsActions} from "nexshop-web-store";
export const CREATE_PLAYLIST = 'CREATE_PLAYLIST';
export const START_DRAG_CONTENTS_ITEM = 'START_DRAG_CONTENTS_ITEM';
export const DROP_DRAG_CONTENTS_ITEM = 'DROP_DRAG_CONTENTS_ITEM';
export const DELETE_CONTENT_ITEM = 'DELETE_CONTENT_ITEM';
export const CHANGE_CONTENT_ITEMS_ORDER_START = 'CHANGE_CONTENT_ITEMS_ORDER_START';
export const CHANGE_CONTENT_ITEMS_ORDER_PROCESS = 'CHANGE_CONTENT_ITEMS_ORDER_PROCESS';
export const CHANGE_CONTENT_ITEMS_ORDER_END = 'CHANGE_CONTENT_ITEMS_ORDER_END';
export const UPDATE_CONTENT_ITEM_TRANSITION = 'UPDATE_CONTENT_ITEM_TRANSITION';
export const UPDATE_CONTENT_ITEM_DURATION = 'UPDATE_CONTENT_ITEM_DURATION';
export const DISCARD_PLAYLIST = 'DISCARD_PLAYLIST';
export function createPlaylist(name, resolution) {
return {
type: CREATE_PLAYLIST,
name,
resolution
}
}
export function savePlaylistAsync(playlist) {
return async (dispatch) => {
try {
const data = await playlistService.savePlaylist(playlist);
dispatch(contentsActions.addContentsItem(data, 0));
dispatch(discardPlaylist());
dispatch(push('/contents/main'));
} catch(error) {
alert(error.errorMessage);
}
}
}
export function startDragContentsItem(contentsItem) {
return {
type: START_DRAG_CONTENTS_ITEM,
contentsItem
}
}
export function dropDragContentsItem() {
return {
type: DROP_DRAG_CONTENTS_ITEM
}
}
export function deleteContentItem(index) {
return {
type: DELETE_CONTENT_ITEM,
index
}
}
export function changeContentItemsOrderStart(index) {
return {
type: CHANGE_CONTENT_ITEMS_ORDER_START,
index
}
}
export function changeContentItemsOrderProcess(index) {
return {
type: CHANGE_CONTENT_ITEMS_ORDER_PROCESS,
index
}
}
export function changeContentItemsOrderEnd() {
return {
type: CHANGE_CONTENT_ITEMS_ORDER_END
}
}
export function updateContentItemTransition(uuid, transitionEffect) {
return {
type: UPDATE_CONTENT_ITEM_TRANSITION,
uuid, transitionEffect
}
}
export function updateContentItemDuration(uuid, durationSeconds) {
return {
type: UPDATE_CONTENT_ITEM_DURATION,
uuid, durationSeconds
}
}
export function discardPlaylist() {
return {
type: DISCARD_PLAYLIST
}
} |