Using UUIDs to identify tracks (instead of a numerical index) to make it easier to synchronize databases.
This commit is contained in:
parent
a212841c6c
commit
bb2130793d
|
@ -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;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue