No longer using localStorage
This commit is contained in:
parent
376e2122d7
commit
e306dad87f
|
@ -51,21 +51,20 @@ const ClipperCatalog: React.FC<ClipperCatalogProps> = ({ app, plugin }) => {
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [advancedSettings, setAdvancedSettings] = useState<AdvancedSettings>(() => {
|
const [advancedSettings, setAdvancedSettings] = useState<AdvancedSettings>({
|
||||||
// Try to load saved settings from localStorage
|
ignoredDirectories: plugin.settings.ignoredDirectories,
|
||||||
const savedSettings = localStorage.getItem('clipper-catalog-advanced-settings');
|
isExpanded: plugin.settings.isAdvancedSettingsExpanded
|
||||||
return savedSettings ? JSON.parse(savedSettings) : {
|
|
||||||
ignoredDirectories: [],
|
|
||||||
isExpanded: false
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
const [newDirectory, setNewDirectory] = useState('');
|
const [newDirectory, setNewDirectory] = useState('');
|
||||||
|
|
||||||
|
|
||||||
// Save advanced settings to localStorage whenever they change
|
// Save advanced settings to localStorage whenever they change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
localStorage.setItem('clipper-catalog-advanced-settings', JSON.stringify(advancedSettings));
|
// Update plugin settings when advanced settings change
|
||||||
}, [advancedSettings]);
|
plugin.settings.ignoredDirectories = advancedSettings.ignoredDirectories;
|
||||||
|
plugin.settings.isAdvancedSettingsExpanded = advancedSettings.isExpanded;
|
||||||
|
plugin.saveSettings();
|
||||||
|
}, [advancedSettings, plugin]);
|
||||||
|
|
||||||
// Helper function to check if a path should be ignored
|
// Helper function to check if a path should be ignored
|
||||||
const isPathIgnored = (filePath: string): boolean => {
|
const isPathIgnored = (filePath: string): boolean => {
|
||||||
|
|
|
@ -5,13 +5,17 @@ import { ClipperCatalogView, VIEW_TYPE_CLIPPER_CATALOG } from './ClipperCatalogV
|
||||||
|
|
||||||
interface ObsidianClipperCatalogSettings {
|
interface ObsidianClipperCatalogSettings {
|
||||||
sourcePropertyName: string;
|
sourcePropertyName: string;
|
||||||
|
ignoredDirectories: string[];
|
||||||
|
isAdvancedSettingsExpanded: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this before the ObsidianClipperCatalog class definition
|
// Add this before the ObsidianClipperCatalog class definition
|
||||||
export const ICON_NAME = 'clipper-catalog';
|
export const ICON_NAME = 'clipper-catalog';
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: ObsidianClipperCatalogSettings = {
|
const DEFAULT_SETTINGS: ObsidianClipperCatalogSettings = {
|
||||||
sourcePropertyName: 'source'
|
sourcePropertyName: 'source',
|
||||||
|
ignoredDirectories: [],
|
||||||
|
isAdvancedSettingsExpanded: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ObsidianClipperCatalog extends Plugin {
|
export default class ObsidianClipperCatalog extends Plugin {
|
||||||
|
|
Loading…
Reference in New Issue