Files
Iris/src/js/services/ui/actions.js

132 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-10-27 10:02:12 +13:00
import * as helpers from '../../helpers'
2016-10-27 10:02:12 +13:00
export function showContextMenu( e, context = false, data ){
return {
2016-11-09 15:51:38 +13:00
type: 'SHOW_CONTEXT_MENU',
2016-10-27 10:02:12 +13:00
position_x: e.clientX,
position_y: e.clientY,
context: context,
data: data
}
}
export function hideContextMenu(){
2016-11-09 15:49:25 +13:00
return {
2016-11-09 15:51:38 +13:00
type: 'HIDE_CONTEXT_MENU'
2016-11-09 15:49:25 +13:00
}
}
export function searchStarted(){
2016-10-27 10:02:12 +13:00
return {
2016-11-09 15:49:25 +13:00
type: 'SEARCH_STARTED',
data: {
artists: [],
albums: [],
playlists: [],
tracks: [],
artists_more: false,
albums_more: false,
playlists_more: false,
tracks_more: false
}
2016-10-27 10:02:12 +13:00
}
}
2016-11-01 08:57:28 +13:00
export function lazyLoading( start ){
return {
2016-11-09 15:51:38 +13:00
type: 'LAZY_LOADING',
2016-11-01 08:57:28 +13:00
start: start
}
}
2016-11-10 16:17:10 +13:00
export function dragStart( e, context, victims ){
return {
type: 'DRAG_START',
context: context,
victims: victims,
position_x: e.clientX,
position_y: e.clientY
}
}
export function dragMove( e ){
return {
type: 'DRAG_MOVE',
position_x: e.clientX,
position_y: e.clientY,
}
}
export function dragCancel(){
return { type: 'DRAG_CANCEL' }
}
2016-11-10 16:17:10 +13:00
export function dragEnd(){
return { type: 'DRAG_END' }
}
export function removeTracksFromPlaylist( playlist_uri, tracks_indexes ){
switch( helpers.uriSource( playlist_uri ) ){
case 'spotify':
return {
type: 'SPOTIFY_REMOVE_PLAYLIST_TRACKS',
playlist_uri: playlist_uri,
tracks_indexes: tracks_indexes
}
case 'm3u':
return {
type: 'MOPIDY_REMOVE_PLAYLIST_TRACKS',
playlist_uri: playlist_uri,
tracks_indexes: tracks_indexes
}
defaut:
return ui
}
}
2016-11-11 23:21:51 +13:00
export function addTracksToPlaylist( playlist_uri, tracks ){
var tracks_uris = []
for( var i = 0; i < tracks.length; i++ ){
tracks_uris.push( tracks[i].uri )
}
switch( helpers.uriSource( playlist_uri ) ){
case 'spotify':
return {
type: 'SPOTIFY_ADD_PLAYLIST_TRACKS',
playlist_uri: playlist_uri,
tracks_uris: tracks_uris
}
break;
case 'm3u':
return {
type: 'MOPIDY_ADD_PLAYLIST_TRACKS',
playlist_uri: playlist_uri,
tracks_uris: tracks_uris
}
break;
2016-11-11 23:21:51 +13:00
}
}
export function openModal( name, data ){
return {
type: 'OPEN_MODAL',
modal: {
name: name,
data: data
}
}
}
export function closeModal(){
return { type: 'CLOSE_MODAL' }
}
2016-10-27 10:02:12 +13:00