Skip to content

Commit

Permalink
プロジェクト周りのテストを通るようにする+0区間のバグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
romot-co committed Jan 27, 2025
1 parent 7b25f3c commit 2ea81f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/components/Sing/ScoreSequencer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
:offset="scrollX"
:numMeasures
/>
<!-- ループエリア -->
<LoopLane :offset="scrollX" />
<!-- 鍵盤 -->
<SequencerKeys
class="sequencer-keys"
Expand Down
14 changes: 9 additions & 5 deletions src/components/Sing/SequencerRuler/LoopLane/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,22 @@ const stopDragging = () => {
}
try {
// ループ範囲が0の場合はクリア
if (previewLoopStartTick.value === previewLoopEndTick.value) {
void store.actions.COMMAND_CLEAR_LOOP_RANGE();
return;
}
// ループ範囲を設定
void store.actions.COMMAND_SET_LOOP_RANGE({
loopStartTick: previewLoopStartTick.value,
loopEndTick: previewLoopEndTick.value,
});
// ループ範囲が有効な場合は再生ヘッドをループ開始位置に移動
if (previewLoopStartTick.value !== previewLoopEndTick.value) {
void store.actions.SET_PLAYHEAD_POSITION({
position: previewLoopStartTick.value,
});
}
void store.actions.SET_PLAYHEAD_POSITION({
position: previewLoopStartTick.value,
});
} catch (error) {
throw new UnreachableError("Failed to set loop range");
}
Expand Down
8 changes: 2 additions & 6 deletions src/domain/project/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export const trackSchema = z.object({
});

export const loopSchema = z.object({
isLoopEnabled: z.boolean(),
startTick: z.number(), // ループ開始ティック
endTick: z.number(), // ループ終了ティック
isLoopEnabled: z.boolean(),
});

// プロジェクトファイルのスキーマ
Expand All @@ -120,11 +120,7 @@ export const projectSchema = z.object({
timeSignatures: z.array(timeSignatureSchema),
tracks: z.record(trackIdSchema, trackSchema),
trackOrder: z.array(trackIdSchema),
loop: z.object({
startTick: z.number(),
endTick: z.number(),
isLoopEnabled: z.boolean(),
}),
loop: loopSchema.optional(),
}),
});

Expand Down
11 changes: 8 additions & 3 deletions src/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ const applySongProjectToStore = async (
}),
),
});
await actions.SET_LOOP_ENABLED({ isLoopEnabled: loop.isLoopEnabled });

// ループ情報を設定(ない場合はデフォルト値を使用)
// TODO: オプショナルチェインを避けたい(プロジェクト関連の仕様がよくわかっていない)
await actions.SET_LOOP_ENABLED({
isLoopEnabled: loop?.isLoopEnabled ?? false,
});
await actions.SET_LOOP_RANGE({
loopStartTick: loop.startTick,
loopEndTick: loop.endTick,
loopStartTick: loop?.startTick ?? 0,
loopEndTick: loop?.endTick ?? 0,
});
};

Expand Down

0 comments on commit 2ea81f9

Please sign in to comment.