All files / src/store/features/trackerDocument trackerDocumentActions.ts

70% Statements 7/10
0% Branches 0/2
0% Functions 0/1
70% Lines 7/10

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 2729x 29x   29x 29x   29x                                 29x   29x  
import { createAsyncThunk } from "@reduxjs/toolkit";
import { actions } from "./trackerDocumentState";
import type { MusicAsset } from "shared/lib/resources/types";
import API from "renderer/lib/api";
import { matchAssetEntity } from "shared/lib/entities/entitiesHelpers";
 
export const convertModToUgeSong = createAsyncThunk<
  {
    data: MusicAsset;
  },
  {
    asset: MusicAsset;
    allMusic: MusicAsset[];
  }
>("tracker/convertModToUge", async ({ asset, allMusic }) => {
  const data = await API.tracker.convertModToUge(asset);
  // Find existing asset with same filename to get correct id
  const existingAsset = matchAssetEntity(data, allMusic);
  return {
    data: existingAsset ? existingAsset : data,
  };
});
 
const allActions = { ...actions, convertModToUgeSong };
 
export default allActions;