Skip to content

Commit

Permalink
revert: isEditorReadyを消す
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Feb 16, 2025
1 parent 76b05fb commit a8d1d9e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 90 deletions.
146 changes: 74 additions & 72 deletions src/backend/vst/vstPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export const vstPlugin: Plugin = {
return;
}
log.info("Saving project file");
store.commit("SET_PROJECT_FILEPATH", { filePath: internalProjectFilePath });
store.commit("SET_PROJECT_FILEPATH", {
filePath: internalProjectFilePath,
});
void store.dispatch("SAVE_PROJECT_FILE", { overwrite: true });
}, 5000),
{ deep: true },
Expand All @@ -136,77 +138,77 @@ export const vstPlugin: Plugin = {
},
);

// プロジェクトの読み込み
const projectPromise = getProject();
onetimeWatch(
() => store.state.isEditorReady,
async (isEditorReady) => {
if (!isEditorReady) {
return "continue";
}

const project = await projectPromise;
if (!project) {
log.info("project not found");
isReady.value = true;
return "unwatch";
}
log.info("project found");

log.info("Engine is ready, loading project");
const loaded = await store.dispatch("LOAD_PROJECT_FILE", {
type: "path",
filePath: internalProjectFilePath,
});
// プロジェクトが読み込めなかった場合の緊急脱出口。
if (!loaded) {
log.info("Failed to load project");
const questionResult = await showQuestionDialog({
title: "プロジェクトをエクスポートしますか?",
message:
"このまま続行すると、現在プラグインに保存されているプロジェクトは破棄されます。",
buttons: [
{
text: "破棄",
color: "warning",
},
{
text: "エクスポート",
color: "primary",
},
],
cancel: "noCancel",
});
if (questionResult === 1) {
await exportProject();
}
}

// キャッシュされた歌声を読み込む
log.info("Loading cached voices");
const encodedVoices = await getVoices();
await store.actions.LOAD_SINGING_VOICE_CACHE({
cache: new Map(
await Promise.all(
Object.entries(encodedVoices).map(
async ([key, encodedVoice]) =>
[
SingingVoiceKey(key),
new Blob([await toBytes(encodedVoice)]),
] satisfies [SingingVoiceKey, SingingVoice],
),
),
),
});

log.info(`Loaded ${Object.keys(encodedVoices).length} voices`);

isReady.value = true;

return "unwatch";
},
{ deep: true },
);
// // プロジェクトの読み込み
// const projectPromise = getProject();
// onetimeWatch(
// () => store.state.projectFilePath,
// async (isEditorReady) => {
// if (!isEditorReady) {
// return "continue";
// }
//
// const project = await projectPromise;
// if (!project) {
// log.info("project not found");
// isReady.value = true;
// return "unwatch";
// }
// log.info("project found");
//
// log.info("Engine is ready, loading project");
// const loaded = await store.dispatch("LOAD_PROJECT_FILE", {
// type: "path",
// filePath: internalProjectFilePath,
// });
// // プロジェクトが読み込めなかった場合の緊急脱出口。
// if (!loaded) {
// log.info("Failed to load project");
// const questionResult = await showQuestionDialog({
// title: "プロジェクトをエクスポートしますか?",
// message:
// "このまま続行すると、現在プラグインに保存されているプロジェクトは破棄されます。",
// buttons: [
// {
// text: "破棄",
// color: "warning",
// },
// {
// text: "エクスポート",
// color: "primary",
// },
// ],
// cancel: "noCancel",
// });
// if (questionResult === 1) {
// await exportProject();
// }
// }
//
// // キャッシュされた歌声を読み込む
// log.info("Loading cached voices");
// const encodedVoices = await getVoices();
// await store.actions.LOAD_SINGING_VOICE_CACHE({
// cache: new Map(
// await Promise.all(
// Object.entries(encodedVoices).map(
// async ([key, encodedVoice]) =>
// [
// SingingVoiceKey(key),
// new Blob([await toBytes(encodedVoice)]),
// ] satisfies [SingingVoiceKey, SingingVoice],
// ),
// ),
// ),
// });
//
// log.info(`Loaded ${Object.keys(encodedVoices).length} voices`);
//
// isReady.value = true;
//
// return "unwatch";
// },
// { deep: true },
// );

// フレーズの送信。100msごとに送信する。
let lastPhrases: VstPhrase[] = [];
Expand Down
2 changes: 0 additions & 2 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,5 @@ onMounted(async () => {
} else {
isProjectFileLoaded.value = false;
}
await store.dispatch("SET_EDITOR_READY", { isEditorReady: true });
});
</script>
6 changes: 0 additions & 6 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,6 @@ export type SettingStoreTypes = {
*/

export type UiStoreState = {
isEditorReady: boolean;
uiLockCount: number;
dialogLockCount: number;
reloadingLock: boolean;
Expand Down Expand Up @@ -2034,11 +2033,6 @@ export type DialogStates = {
};

export type UiStoreTypes = {
SET_EDITOR_READY: {
mutation: { isEditorReady: boolean };
action(palyoad: { isEditorReady: boolean }): void;
};

UI_LOCKED: {
getter: boolean;
};
Expand Down
10 changes: 0 additions & 10 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function withProgress<T>(
}

export const uiStoreState: UiStoreState = {
isEditorReady: false,
uiLockCount: 0,
dialogLockCount: 0,
reloadingLock: false,
Expand All @@ -88,15 +87,6 @@ export const uiStoreState: UiStoreState = {
};

export const uiStore = createPartialStore<UiStoreTypes>({
SET_EDITOR_READY: {
mutation(state, { isEditorReady }) {
state.isEditorReady = isEditorReady;
},
action({ commit }, { isEditorReady }) {
commit("SET_EDITOR_READY", { isEditorReady });
},
},

UI_LOCKED: {
getter(state) {
return state.uiLockCount > 0;
Expand Down

0 comments on commit a8d1d9e

Please sign in to comment.