Fix updates
This commit is contained in:
parent
a60a4c4885
commit
e33ce8b1a8
|
@ -9,7 +9,7 @@ import { Track } from '../track';
|
|||
|
||||
const props = defineProps<{ date: Date, track: Track }>()
|
||||
|
||||
const isSet = computed(() => props.track.isSetOn(props.date))
|
||||
const isSet = computed(() => state.tracks.find(track => track.id === props.track.id)?.isSetOn(props.date))
|
||||
|
||||
const className = computed(() => isSet.value ? "button is-rounded is-info" : "button is-rounded")
|
||||
|
||||
|
|
|
@ -18,33 +18,38 @@ export const state = reactive({
|
|||
source.addEventListener('TickAdded', event => {
|
||||
console.log(event)
|
||||
const tick: Tick = JSON.parse(event.data)
|
||||
for (const track of this.tracks) {
|
||||
if (track.id === tick.track_id) {
|
||||
console.debug('pushing tick')
|
||||
track.ticks?.push(tick)
|
||||
}
|
||||
}
|
||||
// this.tracks = this.tracks.map(track => {
|
||||
// for (const track of this.tracks) {
|
||||
// if (track.id === tick.track_id) {
|
||||
// const ticks = track.ticks ?? []
|
||||
// ticks.push(tick)
|
||||
// track.ticks = ticks
|
||||
// console.debug('pushing tick')
|
||||
// track.ticks?.push(tick)
|
||||
// }
|
||||
// return track
|
||||
// })
|
||||
// }
|
||||
const tracks = this.tracks.map(track => {
|
||||
if (track.id === tick.track_id) {
|
||||
const ticks = track.ticks ?? []
|
||||
ticks.push(tick)
|
||||
track.ticks = ticks
|
||||
|
||||
}
|
||||
return track
|
||||
})
|
||||
console.debug(tracks)
|
||||
this.tracks = tracks
|
||||
})
|
||||
source.addEventListener('TickDropped', event => {
|
||||
console.log(event)
|
||||
const tick: Tick = JSON.parse(event.data)
|
||||
for (const track of this.tracks)
|
||||
if (track.id === tick.track_id)
|
||||
track.ticks = track.ticks?.filter($tick => $tick.id === tick.id)
|
||||
// this.tracks = this.tracks.map(track => {
|
||||
// if (track.id === tick.track_id) {
|
||||
// for (const track of this.tracks)
|
||||
// if (track.id === tick.track_id)
|
||||
// track.ticks = track.ticks?.filter($tick => $tick.id === tick.id)
|
||||
// }
|
||||
// return track
|
||||
// })
|
||||
const tracks = this.tracks.map(track => {
|
||||
if (track.id === tick.track_id) {
|
||||
track.ticks = track.ticks?.filter($tick => $tick.id !== tick.id)
|
||||
}
|
||||
return track
|
||||
})
|
||||
console.debug(tracks)
|
||||
this.tracks = tracks
|
||||
})
|
||||
source.addEventListener('Lagged', event => {
|
||||
console.log(event)
|
||||
|
|
Loading…
Reference in a new issue