Using UUIDs to identify tracks (instead of a numerical index) to make it easier to synchronize databases.

This commit is contained in:
Eric van der Vlist 2022-09-23 15:07:39 +02:00
parent a212841c6c
commit bb2130793d
1 changed files with 1 additions and 4 deletions

View File

@ -1,12 +1,10 @@
import { createSlice } from '@reduxjs/toolkit';
interface TracksState {
index: number;
tracks: { [index: string]: any };
}
const initialTracks: TracksState = {
index: 0,
tracks: {},
};
@ -18,8 +16,7 @@ const tracksSlice = createSlice({
state.tracks[action.payload.id] = action.payload.track;
},
push: (state, action) => {
state.tracks['$' + state.index] = action.payload;
state.index++;
state.tracks[crypto.randomUUID()] = action.payload;
},
},
});