[Update] Plugins: Add notifications.
This commit is contained in:
@@ -244,3 +244,17 @@ config_page:
|
|||||||
label: "Open Config File"
|
label: "Open Config File"
|
||||||
switch_compute_device:
|
switch_compute_device:
|
||||||
label: "Switch VRCT To CPU/GPU Version"
|
label: "Switch VRCT To CPU/GPU Version"
|
||||||
|
|
||||||
|
plugin_notifications:
|
||||||
|
downloading: Downloading the plugin.
|
||||||
|
downloaded_success: Downloaded successfully.
|
||||||
|
downloaded_error: Download failed.
|
||||||
|
|
||||||
|
updating: Updating the plugin.
|
||||||
|
updated_success: Updated successfully.
|
||||||
|
updated_error: Update failed.
|
||||||
|
|
||||||
|
disabled_out_of_support: THe plugin has been disabled. It's not supported on this VRCT version.
|
||||||
|
|
||||||
|
is_enabled: The plugin has enabled.
|
||||||
|
is_disabled: The plugin has disabled.
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { store } from "@store";
|
import { store } from "@store";
|
||||||
import { usePlugins } from "@logics_configs";
|
import { usePlugins } from "@logics_configs";
|
||||||
import { useSoftwareVersion } from "@logics_common";
|
import { useSoftwareVersion } from "@logics_common";
|
||||||
|
import { useNotificationStatus } from "@logics_common";
|
||||||
|
|
||||||
export const MergePluginsController = () => {
|
export const MergePluginsController = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
currentLoadedPlugins,
|
currentLoadedPlugins,
|
||||||
updatePluginsData,
|
updatePluginsData,
|
||||||
updateTargetPluginData,
|
|
||||||
currentPluginsData,
|
currentPluginsData,
|
||||||
currentFetchedPluginsInfo,
|
currentFetchedPluginsInfo,
|
||||||
currentSavedPluginsStatus,
|
currentSavedPluginsStatus,
|
||||||
@@ -15,6 +17,7 @@ export const MergePluginsController = () => {
|
|||||||
setTargetSavedPluginsStatus_Init,
|
setTargetSavedPluginsStatus_Init,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
const { checkVrctVerCompatibility } = useSoftwareVersion();
|
const { checkVrctVerCompatibility } = useSoftwareVersion();
|
||||||
|
const { showNotification_Success, showNotification_Error } = useNotificationStatus();
|
||||||
|
|
||||||
// downloaded, fetched, saved の各情報をまとめてマージ
|
// downloaded, fetched, saved の各情報をまとめてマージ
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -148,16 +151,19 @@ export const MergePluginsController = () => {
|
|||||||
plugin.is_latest_version_available
|
plugin.is_latest_version_available
|
||||||
) {
|
) {
|
||||||
if (!downloadingRef.current.has(plugin.plugin_id)) {
|
if (!downloadingRef.current.has(plugin.plugin_id)) {
|
||||||
|
showNotification_Success(t("plugin_notifications.updating"));
|
||||||
downloadingRef.current.add(plugin.plugin_id);
|
downloadingRef.current.add(plugin.plugin_id);
|
||||||
const target_plugin_id = plugin.plugin_id;
|
const target_plugin_id = plugin.plugin_id;
|
||||||
downloadAndExtractPlugin(plugin)
|
downloadAndExtractPlugin(plugin)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log(`Plugin ${target_plugin_id} updated successfully`);
|
console.log(`Plugin ${target_plugin_id} updated successfully`);
|
||||||
downloadingRef.current.delete(target_plugin_id);
|
downloadingRef.current.delete(target_plugin_id);
|
||||||
|
showNotification_Success(t("plugin_notifications.updated_success"));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(`Plugin ${target_plugin_id} update failed`, error);
|
console.error(`Plugin ${target_plugin_id} update failed`, error);
|
||||||
downloadingRef.current.delete(target_plugin_id);
|
downloadingRef.current.delete(target_plugin_id);
|
||||||
|
showNotification_Error(t("plugin_notifications.updated_error"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,6 +182,7 @@ export const MergePluginsController = () => {
|
|||||||
plugin.latest_plugin_info &&
|
plugin.latest_plugin_info &&
|
||||||
!plugin.latest_plugin_info?.is_plugin_supported
|
!plugin.latest_plugin_info?.is_plugin_supported
|
||||||
) {
|
) {
|
||||||
|
showNotification_Error(t("plugin_notifications.disabled_out_of_support"));
|
||||||
plugin.is_enabled = false;
|
plugin.is_enabled = false;
|
||||||
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
||||||
}
|
}
|
||||||
@@ -184,6 +191,7 @@ export const MergePluginsController = () => {
|
|||||||
!plugin.downloaded_plugin_info.is_plugin_supported &&
|
!plugin.downloaded_plugin_info.is_plugin_supported &&
|
||||||
plugin.is_outdated
|
plugin.is_outdated
|
||||||
) {
|
) {
|
||||||
|
showNotification_Error(t("plugin_notifications.disabled_out_of_support"));
|
||||||
plugin.is_enabled = false;
|
plugin.is_enabled = false;
|
||||||
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
setTargetSavedPluginsStatus_Init(plugin.plugin_id, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
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";
|
||||||
|
import { useNotificationStatus } from "@logics_common";
|
||||||
|
|
||||||
export const Plugins = () => {
|
export const Plugins = () => {
|
||||||
const {
|
const {
|
||||||
@@ -24,6 +26,7 @@ export const Plugins = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PluginDownloadContainer = () => {
|
const PluginDownloadContainer = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
downloadAndExtractPlugin,
|
downloadAndExtractPlugin,
|
||||||
currentPluginsData,
|
currentPluginsData,
|
||||||
@@ -31,16 +34,22 @@ const PluginDownloadContainer = () => {
|
|||||||
toggleSavedPluginsStatus,
|
toggleSavedPluginsStatus,
|
||||||
handlePendingPlugin,
|
handlePendingPlugin,
|
||||||
} = usePlugins();
|
} = usePlugins();
|
||||||
|
const { showNotification_Success, showNotification_Error } = useNotificationStatus();
|
||||||
|
|
||||||
// ダウンロード開始時の状態更新処理
|
// ダウンロード開始時の状態更新処理
|
||||||
const downloadStartFunction = async (target_plugin_id) => {
|
const downloadStartFunction = async (target_plugin_id) => {
|
||||||
handlePendingPlugin(target_plugin_id, true);
|
handlePendingPlugin(target_plugin_id, true);
|
||||||
|
showNotification_Success(t("plugin_notifications.downloading"));
|
||||||
|
|
||||||
const target_plugin_info = currentPluginsData.data.find(
|
const target_plugin_info = currentPluginsData.data.find(
|
||||||
(d) => d.plugin_id === target_plugin_id
|
(d) => d.plugin_id === target_plugin_id
|
||||||
);
|
);
|
||||||
downloadAndExtractPlugin(target_plugin_info).then(() => {
|
downloadAndExtractPlugin(target_plugin_info).then(() => {
|
||||||
handlePendingPlugin(target_plugin_id, false);
|
handlePendingPlugin(target_plugin_id, false);
|
||||||
|
showNotification_Success(t("plugin_notifications.downloaded_success"));
|
||||||
|
}).catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
showNotification_Error(t("plugin_notifications.downloaded_error"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { IS_PLUGIN_PATH_DEV_MODE, getPluginsList } from "@ui_configs";
|
import { IS_PLUGIN_PATH_DEV_MODE, getPluginsList } from "@ui_configs";
|
||||||
import {
|
import {
|
||||||
store,
|
store,
|
||||||
@@ -25,17 +26,18 @@ dev_plugins.forEach(async ({entry_path}) => {
|
|||||||
|
|
||||||
import JSZip from "jszip";
|
import JSZip from "jszip";
|
||||||
|
|
||||||
import { useFetch, useSoftwareVersion } from "@logics_common";
|
import { useFetch, useSoftwareVersion, useNotificationStatus } from "@logics_common";
|
||||||
|
|
||||||
import * as logics_configs from "@logics_configs";
|
import * as logics_configs from "@logics_configs";
|
||||||
import * as logics_main from "@logics_main";
|
import * as logics_main from "@logics_main";
|
||||||
import * as logics_common from "@logics_common";
|
import * as logics_common from "@logics_common";
|
||||||
|
|
||||||
|
|
||||||
// PLUGIN_LIST_URL は中央リポジトリにある、各プラグインの plugin_info.json への URL の配列を保持する JSON の URL
|
// PLUGIN_LIST_URL は中央リポジトリにある、各プラグインの plugin_info.json への URL の配列を保持する JSON の URL
|
||||||
const PLUGIN_LIST_URL = getPluginsList();
|
const PLUGIN_LIST_URL = getPluginsList();
|
||||||
|
|
||||||
export const usePlugins = () => {
|
export const usePlugins = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { showNotification_Success, showNotification_Error } = useNotificationStatus();
|
||||||
const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
|
||||||
const { currentFetchedPluginsInfo, updateFetchedPluginsInfo, pendingFetchedPluginsInfo } = useStore_FetchedPluginsInfo();
|
const { currentFetchedPluginsInfo, updateFetchedPluginsInfo, pendingFetchedPluginsInfo } = useStore_FetchedPluginsInfo();
|
||||||
@@ -308,6 +310,9 @@ export const usePlugins = () => {
|
|||||||
new_value = currentSavedPluginsStatus.data.map((d) => {
|
new_value = currentSavedPluginsStatus.data.map((d) => {
|
||||||
if (d.plugin_id === target_plugin_id) {
|
if (d.plugin_id === target_plugin_id) {
|
||||||
d.is_enabled = !d.is_enabled;
|
d.is_enabled = !d.is_enabled;
|
||||||
|
(d.is_enabled)
|
||||||
|
? showNotification_Success(t("plugin_notifications.is_enabled"))
|
||||||
|
: showNotification_Success(t("plugin_notifications.is_disabled"));
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
@@ -317,6 +322,7 @@ export const usePlugins = () => {
|
|||||||
plugin_id: target_plugin_id,
|
plugin_id: target_plugin_id,
|
||||||
is_enabled: true,
|
is_enabled: true,
|
||||||
});
|
});
|
||||||
|
showNotification_Success(t("plugin_notifications.is_enabled"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 「currentPluginsData.data」でis_downloadedがtrueのものだけ残す
|
// 「currentPluginsData.data」でis_downloadedがtrueのものだけ残す
|
||||||
|
|||||||
Reference in New Issue
Block a user