From b42408d6c3053d86e15f8a63fd6048a8918bdc47 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Thu, 1 Aug 2024 02:26:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=A9=E3=83=83=E3=82=AF=E3=82=92?= =?UTF-8?q?=E4=B8=8A=E6=9B=B8=E3=81=8D=E3=81=97=E3=81=A6=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=88=E3=81=99=E3=82=8B=E4=BB=95=E7=B5=84?= =?UTF-8?q?=E3=81=BF=E3=82=92=E5=85=83=E3=81=AE=E4=BB=95=E6=A7=98=E3=81=AB?= =?UTF-8?q?=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sing/domain.ts | 3 ++- src/store/singing.ts | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/sing/domain.ts b/src/sing/domain.ts index fc85b72683..6d84530b73 100644 --- a/src/sing/domain.ts +++ b/src/sing/domain.ts @@ -21,7 +21,8 @@ const BEAT_TYPES = [2, 4, 8, 16]; const MIN_BPM = 40; const MAX_SNAP_TYPE = 32; -export const isTrackEmpty = (track: Track) => track.notes.length === 0; +export const isTracksEmpty = (tracks: Track[]) => + tracks.length === 0 || (tracks.length === 1 && tracks[0].notes.length === 0); export const isValidTpqn = (tpqn: number) => { return ( diff --git a/src/store/singing.ts b/src/store/singing.ts index a5c84bd916..187620a989 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -76,7 +76,7 @@ import { isValidTrack, SEQUENCER_MIN_NUM_MEASURES, getNumMeasures, - isTrackEmpty, + isTracksEmpty, shouldPlayTracks, } from "@/sing/domain"; import { @@ -2762,7 +2762,7 @@ export const singingCommandStore = transformCommandStore( }, /** * 複数のトラックを選択中のトラックの後ろに挿入し、テンポ情報などをインポートする。 - * 選択中のトラックが空の場合は最初のトラックで上書きする。 + * 空のプロジェクトならトラックを上書きする。 */ async action( { state, commit, getters, dispatch }, @@ -2778,11 +2778,8 @@ export const singingCommandStore = transformCommandStore( if (!isValidTrack(track)) { throw new Error("The track is invalid."); } - // 空のトラックなら上書きする - if ( - i === 0 && - isTrackEmpty(getOrThrow(state.tracks, prevTrackId)) - ) { + // 空のプロジェクトならトラックを上書きする + if (i === 0 && isTracksEmpty([...state.tracks.values()])) { payload.push({ track, trackId: prevTrackId,