Sort track in track list
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
23fb78b037
commit
4f615662f3
@ -2,6 +2,18 @@ import { writable } from 'svelte/store';
|
|||||||
|
|
||||||
import { getTracks } from '$lib/track'
|
import { getTracks } from '$lib/track'
|
||||||
|
|
||||||
|
function cmpTracks(a, b) {
|
||||||
|
if (a.enabled && !b.enabled) return -1;
|
||||||
|
if (!a.enabled && b.enabled) return 1;
|
||||||
|
|
||||||
|
if (a.path.toLowerCase() > b.path.toLowerCase())
|
||||||
|
return 1;
|
||||||
|
if (a.path.toLowerCase() < b.path.toLowerCase())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
function createTracksStore() {
|
function createTracksStore() {
|
||||||
const { subscribe, set, update } = writable({list: null});
|
const { subscribe, set, update } = writable({list: null});
|
||||||
|
|
||||||
@ -14,6 +26,7 @@ function createTracksStore() {
|
|||||||
|
|
||||||
refresh: async () => {
|
refresh: async () => {
|
||||||
const list = await getTracks();
|
const list = await getTracks();
|
||||||
|
list.sort(cmpTracks);
|
||||||
update((m) => Object.assign(m, {list}));
|
update((m) => Object.assign(m, {list}));
|
||||||
return list;
|
return list;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user