[bugfix] Plugins: fix auto disable plugins function.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { store } from "@store";
|
||||
import { usePlugins } from "@logics_configs";
|
||||
import { useSoftwareVersion } from "@logics_common";
|
||||
|
||||
@@ -121,29 +122,6 @@ export const MergePluginsController = () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ダウンロード済みかつ有効なプラグインで、サポート対象でない場合は無効化
|
||||
new_data.forEach(plugin => {
|
||||
if (plugin.is_downloaded && plugin.is_enabled) {
|
||||
if (
|
||||
!plugin.downloaded_plugin_info.is_plugin_supported &&
|
||||
plugin.latest_plugin_info &&
|
||||
!plugin.latest_plugin_info?.is_plugin_supported
|
||||
) {
|
||||
plugin.is_enabled = false;
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log("merged plugin data", new_data);
|
||||
return new_data;
|
||||
});
|
||||
@@ -168,8 +146,6 @@ export const MergePluginsController = () => {
|
||||
!plugin.is_latest_version_already &&
|
||||
plugin.is_latest_version_available
|
||||
) {
|
||||
console.log(!downloadingRef.current.has(plugin.plugin_id));
|
||||
|
||||
if (!downloadingRef.current.has(plugin.plugin_id)) {
|
||||
downloadingRef.current.add(plugin.plugin_id);
|
||||
downloadAndExtractPlugin(plugin)
|
||||
@@ -186,5 +162,35 @@ export const MergePluginsController = () => {
|
||||
});
|
||||
}, [currentPluginsData.data]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
// ダウンロード済みかつ有効なプラグインで、サポート対象でない場合は無効化
|
||||
if (store.is_initialized_fetched_plugin_info) {
|
||||
updatePluginsData(prev => {
|
||||
prev.data.forEach(plugin => {
|
||||
if (plugin.is_downloaded && plugin.is_enabled) {
|
||||
if (
|
||||
!plugin.downloaded_plugin_info.is_plugin_supported &&
|
||||
plugin.latest_plugin_info &&
|
||||
!plugin.latest_plugin_info?.is_plugin_supported
|
||||
) {
|
||||
plugin.is_enabled = false;
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
return prev.data;
|
||||
});
|
||||
}
|
||||
}, [store.is_initialized_fetched_plugin_info]);
|
||||
|
||||
return null;
|
||||
};
|
||||
@@ -221,8 +221,8 @@ export const usePlugins = () => {
|
||||
|
||||
|
||||
const asyncFetchPluginsInfo = async () => {
|
||||
if (store.is_fetched_plugins_info) return;
|
||||
store.is_fetched_plugins_info = true;
|
||||
if (store.is_fetched_plugins_info_already) return;
|
||||
store.is_fetched_plugins_info_already = true;
|
||||
|
||||
try {
|
||||
const response = await asyncTauriFetchGithub(PLUGIN_LIST_URL);
|
||||
@@ -251,6 +251,8 @@ export const usePlugins = () => {
|
||||
} catch (error) {
|
||||
console.error("Error fetching plugin info list: ", error);
|
||||
}
|
||||
|
||||
store.is_initialized_fetched_plugin_info = true;
|
||||
}
|
||||
|
||||
const asyncFetchPluginInfo = async (plugin_info_asset_url) => {
|
||||
@@ -360,7 +362,6 @@ export const usePlugins = () => {
|
||||
|
||||
// init時、currentPluginsDataからのデータではデータ更新が間に合わないので、currentSavedPluginsStatusから直接取得
|
||||
const isAnyPluginEnabled_Init = () => {
|
||||
console.log(currentSavedPluginsStatus);
|
||||
return currentSavedPluginsStatus.data.some(plugin => plugin.is_enabled);
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ export const store = {
|
||||
text_area_ref: null,
|
||||
is_applied_init_message_box_height: false,
|
||||
is_initialized_load_plugin: false,
|
||||
is_fetched_plugins_info: false,
|
||||
is_fetched_plugins_info_already: false,
|
||||
is_initialized_fetched_plugin_info: false,
|
||||
};
|
||||
|
||||
const generatePropertyNames = (base_name) => ({
|
||||
|
||||
Reference in New Issue
Block a user