[Update] Add hotkeys main functions

This commit is contained in:
Sakamoto Shiina
2025-01-17 02:41:27 +09:00
parent 34d221c437
commit bac7bb15d3
11 changed files with 145 additions and 57 deletions

View File

@@ -55,20 +55,20 @@ const createAtomWithHook = (initialValue, base_name, options) => {
});
};
const updateAtom = (payload) => {
const updateAtom = (payload, options = {}) => {
const { remain_state = false, set_state } = options;
setAtom((currentValue) => {
if (typeof payload === "function") {
const updated_data = payload(currentValue);
return {
state: "ok",
data: updated_data,
};
} else {
return {
state: "ok",
data: payload,
};
}
const new_state = set_state ?? (remain_state ? currentValue.state : "ok");
const updated_data = typeof payload === "function"
? payload(currentValue)
: payload;
return {
state: new_state,
data: updated_data,
};
});
};
@@ -266,7 +266,10 @@ export const { atomInstance: Atom_EnableSendReceivedMessageToVrc, useHook: useSt
// Hotkeys
export const { atomInstance: Atom_Hotkeys, useHook: useStore_Hotkeys } = createAtomWithHook({
toggle_active_vrct: null,
toggle_vrct_visibility: null,
toggle_translation: null,
toggle_transcription_send: null,
toggle_transcription_receive: null,
}, "Hotkeys");
// Advanced Settings