<template>
  <modal-feed
   @close-modal="closeModal"
   @destroyFeed="destroyFeed"
   :modalFeed='modalFeed' :open="show" />

  <div v-for="feed in feedLists" :key="feed.id">
    <feed-node @open-modal="openModal" :feed="feed" />
  </div>
</template>

<script>
import FeedNode from "@/Shared/Feed/FeedNode";
import ModalFeed from "@/Shared/Overlay/ModalFeed";
import { filter } from "lodash";

export default {
  components: {
    FeedNode,
    ModalFeed,
  },

  props: {
    feeds: Array,
    selfFeed: Boolean,
    selfUser: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      showLoadButton: true,
      show: false,
      entity: {},
      feedLists: [],
      complaints: [],
      modalFeed: {},
    };
  },

  mounted() {
    this.feedLists = this.feeds;
  },

  methods: {
    destroyFeed(){
        const that = this;
        this.feedLists = filter(this.feedLists, function (x) {
            return x.id !== that.modalFeed.id;
        });
    },
    openModal(feed) {
      this.show = true;
      this.modalFeed = feed;
    },
    closeModal() {
        this.show = false;
    }
  },
};
</script>
