move channel list logic to atom
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
import { DEFAULT_CHANNELS } from '@stores/constants';
|
||||
|
||||
import { atom } from 'jotai';
|
||||
import { atomWithReset } from 'jotai/utils';
|
||||
|
||||
// channel list
|
||||
export const defaultChannelsAtom = atom(DEFAULT_CHANNELS);
|
||||
export const channelsAtom = atom(async (get) => {
|
||||
const { getChannels } = await import('@utils/storage');
|
||||
const result: any = await getChannels(100, 0);
|
||||
return get(defaultChannelsAtom).concat(result);
|
||||
});
|
||||
|
||||
// channel reply id
|
||||
export const channelReplyAtom = atomWithReset({ id: null, pubkey: null, content: null });
|
||||
|
||||
// channel messages
|
||||
export const channelMessagesAtom = atomWithReset([]);
|
||||
export const sortedChannelMessagesAtom = atom((get) => {
|
||||
|
||||
Reference in New Issue
Block a user