All files / nexshop-web-contents/src/action playlist.js

100% Statements 29/29
100% Branches 0/0
100% Functions 12/12
100% Lines 29/29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 951x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     3x               4x 3x 3x 2x 2x 2x   1x           2x             1x           2x             4x             4x             2x           3x             3x             5x      
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
    }
}