Skip to content

Commit

Permalink
uuidをfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Nov 14, 2024
1 parent 5ac0860 commit 18580d5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/domain/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DEFAULT_TPQN,
DEFAULT_TRACK_NAME,
} from "@/sing/domain";
import { uuid4 } from "@/helpers/random";

const DEFAULT_SAMPLING_RATE = 24000;

Expand Down Expand Up @@ -296,7 +297,7 @@ export const migrateProjectFileObject = async (
track.mute = false;
track.gain = 1;
track.pan = 0;
newTracks[TrackId(crypto.randomUUID())] = track;
newTracks[TrackId(uuid4())] = track;
}
projectData.song.tracks = newTracks;
projectData.song.trackOrder = Object.keys(newTracks);
Expand Down
3 changes: 2 additions & 1 deletion src/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
showAlertDialog,
showQuestionDialog,
} from "@/components/Dialog/Dialog";
import { uuid4 } from "@/helpers/random";

export const projectStoreState: ProjectStoreState = {
savedLastCommandIds: { talk: null, song: null },
Expand Down Expand Up @@ -125,7 +126,7 @@ export const projectStore = createPartialStore<ProjectStoreTypes>({
await context.actions.SET_TIME_SIGNATURES({
timeSignatures: [createDefaultTimeSignature(1)],
});
const trackId = TrackId(crypto.randomUUID());
const trackId = TrackId(uuid4());
await context.actions.SET_TRACKS({
tracks: new Map([[trackId, createDefaultTrack()]]),
});
Expand Down
4 changes: 2 additions & 2 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ const singingPitchCache = new Map<SingingPitchKey, SingingPitch>();
const singingVolumeCache = new Map<SingingVolumeKey, SingingVolume>();
const singingVoiceCache = new Map<SingingVoiceKey, SingingVoice>();

const initialTrackId = TrackId(crypto.randomUUID());
const initialTrackId = TrackId(uuid4());

/**
* シーケンスの音源の出力を取得する。
Expand Down Expand Up @@ -1577,7 +1577,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({

CREATE_TRACK: {
action() {
const trackId = TrackId(crypto.randomUUID());
const trackId = TrackId(uuid4());
const track = createDefaultTrack();

return { trackId, track };
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/domain/__snapshots__/project.spec.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/unit/domain/project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import path from "path";
import fs from "fs";
import { migrateProjectFileObject } from "@/domain/project";
import { EngineId, SpeakerId, StyleId } from "@/type/preload";
import { resetMockMode } from "@/helpers/random";

const engineId = EngineId("074fc39e-678b-4c13-8916-ffca8d505d1d");

const vvprojDir = "tests/unit/domain/vvproj/";

beforeEach(() => {
resetMockMode();
});

describe("migrateProjectFileObject", () => {
test("v0.14.11", async () => {
// 8期生のプロジェクトファイル
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/domain/sing/shouldPlayTracks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { uuid4 } from "@/helpers/random";
import { createDefaultTrack, shouldPlayTracks } from "@/sing/domain";
import { Track } from "@/store/type";
import { TrackId } from "@/type/preload";
Expand All @@ -10,7 +11,7 @@ const createTrack = ({ solo, mute }: { solo: boolean; mute: boolean }) => {
};
const toTracksMap = (tracks: Track[]) => {
return tracks.reduce((acc, track) => {
acc.set(TrackId(crypto.randomUUID()), track);
acc.set(TrackId(uuid4()), track);
return acc;
}, new Map<TrackId, Track>());
};
Expand Down

0 comments on commit 18580d5

Please sign in to comment.