mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 22:44:26 +01:00
refactor: move directory
This commit is contained in:
36
src/nostr/useConfig.ts
Normal file
36
src/nostr/useConfig.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Signal } from 'solid-js';
|
||||
import {
|
||||
createStorageWithSerializer,
|
||||
createSignalWithStorage,
|
||||
} from '@/hooks/createSignalWithStorage';
|
||||
|
||||
type Config = {
|
||||
relayUrls: string[];
|
||||
};
|
||||
|
||||
const InitialConfig: Config = {
|
||||
relayUrls: [
|
||||
'wss://relay-jp.nostr.wirednet.jp',
|
||||
'wss://nostr.h3z.jp/',
|
||||
'wss://relay.damus.io',
|
||||
'wss://nos.lol',
|
||||
// 'wss://relay.snort.social',
|
||||
'wss://relay.current.fyi',
|
||||
'wss://relay.nostr.wirednet.jp',
|
||||
'wss://nostr-relay.nokotaro.com',
|
||||
'wss://nostr.holybea.com',
|
||||
],
|
||||
};
|
||||
|
||||
const serializer = (config: Config): string => JSON.stringify(config);
|
||||
// TODO zod使う
|
||||
const deserializer = (json: string): Config => JSON.parse(json) as Config;
|
||||
|
||||
const storage = createStorageWithSerializer(() => window.localStorage, serializer, deserializer);
|
||||
const [config, setConfig] = createSignalWithStorage('RabbitConfig', InitialConfig, storage);
|
||||
|
||||
const useConfig = (): Signal<Config> => {
|
||||
return [config, setConfig];
|
||||
};
|
||||
|
||||
export default useConfig;
|
||||
Reference in New Issue
Block a user