Follow track change when toggle
This commit is contained in:
parent
cc301da971
commit
69ddfd48e9
@ -58,6 +58,10 @@ func (t *Track) Rename(newName string) error {
|
||||
}
|
||||
|
||||
t.Path = newPath
|
||||
|
||||
// Recalculate hash
|
||||
hash := sha512.Sum512([]byte(t.Path))
|
||||
t.Id = hash[:]
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -73,6 +77,10 @@ func (t *Track) MoveTo(path string) error {
|
||||
}
|
||||
|
||||
t.Path = path
|
||||
|
||||
// Recalculate hash
|
||||
hash := sha512.Sum512([]byte(t.Path))
|
||||
t.Id = hash[:]
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,9 @@ export class Track {
|
||||
}
|
||||
}
|
||||
|
||||
toggleEnable() {
|
||||
async toggleEnable() {
|
||||
this.enabled = !this.enabled;
|
||||
this.save();
|
||||
return this;
|
||||
return await this.save();
|
||||
}
|
||||
|
||||
async save() {
|
||||
@ -39,7 +38,7 @@ export class Track {
|
||||
if (res.status == 200) {
|
||||
const data = await res.json();
|
||||
this.update(data);
|
||||
return data;
|
||||
return this;
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
|
@ -14,6 +14,12 @@
|
||||
import { getTrack } from '$lib/track';
|
||||
import { tracks } from '$lib/stores/tracks';
|
||||
|
||||
function toggleEnable(track) {
|
||||
track.toggleEnable().then((t) => {
|
||||
tracks.refresh();
|
||||
goto('musiks/tracks/' + t.id);
|
||||
})
|
||||
}
|
||||
function deleteThis(track) {
|
||||
track.delete().then(() => {
|
||||
tracks.refresh();
|
||||
@ -38,7 +44,7 @@
|
||||
</ListGroupItem>
|
||||
<ListGroupItem class="d-flex gap-2">
|
||||
<strong>Active ?</strong>
|
||||
<Input type="switch" on:change={() => track.toggleEnable()} checked={track.enabled} />
|
||||
<Input type="switch" on:change={() => toggleEnable(track)} checked={track.enabled} />
|
||||
</ListGroupItem>
|
||||
<ListGroupItem>
|
||||
<strong>ID</strong>
|
||||
|
Loading…
Reference in New Issue
Block a user