-
Notifications
You must be signed in to change notification settings - Fork 1
/
programme.js
65 lines (54 loc) · 1.36 KB
/
programme.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
import Vue from 'vue'
export default {
namespaced: true,
state: () => ({
// An optional intro track
introTrack: null,
// An optional extro track
extroTrack: null,
//
currentTime: 0.00,
// Main track events
points: []
}),
getters: {
currentTime (state) {
return state.currentTime
},
introTrack (state) {
return state.introTrack
},
extroTrack (state) {
return state.extroTrack
},
points (state) {
return state.points.sort((a, b) => a.time - b.time)
}
},
mutations: {
// Find and merge an existing cue with newly provided data
updatePoint (state, payload) {
const index = state.points.findIndex(({ id }) => id === payload.id)
Object.entries(payload).forEach(([key, value]) => {
Vue.set(state.points[index], key, value)
})
},
removePoint (state, id) {
const index = state.points.findIndex((point) => point.id === id)
Vue.delete(state.points, index)
},
addPoint (state, point) {
state.points = [...state.points, point]
},
addPoints (state, points) {
state.points = [...state.points, ...points]
},
// We can use `intro` or `extro` as a Type
setTrack(state, { type, src }) {
state[`${type}Track`] = src
},
setCurrentTime(state, time) {
state.currentTime = time
}
}
}