feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,76 @@
|
||||
import { produce } from 'immer';
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
import { ItemEvent, OnPluginSettingChangeHandler } from './types';
|
||||
import type * as React from 'react';
|
||||
import shim from '../../../../shim';
|
||||
import RepositoryApi from '../../../../services/plugins/RepositoryApi';
|
||||
import PluginService, { PluginSettings, defaultPluginSetting } from '../../../../services/plugins/PluginService';
|
||||
import { _ } from '../../../../locale';
|
||||
|
||||
const logger = Logger.create('useOnInstallHandler');
|
||||
|
||||
type GetRepoApiCallback = ()=> RepositoryApi;
|
||||
|
||||
const useOnInstallHandler = (
|
||||
setInstallingPluginIds: React.Dispatch<React.SetStateAction<Record<string, boolean>>>,
|
||||
pluginSettingsRef: React.RefObject<PluginSettings>,
|
||||
getRepoApi: GetRepoApiCallback|RepositoryApi,
|
||||
onPluginSettingsChange: OnPluginSettingChangeHandler,
|
||||
isUpdate: boolean,
|
||||
) => {
|
||||
const React = shim.react();
|
||||
return React.useCallback(async (event: ItemEvent) => {
|
||||
const pluginId = event.item.manifest.id;
|
||||
|
||||
setInstallingPluginIds(prev => {
|
||||
return {
|
||||
...prev, [pluginId]: true,
|
||||
};
|
||||
});
|
||||
|
||||
let installError = null;
|
||||
|
||||
try {
|
||||
const repoApi = typeof getRepoApi === 'function' ? getRepoApi() : getRepoApi;
|
||||
|
||||
if (isUpdate) {
|
||||
await PluginService.instance().updatePluginFromRepo(repoApi, pluginId);
|
||||
} else {
|
||||
await PluginService.instance().installPluginFromRepo(repoApi, pluginId);
|
||||
}
|
||||
} catch (error) {
|
||||
installError = error;
|
||||
logger.error(error);
|
||||
}
|
||||
|
||||
if (!installError) {
|
||||
const pluginSettings = pluginSettingsRef.current;
|
||||
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
||||
draft[pluginId] = defaultPluginSetting();
|
||||
if (isUpdate) {
|
||||
if (pluginSettings[pluginId]) {
|
||||
draft[pluginId].enabled = pluginSettings[pluginId].enabled;
|
||||
}
|
||||
draft[pluginId].hasBeenUpdated = true;
|
||||
}
|
||||
});
|
||||
|
||||
onPluginSettingsChange({ value: newSettings });
|
||||
}
|
||||
|
||||
setInstallingPluginIds(prev => {
|
||||
return {
|
||||
...prev, [pluginId]: false,
|
||||
};
|
||||
});
|
||||
|
||||
if (installError) {
|
||||
await shim.showMessageBox(
|
||||
_('Could not install plugin: %s', installError.message),
|
||||
{ buttons: [_('OK')] },
|
||||
);
|
||||
}
|
||||
}, [getRepoApi, isUpdate, pluginSettingsRef, onPluginSettingsChange, setInstallingPluginIds]);
|
||||
};
|
||||
|
||||
export default useOnInstallHandler;
|
||||
在新工单中引用
屏蔽一个用户