"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = MyStories;
var _react = require("react");
var _reactNative = require("react-native");
var _styles = require("./styles");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _CommunityStories = _interopRequireDefault(require("../CommunityStories"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function MyStories() {
  const styles = (0, _styles.useStyles)();
  const [communityItems, setCommunityItems] = (0, _react.useState)([]);
  const queryCommunities = () => {
    const unsubscribe = _tsSdkReactNative.CommunityRepository.getCommunities({
      membership: 'member',
      limit: 10,
      sortBy: 'firstCreated'
    }, ({
      data
    }) => {
      const communityIds = data.map(item => {
        return item.communityId;
      });
      setCommunityItems(communityIds);
    });
    unsubscribe();
  };
  (0, _react.useEffect)(() => {
    queryCommunities();
  }, []);
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, (communityItems === null || communityItems === void 0 ? void 0 : communityItems.length) > 0 && communityItems.map(communityId => {
    return /*#__PURE__*/React.createElement(_CommunityStories.default, {
      communityId: communityId
    });
  }));
}
//# sourceMappingURL=index.js.map