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-30 09:32:46 +13:00
|
|
|
export function toggleSidebar( new_state = 'toggle' ){
|
|
|
|
|
var action = { type: 'TOGGLE_SIDEBAR' }
|
|
|
|
|
if( new_state != 'toggle' ) action.new_state = new_state
|
|
|
|
|
return action
|
2016-11-21 21:46:53 +13:00
|
|
|
}
|
|
|
|
|
|
2016-11-15 17:08:21 +13:00
|
|
|
export function dragStart( e, context, victims, victims_indexes = false ){
|
2016-11-10 16:17:10 +13:00
|
|
|
return {
|
|
|
|
|
type: 'DRAG_START',
|
|
|
|
|
context: context,
|
|
|
|
|
victims: victims,
|
2016-11-15 17:08:21 +13:00
|
|
|
victims_indexes: victims_indexes,
|
|
|
|
|
start_x: e.clientX,
|
|
|
|
|
start_y: e.clientY
|
2016-11-10 16:17:10 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 17:08:21 +13:00
|
|
|
export function dragActive(){
|
|
|
|
|
return { type: 'DRAG_ACTIVE' }
|
2016-11-10 21:33:23 +13:00
|
|
|
}
|
|
|
|
|
|
2016-11-10 16:17:10 +13:00
|
|
|
export function dragEnd(){
|
|
|
|
|
return { type: 'DRAG_END' }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 10:06:25 +13:00
|
|
|
export function setView( view ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'SET_VIEW',
|
|
|
|
|
view: view
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 16:30:49 +13:00
|
|
|
export function reorderPlaylistTracks( uri, indexes, insert_before, snapshot_id = false ){
|
|
|
|
|
var range = helpers.createRange( indexes );
|
2016-11-16 13:13:35 +13:00
|
|
|
switch( helpers.uriSource( uri ) ){
|
2016-11-15 17:08:21 +13:00
|
|
|
|
2016-11-16 13:13:35 +13:00
|
|
|
case 'spotify':
|
2016-11-15 17:08:21 +13:00
|
|
|
return {
|
2016-11-16 13:13:35 +13:00
|
|
|
type: 'SPOTIFY_REORDER_PLAYLIST_TRACKS',
|
|
|
|
|
uri: uri,
|
2016-11-16 16:30:49 +13:00
|
|
|
range_start: range.start,
|
|
|
|
|
range_length: range.length,
|
|
|
|
|
insert_before: insert_before,
|
2016-11-16 14:58:08 +13:00
|
|
|
snapshot_id: snapshot_id
|
2016-11-15 17:08:21 +13:00
|
|
|
}
|
|
|
|
|
|
2016-11-16 13:13:35 +13:00
|
|
|
case 'm3u':
|
2016-11-15 17:08:21 +13:00
|
|
|
return {
|
2016-11-16 13:13:35 +13:00
|
|
|
type: 'MOPIDY_REORDER_PLAYLIST_TRACKS',
|
|
|
|
|
uri: uri,
|
2016-11-16 16:30:49 +13:00
|
|
|
range_start: range.start,
|
|
|
|
|
range_length: range.length,
|
|
|
|
|
insert_before: insert_before
|
2016-11-15 17:08:21 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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-24 13:35:21 +13:00
|
|
|
export function addTracksToPlaylist( playlist_uri, tracks ){
|
|
|
|
|
var tracks_uris = helpers.asURIs(tracks)
|
2016-11-13 12:55:00 +13:00
|
|
|
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
|
|
|
|