import { useEffect, useState } from 'react';
import { View } from 'react-native';
import { useStyles } from './styles';
import { CommunityRepository } from '@amityco/ts-sdk-react-native';
import CommunityStories from '../CommunityStories';
export default function MyStories() {
  const styles = useStyles();
  const [communityItems, setCommunityItems] = useState([]);
  const queryCommunities = () => {
    const unsubscribe = CommunityRepository.getCommunities({
      membership: 'member',
      limit: 10,
      sortBy: 'firstCreated'
    }, ({
      data
    }) => {
      const communityIds = data.map(item => {
        return item.communityId;
      });
      setCommunityItems(communityIds);
    });
    unsubscribe();
  };
  useEffect(() => {
    queryCommunities();
  }, []);
  return /*#__PURE__*/React.createElement(View, {
    style: styles.container
  }, (communityItems === null || communityItems === void 0 ? void 0 : communityItems.length) > 0 && communityItems.map(communityId => {
    return /*#__PURE__*/React.createElement(CommunityStories, {
      communityId: communityId
    });
  }));
}
//# sourceMappingURL=index.js.map