Skip to content

Commit

Permalink
fix: Simplify settings state persistent path
Browse files Browse the repository at this point in the history
  • Loading branch information
nfnfgo committed Oct 20, 2024
1 parent 0da530b commit 8ff00b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/states/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {create} from 'zustand';
import {immer} from 'zustand/middleware/immer';
import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';

import {persist, createJSONStorage, subscribeWithSelector} from 'zustand/middleware';
import {LiteLoaderStorage} from '@/utils/liteloader_config';
import { persist, createJSONStorage, subscribeWithSelector } from 'zustand/middleware';
import { LiteLoaderStorage } from '@/utils/liteloader_config';

export interface SettingStateProperties {
// Boolean properties
Expand Down Expand Up @@ -86,7 +86,7 @@ export const useSettingsStore = create<SettingStateProperties & SettingStateActi
}
}))),
{
name: 'state/settings',
name: 'settings',
storage: LiteLoaderStorage,
}
),
Expand Down
8 changes: 4 additions & 4 deletions src/utils/liteloader_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import { LiteLoaderInterFace } from '@/utils/liteloader_type';

declare const LiteLoader: LiteLoaderInterFace<Object>;

const pluginSlugPrefix = 'markdown-it';
const pluginSlugPrefix = 'markdown_it';
const emptyStorageState = {};


const _storage = {
async getItem(name: string) {
return JSON.stringify(
await LiteLoader.api.config.get(`${pluginSlugPrefix}-${name}`, emptyStorageState)
await LiteLoader.api.config.get(`${pluginSlugPrefix}/${name}`, emptyStorageState)
);
},
async setItem(name: string, value: string) {
return await LiteLoader.api.config.set(`${pluginSlugPrefix}-${name}`, JSON.parse(value));
return await LiteLoader.api.config.set(`${pluginSlugPrefix}/${name}`, JSON.parse(value));
},
async removeItem(name: string) {
return await LiteLoader.api.config.set(pluginSlugPrefix, emptyStorageState);
return await LiteLoader.api.config.set(`${pluginSlugPrefix}/${name}`, emptyStorageState);
}
}

Expand Down

0 comments on commit 8ff00b7

Please sign in to comment.