2016-10-27 10:02:12 +13:00
|
|
|
|
2016-11-13 12:55:00 +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,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 21:33:23 +13:00
|
|
|
export function dragCancel(){
|
|
|
|
|
return { type: 'DRAG_CANCEL' }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 16:17:10 +13:00
|
|
|
export function dragEnd(){
|
|
|
|
|
return { type: 'DRAG_END' }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
export function savePlaylist( uri, name, is_public = false ){
|
|
|
|
|
switch( helpers.uriSource( uri ) ){
|
|
|
|
|
|
|
|
|
|
case 'spotify':
|
|
|
|
|
return {
|
|
|
|
|
type: 'SPOTIFY_SAVE_PLAYLIST',
|
|
|
|
|
uri: uri,
|
|
|
|
|
name: name,
|
|
|
|
|
is_public: is_public
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'm3u':
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_SAVE_PLAYLIST',
|
|
|
|
|
uri: uri,
|
|
|
|
|
name: name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createPlaylist( scheme, name, is_public = false ){
|
2016-11-14 11:20:02 +13:00
|
|
|
switch( scheme ){
|
|
|
|
|
|
|
|
|
|
case 'spotify':
|
|
|
|
|
return {
|
|
|
|
|
type: 'SPOTIFY_CREATE_PLAYLIST',
|
|
|
|
|
name: name,
|
2016-11-14 17:32:36 +13:00
|
|
|
is_public: is_public
|
2016-11-14 11:20:02 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'm3u':
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_CREATE_PLAYLIST',
|
|
|
|
|
scheme: scheme,
|
|
|
|
|
name: name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-13 12:55:00 +13:00
|
|
|
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
|
|
|
|
|
}
|
2016-11-11 12:12:50 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-11 23:21:51 +13:00
|
|
|
export function addTracksToPlaylist( playlist_uri, tracks ){
|
2016-11-13 12:55:00 +13:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'm3u':
|
|
|
|
|
return {
|
2016-11-13 14:41:08 +13:00
|
|
|
type: 'MOPIDY_ADD_PLAYLIST_TRACKS',
|
2016-11-13 12:55:00 +13:00
|
|
|
playlist_uri: playlist_uri,
|
|
|
|
|
tracks_uris: tracks_uris
|
|
|
|
|
}
|
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
|
|
|
|