Files
workavia-drive/tdrive/frontend/src/app/features/channels/state/channels.ts
T
Montassar Ghanmy e0615fa867 📁 Changed TDrive root folder (#16)
📁 Changed TDrive root folder
2023-04-11 10:04:29 +01:00

37 lines
976 B
TypeScript

import { atom, atomFamily, selectorFamily } from 'recoil';
import _ from 'lodash';
import { ChannelType } from 'app/features/channels/types/channel';
type ChannelsListContextType = { companyId: string; workspaceId: string };
export const ChannelsState = atom<ChannelType[]>({
key: 'ChannelsState',
default: [],
});
export const ChannelSelector = selectorFamily<ChannelType | undefined, string>({
key: 'ChannelSelector',
get:
channelId =>
({ get }) => {
const channels = get(ChannelsState);
return _.find(channels, { id: channelId });
},
});
export const MineChannelsState = atomFamily<ChannelType[], ChannelsListContextType>({
key: 'MineChannelsState',
default: [],
});
export const ReachableChannelsState = atomFamily<ChannelType[], ChannelsListContextType>({
key: 'ReachableChannelsState',
default: [],
});
export const DirectChannelsState = atomFamily<ChannelType[], string>({
key: 'DirectChannelsState',
default: [],
});