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';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
interface TracksState {
|
interface TracksState {
|
||||||
index: number;
|
|
||||||
tracks: { [index: string]: any };
|
tracks: { [index: string]: any };
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialTracks: TracksState = {
|
const initialTracks: TracksState = {
|
||||||
index: 0,
|
|
||||||
tracks: {},
|
tracks: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,8 +16,7 @@ const tracksSlice = createSlice({
|
||||||
state.tracks[action.payload.id] = action.payload.track;
|
state.tracks[action.payload.id] = action.payload.track;
|
||||||
},
|
},
|
||||||
push: (state, action) => {
|
push: (state, action) => {
|
||||||
state.tracks['$' + state.index] = action.payload;
|
state.tracks[crypto.randomUUID()] = action.payload;
|
||||||
state.index++;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue