forked from buddyboss/buddyboss-app-custom-code-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
96 lines (80 loc) · 2.52 KB
/
index.js
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
95
96
import Podcasts from "./components/Podcasts";
export const applyCustomCode = externalCodeSetup => {
Podcasts.navigationOptions = {
header: null
}
// Podcast List
externalCodeSetup.navigationApi.addNavigationRoute(
"podcasts",
"PodcastsScreen",
Podcasts,
"All"
);
externalCodeSetup.navigationApi.addNavigationRoute(
"podcasts",
"PodcastsScreen",
Podcasts,
"Main"
);
// REDUCERS
/* Track Object:
{
id: null,
title: null,
artwork: null,
mp3: null
}
*/
const audioPlayer = {
liveRadio: {},
currentTrack: null,
currentPosition: 0,
podcasts: [],
downloads: [],
playlist: [],
playlistTrans: null,
isReady: false,
};
externalCodeSetup.reduxApi.addReducer(
"audioPlayerReducer",
(state = audioPlayer, action) => {
if (action.type === "SET_RADIO_DATA") {
console.log("APR: Live Radio", action.payload)
return {...state, liveRadio: action.payload};
} else if (action.type === "SET_CURRENT_TRACK") {
console.log("APR: Current Track", action.payload)
return {...state, currentTrack: action.payload};
} else if (action.type==='LOAD_PODCAST_DATA') {
console.log("APR API:", action.payload)
const currentArr = state.podcasts
const newArr = currentArr.concat(action.payload)
return {...state, podcasts: newArr}
} else if (action.type==='LOAD_DOWNLOAD_MP3') {
console.log("APR: DOWNLOADS", action.payload)
return {...state, downloads: action.payload}
} else if (action.type==='SET_READY') {
console.log("APR: IS READY:", action.payload)
return {...state, isReady: action.payload}
} else if (action.type==='SET_POSITION') {
return {...state, currentPosition: action.payload.position}
} else if (action.type==='CUE_TRACK') {
const currentArr = state.playlist
const payload = action.payload
const isPlaylist = currentArr.find(({id}) => id === payload.id)
console.log("APR:ISFOUND:", isPlaylist)
const newArr = !isPlaylist ? currentArr.concat(action.payload) : currentArr
return {...state, playlist: newArr}
} else if (action.type==='CUE_TRANS_TRACK') {
console.log("APR:CUETRANSTRACK:", action.payload)
return {...state, playlistTrans: action.payload}
} else if (action.type==='CUE_REMOVE') {
const playlist = state.playlist
const newArr = playlist.filter(item => item !== action.payload)
console.log("APR:REMOVECUE:", newArr)
return {...state, playlist: newArr}
} else {
return state;
}
}
);
}