Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前回開いていたエディタ(トーク or ソング)画面を起動時に表示 #2355

Merged
merged 9 commits into from
Nov 19, 2024
10 changes: 8 additions & 2 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useGtm } from "@gtm-support/vue-gtm";
import { TooltipProvider } from "radix-vue";
import TalkEditor from "@/components/Talk/TalkEditor.vue";
import SingEditor from "@/components/Sing/SingEditor.vue";
import { EngineId } from "@/type/preload";
import { EngineId, EditorType } from "@/type/preload";
import ErrorBoundary from "@/components/ErrorBoundary.vue";
import { useStore } from "@/store";
import { useHotkeyManager } from "@/plugins/hotkeyPlugin";
Expand Down Expand Up @@ -77,6 +77,10 @@ watch(
async (openedEditor) => {
if (openedEditor != undefined) {
hotkeyManager.onEditorChange(openedEditor);
await store.dispatch("SET_ROOT_MISC_SETTING", {
key: "editorType",
value: openedEditor,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここはなくなる

}
},
);
Expand Down Expand Up @@ -111,7 +115,9 @@ onMounted(async () => {
const projectFilePath = urlParams.get("projectFilePath");

// どちらのエディタを開くか設定
await store.actions.SET_OPENED_EDITOR({ editor: "talk" });
await store.actions.SET_OPENED_EDITOR({
editor: store.state.editorType as EditorType,
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
});

// ショートカットキーの設定を登録
const hotkeySettings = store.state.hotkeySettings;
Expand Down
2 changes: 2 additions & 0 deletions src/store/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const settingStoreState: SettingStoreState = {
},
showSingCharacterPortrait: true,
playheadPositionDisplayFormat: "MINUTES_SECONDS",
editorType: "talk",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openedEditorに

};

export const settingStore = createPartialStore<SettingStoreTypes>({
Expand Down Expand Up @@ -148,6 +149,7 @@ export const settingStore = createPartialStore<SettingStoreTypes>({
"undoableTrackOperations",
"showSingCharacterPortrait",
"playheadPositionDisplayFormat",
"editorType",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここもopenedEditor

] as const;

// rootMiscSettingKeysに値を足し忘れていたときに型エラーを出す検出用コード
Expand Down
5 changes: 5 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,11 @@ export type UiStoreTypes = {
action(payload: { activePointScrollMode: ActivePointScrollMode }): void;
};

SET_EDITOR_TYPE: {
mutation: { editorType: EditorType };
action(payload: { editorType: EditorType }): void;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これもなくせるはず


SET_AVAILABLE_THEMES: {
mutation: { themes: ThemeConf[] };
};
Expand Down
17 changes: 16 additions & 1 deletion src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
UiStoreTypes,
} from "./type";
import { createPartialStore } from "./vuex";
import { ActivePointScrollMode } from "@/type/preload";
import { ActivePointScrollMode, EditorType } from "@/type/preload";
import {
AlertDialogOptions,
ConfirmDialogOptions,
Expand Down Expand Up @@ -260,6 +260,10 @@ export const uiStore = createPartialStore<UiStoreTypes>({
),
});

mutations.SET_OPENED_EDITOR({
editor: await window.backend.getSetting("editorType"),
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HYDRATE_SETTING_STORE内のmutations.SET_ROOT_MISC_SETTINGがあるのでこのコードはなくても良いはず!

(さらに言うと上のmutations.SET_ACTIVE_POINT_SCROLL_MODEとかもいらなそうだけど・・・まあ一旦放置で・・・。
あ、もし気が向いたら別でプルリクエストとかいただけるとめちゃくちゃ嬉しいです!!)

// electron-window-stateがvuex初期化前に働くので
// ここで改めてelectron windowの最大化状態をVuex storeに同期
if (await window.backend.isMaximizedWindow()) {
Expand Down Expand Up @@ -335,6 +339,17 @@ export const uiStore = createPartialStore<UiStoreTypes>({
},
},

SET_EDITOR_TYPE: {
mutation(state, { editorType }: { editorType: EditorType }) {
state.editorType = editorType;
},
async action({ mutations }, { editorType }: { editorType: EditorType }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここもなくせそう!

mutations.SET_OPENED_EDITOR({
editor: await window.backend.setSetting("editorType", editorType),
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mutations.SET_OPENED_EDITOR({
editor: await window.backend.setSetting("editorType", editorType),
});
await window.backend.setSetting("editorType", editorType)
mutations.SET_OPENED_EDITOR({
editor: editorType,
});

普通に分けた方が良さそう。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私もそちらが分かりやすそうに思えます。ただ、既存のSET_INHERIT_AUDIOINFOやSET_ACTIVE_POINT_SCROLL_MODEでは引数内で記述されているので統一感を考慮してSET_EDITOR_TYPEもそれに倣いました。これらの関数がどのような意図や都合で書かれたか分からないため、判断に迷っています。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かにこれ混乱しますね!!
僕も正確なところがちょっとわかんないです。。。

最初は設定ごとにSETのためのmutation/actionがあったのですが、後々に統合されたSET_ROOT_MISC_SETTINGができました。
なので大多数はSET_ROOT_MISC_SETTINGを使ってますが、どうやらまだ個別にSETしているものが残っていたっぽいです・・・!

今回の場合は多分SET_EDITOR_TYPEは用意せず、SET_ROOT_MISC_SETTINGを使う形が良さそうに感じました!

},
},

/**
* 選択可能なテーマをセットする。
* NOTE: カスタムテーマが導入された場合を見越して残している。
Expand Down
2 changes: 2 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ export const rootMiscSettingSchema = z.object({
playheadPositionDisplayFormat: z
.enum(["MINUTES_SECONDS", "MEASURES_BEATS"])
.default("MINUTES_SECONDS"), // 再生ヘッド位置の表示モード
editorType: z.enum(["talk", "song"]).default("talk"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここをopenedEditorに変える感じで・・・!
(これが今回の提案の肝)

});
export type RootMiscSettingType = z.infer<typeof rootMiscSettingSchema>;

Expand All @@ -603,6 +604,7 @@ export const configSchema = z
activePointScrollMode: z
.enum(["CONTINUOUSLY", "PAGE", "OFF"])
.default("OFF"),
editorType: z.enum(["talk", "song"]).default("talk"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rootMiscSettingSchema側にあるのでこちらいらないはず!

savingSetting: z
.object({
fileEncoding: z.enum(["UTF-8", "Shift_JIS"]).default("UTF-8"),
Expand Down
Loading