Fix updates

This commit is contained in:
D. Scott Boggs 2023-06-20 08:54:03 -04:00
parent a60a4c4885
commit e33ce8b1a8
2 changed files with 26 additions and 21 deletions

View file

@ -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")

View file

@ -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)