You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Mobile: Plugin settings: Fix plugins without settings can't be disabled without reinstall (#10579)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
@ -2,7 +2,7 @@ import { ItemEvent, OnPluginSettingChangeEvent } from '@joplin/lib/components/sh
|
||||
import useOnDeleteHandler from '@joplin/lib/components/shared/config/plugins/useOnDeleteHandler';
|
||||
import useOnInstallHandler from '@joplin/lib/components/shared/config/plugins/useOnInstallHandler';
|
||||
import NavService from '@joplin/lib/services/NavService';
|
||||
import { PluginSettings } from '@joplin/lib/services/plugins/PluginService';
|
||||
import { PluginSettings, defaultPluginSetting } from '@joplin/lib/services/plugins/PluginService';
|
||||
import RepositoryApi from '@joplin/lib/services/plugins/RepositoryApi';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
@ -29,14 +29,18 @@ const usePluginCallbacks = (props: Props) => {
|
||||
|
||||
const updatePluginEnabled = useCallback((pluginId: string, enabled: boolean) => {
|
||||
const newSettings = { ...props.pluginSettings };
|
||||
newSettings[pluginId].enabled = enabled;
|
||||
newSettings[pluginId] = {
|
||||
...defaultPluginSetting(),
|
||||
...newSettings[pluginId],
|
||||
enabled,
|
||||
};
|
||||
|
||||
props.updatePluginStates(newSettings);
|
||||
}, [props.pluginSettings, props.updatePluginStates]);
|
||||
|
||||
const onToggle = useCallback((event: ItemEvent) => {
|
||||
const pluginId = event.item.manifest.id;
|
||||
const settings = props.pluginSettings[pluginId];
|
||||
const settings = props.pluginSettings[pluginId] ?? defaultPluginSetting();
|
||||
updatePluginEnabled(pluginId, !settings.enabled);
|
||||
}, [props.pluginSettings, updatePluginEnabled]);
|
||||
|
||||
|
Reference in New Issue
Block a user