Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { createEntityAdapter, createSlice, PayloadAction, } from "@reduxjs/toolkit"; import type { MusicAsset } from "shared/lib/resources/types"; const musicAssetsAdapter = createEntityAdapter<MusicAsset>(); const musicAssetsSlice = createSlice({ name: "musicAssets", initialState: musicAssetsAdapter.getInitialState(), reducers: { setMusicAssets: (state, action: PayloadAction<MusicAsset[]>) => musicAssetsAdapter.setAll(state, action.payload), renameMusicAsset: ( state, action: PayloadAction<{ musicId: string; newFilename: string }>, ) => { const existing = state.entities[action.payload.musicId]; Iif (!existing) { return; } musicAssetsAdapter.updateOne(state, { id: action.payload.musicId, changes: { filename: action.payload.newFilename, name: action.payload.newFilename.replace(/\.[^.]+$/, ""), }, }); }, removeMusicAsset: (state, action: PayloadAction<{ musicId: string }>) => musicAssetsAdapter.removeOne(state, action.payload.musicId), }, }); export const { actions: musicAssetActions, reducer: musicAssetsReducer } = musicAssetsSlice; |