[bugfix/Refactor]
Fix plugin compatibility list that was showed incorrectly. Change init function.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { useRef } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -29,10 +28,6 @@ export const App = () => {
|
|||||||
const { currentIsBackendReady } = useIsBackendReady();
|
const { currentIsBackendReady } = useIsBackendReady();
|
||||||
const { WindowGeometryController } = useWindow();
|
const { WindowGeometryController } = useWindow();
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const pluginsControllerHasRunRef = useRef({
|
|
||||||
is_initialized_load_plugin: false,
|
|
||||||
is_init_fetched_plugins_info: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
@@ -49,7 +44,7 @@ export const App = () => {
|
|||||||
|
|
||||||
{(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false)
|
{(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false)
|
||||||
? <SplashComponent />
|
? <SplashComponent />
|
||||||
: <Contents key={i18n.language} pluginsControllerHasRunRef={pluginsControllerHasRunRef} />
|
: <Contents key={i18n.language} />
|
||||||
}
|
}
|
||||||
|
|
||||||
<SnackbarController />
|
<SnackbarController />
|
||||||
@@ -58,11 +53,11 @@ export const App = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Contents = ({ pluginsControllerHasRunRef }) => {
|
const Contents = () => {
|
||||||
const { currentIsSoftwareUpdating } = useIsSoftwareUpdating();
|
const { currentIsSoftwareUpdating } = useIsSoftwareUpdating();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PluginsController pluginsControllerHasRunRef={pluginsControllerHasRunRef} />
|
<PluginsController />
|
||||||
|
|
||||||
<WindowTitleBar />
|
<WindowTitleBar />
|
||||||
{currentIsSoftwareUpdating.data === false
|
{currentIsSoftwareUpdating.data === false
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import { LoadPluginsController } from "./plugins_controllers/LoadPluginsControll
|
|||||||
import { FetchLatestPluginsDataController } from "./plugins_controllers/FetchLatestPluginsDataController";
|
import { FetchLatestPluginsDataController } from "./plugins_controllers/FetchLatestPluginsDataController";
|
||||||
import { MergePluginsController } from "./plugins_controllers/MergePluginsController";
|
import { MergePluginsController } from "./plugins_controllers/MergePluginsController";
|
||||||
|
|
||||||
export const PluginsController = ({ pluginsControllerHasRunRef }) => {
|
export const PluginsController = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MergePluginsController />
|
<MergePluginsController />
|
||||||
<LoadPluginsController pluginsControllerHasRunRef={pluginsControllerHasRunRef}/>
|
<LoadPluginsController />
|
||||||
<FetchLatestPluginsDataController pluginsControllerHasRunRef={pluginsControllerHasRunRef}/>
|
<FetchLatestPluginsDataController />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,23 +1,15 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { usePlugins } from "@logics_configs";
|
import { usePlugins } from "@logics_configs";
|
||||||
|
|
||||||
export const FetchLatestPluginsDataController = ({ pluginsControllerHasRunRef }) => {
|
export const FetchLatestPluginsDataController = () => {
|
||||||
const {
|
const {
|
||||||
asyncFetchPluginsInfo,
|
asyncFetchPluginsInfo,
|
||||||
|
isAnyPluginEnabled_Init,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
|
|
||||||
const asyncInitFetchPluginsInfo = async () => {
|
|
||||||
try {
|
|
||||||
await asyncFetchPluginsInfo();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!pluginsControllerHasRunRef.current.is_init_fetched_plugins_info) {
|
if (isAnyPluginEnabled_Init()) {
|
||||||
asyncInitFetchPluginsInfo();
|
asyncFetchPluginsInfo();
|
||||||
pluginsControllerHasRunRef.current.is_init_fetched_plugins_info = true;
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { usePlugins } from "@logics_configs";
|
import { usePlugins } from "@logics_configs";
|
||||||
|
import { store } from "@store";
|
||||||
|
|
||||||
export const LoadPluginsController = ({ pluginsControllerHasRunRef }) => {
|
export const LoadPluginsController = () => {
|
||||||
const {
|
const {
|
||||||
asyncLoadAllPlugins,
|
asyncLoadAllPlugins,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
@@ -15,9 +16,9 @@ export const LoadPluginsController = ({ pluginsControllerHasRunRef }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!pluginsControllerHasRunRef.current.is_initialized_load_plugin) {
|
if (!store.is_initialized_load_plugin) {
|
||||||
asyncInitLoadPlugins();
|
asyncInitLoadPlugins();
|
||||||
pluginsControllerHasRunRef.current.is_initialized_load_plugin = true;
|
store.is_initialized_load_plugin = true;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const MergePluginsController = () => {
|
|||||||
currentFetchedPluginsInfo,
|
currentFetchedPluginsInfo,
|
||||||
currentSavedPluginsStatus,
|
currentSavedPluginsStatus,
|
||||||
downloadAndExtractPlugin,
|
downloadAndExtractPlugin,
|
||||||
toggleSavedPluginsStatus,
|
setTargetSavedPluginsStatus_Init,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
const { checkVrctVerCompatibility } = useSoftwareVersion();
|
const { checkVrctVerCompatibility } = useSoftwareVersion();
|
||||||
|
|
||||||
@@ -131,7 +131,15 @@ export const MergePluginsController = () => {
|
|||||||
!plugin.latest_plugin_info?.is_plugin_supported
|
!plugin.latest_plugin_info?.is_plugin_supported
|
||||||
) {
|
) {
|
||||||
plugin.is_enabled = false;
|
plugin.is_enabled = false;
|
||||||
toggleSavedPluginsStatus(plugin.plugin_id);
|
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!plugin.downloaded_plugin_info.is_plugin_supported &&
|
||||||
|
plugin.is_outdated
|
||||||
|
) {
|
||||||
|
plugin.is_enabled = false;
|
||||||
|
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
import React from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { usePlugins } from "@logics_configs";
|
import { usePlugins } from "@logics_configs";
|
||||||
import styles from "./Plugins.module.scss";
|
import styles from "./Plugins.module.scss";
|
||||||
import { PluginsControlComponent } from "../_components/plugins_control_component/PluginsControlComponent";
|
import { PluginsControlComponent } from "../_components/plugins_control_component/PluginsControlComponent";
|
||||||
|
|
||||||
export const Plugins = () => {
|
export const Plugins = () => {
|
||||||
const {
|
const {
|
||||||
|
asyncFetchPluginsInfo,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
|
const hasRunRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!hasRunRef.current) {
|
||||||
|
asyncFetchPluginsInfo();
|
||||||
|
}
|
||||||
|
return () => hasRunRef.current = true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
import styles from "./PluginCompatibilityList.module.scss";
|
import styles from "./PluginCompatibilityList.module.scss";
|
||||||
import { usePlugins } from "@logics_configs";
|
import { usePlugins } from "@logics_configs";
|
||||||
import CheckMarkSvg from "@images/check_mark.svg?react";
|
import CheckMarkSvg from "@images/check_mark.svg?react";
|
||||||
@@ -5,7 +6,14 @@ import XSvg from "@images/x_mark.svg?react";
|
|||||||
import WarningSvg from "@images/warning.svg?react";
|
import WarningSvg from "@images/warning.svg?react";
|
||||||
|
|
||||||
export const PluginCompatibilityList = () => {
|
export const PluginCompatibilityList = () => {
|
||||||
const { enabledPluginsList } = usePlugins();
|
const {
|
||||||
|
enabledPluginsList,
|
||||||
|
asyncFetchPluginsInfo,
|
||||||
|
} = usePlugins();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
asyncFetchPluginsInfo();
|
||||||
|
}, []);
|
||||||
|
|
||||||
// ダウンロード済みのもの
|
// ダウンロード済みのもの
|
||||||
const downloaded_plugin = enabledPluginsList().filter(p => p.is_downloaded);
|
const downloaded_plugin = enabledPluginsList().filter(p => p.is_downloaded);
|
||||||
@@ -13,7 +21,7 @@ export const PluginCompatibilityList = () => {
|
|||||||
const compatible_plugins_list = [];
|
const compatible_plugins_list = [];
|
||||||
const incompatible_plugins_list = [];
|
const incompatible_plugins_list = [];
|
||||||
for (const p of downloaded_plugin) {
|
for (const p of downloaded_plugin) {
|
||||||
if (!p.downloaded_plugin_info?.is_plugin_supported_latest_vrct || !p.latest_plugin_info?.is_plugin_supported_latest_vrct) {
|
if (!p.downloaded_plugin_info?.is_plugin_supported_latest_vrct && !p.latest_plugin_info?.is_plugin_supported_latest_vrct) {
|
||||||
// プラグイン最新版でも、VRCT最新版(VRCTアプデ後)に非対応のもの
|
// プラグイン最新版でも、VRCT最新版(VRCTアプデ後)に非対応のもの
|
||||||
incompatible_plugins_list.push(p);
|
incompatible_plugins_list.push(p);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import { IS_PLUGIN_PATH_DEV_MODE, getPluginsList } from "@ui_configs";
|
import { IS_PLUGIN_PATH_DEV_MODE, getPluginsList } from "@ui_configs";
|
||||||
import {
|
import {
|
||||||
|
store,
|
||||||
|
|
||||||
createAtomWithHook,
|
createAtomWithHook,
|
||||||
useStore_SavedPluginsStatus,
|
useStore_SavedPluginsStatus,
|
||||||
useStore_PluginsData,
|
useStore_PluginsData,
|
||||||
useStore_IsFetchedPluginsInfo,
|
|
||||||
|
|
||||||
useStore_FetchedPluginsInfo,
|
useStore_FetchedPluginsInfo,
|
||||||
useStore_LoadedPlugins,
|
useStore_LoadedPlugins,
|
||||||
@@ -37,8 +38,6 @@ const PLUGIN_LIST_URL = getPluginsList();
|
|||||||
export const usePlugins = () => {
|
export const usePlugins = () => {
|
||||||
const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
|
||||||
const { currentIsFetchedPluginsInfo, updateIsFetchedPluginsInfo, pendingIsFetchedPluginsInfo } = useStore_IsFetchedPluginsInfo();
|
|
||||||
|
|
||||||
const { currentFetchedPluginsInfo, updateFetchedPluginsInfo, pendingFetchedPluginsInfo } = useStore_FetchedPluginsInfo();
|
const { currentFetchedPluginsInfo, updateFetchedPluginsInfo, pendingFetchedPluginsInfo } = useStore_FetchedPluginsInfo();
|
||||||
const { currentLoadedPlugins, updateLoadedPlugins, pendingLoadedPlugins } = useStore_LoadedPlugins();
|
const { currentLoadedPlugins, updateLoadedPlugins, pendingLoadedPlugins } = useStore_LoadedPlugins();
|
||||||
|
|
||||||
@@ -222,7 +221,9 @@ export const usePlugins = () => {
|
|||||||
|
|
||||||
|
|
||||||
const asyncFetchPluginsInfo = async () => {
|
const asyncFetchPluginsInfo = async () => {
|
||||||
if (currentIsFetchedPluginsInfo.data) return;
|
if (store.is_fetched_plugins_info) return;
|
||||||
|
store.is_fetched_plugins_info = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await asyncTauriFetchGithub(PLUGIN_LIST_URL);
|
const response = await asyncTauriFetchGithub(PLUGIN_LIST_URL);
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
@@ -247,7 +248,6 @@ export const usePlugins = () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
updateFetchedPluginsInfo(updated_list);
|
updateFetchedPluginsInfo(updated_list);
|
||||||
updateIsFetchedPluginsInfo(true);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching plugin info list: ", error);
|
console.error("Error fetching plugin info list: ", error);
|
||||||
}
|
}
|
||||||
@@ -327,11 +327,43 @@ export const usePlugins = () => {
|
|||||||
setSavedPluginsStatus(new_value);
|
setSavedPluginsStatus(new_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Init時の処理 非対応のものを無効化する際に、savedDPluginsStatusから不要なものを削除する処理が邪魔になるので該当コードを削除したバージョン。Init以外で使用する時にはリファクタが必要になる。
|
||||||
|
const setTargetSavedPluginsStatus_Init = (target_plugin_id, is_enabled) => {
|
||||||
|
const is_exists = currentSavedPluginsStatus.data.some(
|
||||||
|
(d) => d.plugin_id === target_plugin_id
|
||||||
|
);
|
||||||
|
let new_value = [];
|
||||||
|
if (is_exists) {
|
||||||
|
new_value = currentSavedPluginsStatus.data.map((d) => {
|
||||||
|
if (d.plugin_id === target_plugin_id) {
|
||||||
|
d.is_enabled = is_enabled;
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
new_value.push(...currentSavedPluginsStatus.data);
|
||||||
|
new_value.push({
|
||||||
|
plugin_id: target_plugin_id,
|
||||||
|
is_enabled: is_enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setSavedPluginsStatus(new_value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const setSavedPluginsStatus = (plugins_status) => {
|
const setSavedPluginsStatus = (plugins_status) => {
|
||||||
pendingSavedPluginsStatus();
|
pendingSavedPluginsStatus();
|
||||||
asyncStdoutToPython("/set/data/plugins_status", plugins_status);
|
asyncStdoutToPython("/set/data/plugins_status", plugins_status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// init時、currentPluginsDataからのデータではデータ更新が間に合わないので、currentSavedPluginsStatusから直接取得
|
||||||
|
const isAnyPluginEnabled_Init = () => {
|
||||||
|
console.log(currentSavedPluginsStatus);
|
||||||
|
return currentSavedPluginsStatus.data.some(plugin => plugin.is_enabled);
|
||||||
|
};
|
||||||
|
|
||||||
const isAnyPluginEnabled = () => {
|
const isAnyPluginEnabled = () => {
|
||||||
return currentPluginsData.data.some(plugin => plugin.is_enabled);
|
return currentPluginsData.data.some(plugin => plugin.is_enabled);
|
||||||
};
|
};
|
||||||
@@ -345,6 +377,7 @@ export const usePlugins = () => {
|
|||||||
return {
|
return {
|
||||||
asyncFetchPluginsInfo,
|
asyncFetchPluginsInfo,
|
||||||
|
|
||||||
|
isAnyPluginEnabled_Init,
|
||||||
isAnyPluginEnabled,
|
isAnyPluginEnabled,
|
||||||
enabledPluginsList,
|
enabledPluginsList,
|
||||||
|
|
||||||
@@ -357,9 +390,6 @@ export const usePlugins = () => {
|
|||||||
currentPluginsData,
|
currentPluginsData,
|
||||||
updatePluginsData,
|
updatePluginsData,
|
||||||
|
|
||||||
currentIsFetchedPluginsInfo,
|
|
||||||
updateIsFetchedPluginsInfo,
|
|
||||||
|
|
||||||
currentFetchedPluginsInfo,
|
currentFetchedPluginsInfo,
|
||||||
updateFetchedPluginsInfo,
|
updateFetchedPluginsInfo,
|
||||||
|
|
||||||
@@ -367,6 +397,7 @@ export const usePlugins = () => {
|
|||||||
updateLoadedPlugins,
|
updateLoadedPlugins,
|
||||||
|
|
||||||
toggleSavedPluginsStatus,
|
toggleSavedPluginsStatus,
|
||||||
|
setTargetSavedPluginsStatus_Init,
|
||||||
setSavedPluginsStatus,
|
setSavedPluginsStatus,
|
||||||
|
|
||||||
handlePendingPlugin,
|
handlePendingPlugin,
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export const store = {
|
|||||||
log_box_ref: null,
|
log_box_ref: null,
|
||||||
text_area_ref: null,
|
text_area_ref: null,
|
||||||
is_applied_init_message_box_height: false,
|
is_applied_init_message_box_height: false,
|
||||||
|
is_initialized_load_plugin: false,
|
||||||
|
is_fetched_plugins_info: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const generatePropertyNames = (base_name) => ({
|
const generatePropertyNames = (base_name) => ({
|
||||||
@@ -278,8 +280,6 @@ export const { atomInstance: Atom_Hotkeys, useHook: useStore_Hotkeys } = createA
|
|||||||
}, "Hotkeys");
|
}, "Hotkeys");
|
||||||
|
|
||||||
// Plugins
|
// Plugins
|
||||||
export const { atomInstance: Atom_IsFetchedPluginsInfo, useHook: useStore_IsFetchedPluginsInfo } = createAtomWithHook(false, "IsFetchedPluginsInfo");
|
|
||||||
|
|
||||||
export const { atomInstance: Atom_FetchedPluginsInfo, useHook: useStore_FetchedPluginsInfo } = createAtomWithHook([], "FetchedPluginsInfo");
|
export const { atomInstance: Atom_FetchedPluginsInfo, useHook: useStore_FetchedPluginsInfo } = createAtomWithHook([], "FetchedPluginsInfo");
|
||||||
export const { atomInstance: Atom_LoadedPlugins, useHook: useStore_LoadedPlugins } = createAtomWithHook([], "LoadedPlugins");
|
export const { atomInstance: Atom_LoadedPlugins, useHook: useStore_LoadedPlugins } = createAtomWithHook([], "LoadedPlugins");
|
||||||
export const { atomInstance: Atom_SavedPluginsStatus, useHook: useStore_SavedPluginsStatus } = createAtomWithHook([], "SavedPluginsStatus");
|
export const { atomInstance: Atom_SavedPluginsStatus, useHook: useStore_SavedPluginsStatus } = createAtomWithHook([], "SavedPluginsStatus");
|
||||||
|
|||||||
Reference in New Issue
Block a user