1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixed installing plugins

This commit is contained in:
Laurent Cozic 2021-01-26 23:56:35 +00:00
parent 11b8821bf4
commit cda9441c69
3 changed files with 16 additions and 11 deletions

View File

@ -20,6 +20,10 @@ export enum UpdateState {
HasBeenUpdated = 4,
}
export interface ItemEvent {
item: PluginItem;
}
interface Props {
item?: PluginItem;
manifest?: PluginManifest;
@ -27,10 +31,10 @@ interface Props {
updateState?: UpdateState;
themeId: number;
isCompatible: boolean;
onToggle?: Function;
onDelete?: Function;
onInstall?: Function;
onUpdate?: Function;
onToggle?: (event: ItemEvent)=> void;
onDelete?: (event: ItemEvent)=> void;
onInstall?: (event: ItemEvent)=> void;
onUpdate?: (event: ItemEvent)=> void;
}
function manifestToItem(manifest: PluginManifest): PluginItem {

View File

@ -4,7 +4,7 @@ import PluginService, { defaultPluginSetting, Plugins, PluginSetting, PluginSett
import { _ } from '@joplin/lib/locale';
import styled from 'styled-components';
import SearchPlugins from './SearchPlugins';
import PluginBox, { UpdateState } from './PluginBox';
import PluginBox, { ItemEvent, UpdateState } from './PluginBox';
import Button, { ButtonLevel } from '../../../Button/Button';
import bridge from '../../../../services/bridge';
import produce from 'immer';
@ -128,8 +128,8 @@ export default function(props: Props) {
};
}, [manifestsLoaded, pluginItems]);
const onDelete = useCallback(async (event: any) => {
const item: PluginItem = event.item;
const onDelete = useCallback(async (event: ItemEvent) => {
const item = event.item;
const confirm = await bridge().showConfirmMessageBox(_('Delete plugin "%s"?', item.manifest.name));
if (!confirm) return;
@ -141,8 +141,8 @@ export default function(props: Props) {
props.onChange({ value: pluginService.serializePluginSettings(newSettings) });
}, [pluginSettings, props.onChange]);
const onToggle = useCallback((event: any) => {
const item: PluginItem = event.item;
const onToggle = useCallback((event: ItemEvent) => {
const item = event.item;
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
if (!draft[item.manifest.id]) draft[item.manifest.id] = defaultPluginSetting();

View File

@ -3,6 +3,7 @@ import PluginService, { defaultPluginSetting, PluginSettings } from '@joplin/lib
import produce from 'immer';
import { _ } from '@joplin/lib/locale';
import Logger from '@joplin/lib/Logger';
import { ItemEvent } from './PluginBox';
const logger = Logger.create('useOnInstallHandler');
@ -13,8 +14,8 @@ export interface OnPluginSettingChangeEvent {
type OnPluginSettingChangeHandler = (event: OnPluginSettingChangeEvent)=> void;
export default function(setInstallingPluginIds: Function, pluginSettings: PluginSettings, repoApi: Function, onPluginSettingsChange: OnPluginSettingChangeHandler, isUpdate: boolean) {
return useCallback(async (event: any) => {
const pluginId = event.item.id;
return useCallback(async (event: ItemEvent) => {
const pluginId = event.item.manifest.id;
setInstallingPluginIds((prev: any) => {
return {