<commit_before><template>
  <div>
    <h3>Post</h3>
    <div class="mt-3">
      <post :data="post" />
    </div>
    <div>
      <compose />
    </div>
  </div>
</template>

<script>
import Post from '~components/Post'
import Compose from '~components/Compose'
import api from '~plugins/api'

export default {
  async asyncData(ctx) {
    const { params: { id } } = ctx
    const { data: post } = await api(ctx).fetch()
    return {
      post
    }
  },
  components: {
    Post, Compose
  }
}
</script><commit_msg>Support conversations<commit_after><template>
  <div>
    <div>
      <list :data="before" type="Post" v-if="before.data.length" :key="`${id}-before`" />
    </div>
    <div>
      <post :data="post" @post="addAfter" detail />
    </div>
    <div>
      <compose focus />
    </div>
    <div>
      <list :data="after" type="Post" v-if="after.data.length" :key="`${id}-after`" />
    </div>
  </div>
</template>

<script>
import Post from '~components/Post'
import Compose from '~components/Compose'
import List from '~components/List'
import api from '~plugins/api'
import bus from '~assets/js/bus'

export default {
  async asyncData(ctx) {
    const { params: { id } } = ctx
    const _api = api(ctx)
    const postPromise = _api.fetch()
    const beforePromise = _api.get(`/posts/${id}/thread`, {
      before_id: id
    })
    const afterPromise = _api.get(`/posts/${id}/thread`, {
      since_id: id
    })
    const [{ data: post }, before, after] = await Promise.all([
      postPromise,
      beforePromise,
      afterPromise
    ])
    before.data = before.data.reverse()
    after.data = after.data.reverse()
    return {
      post, before, after, id
    }
  },
  validate ({ params }) {
    return /^\d+$/.test(params.id)
  },
  components: {
    Post, Compose, List
  },
  mounted() {
    bus.$emit('setReply', this.post)
  },
  methods: {
    addAfter (post) {
      this.after.push(post)
    }
  },
  head() {
    let title = this.post.content.text
    if(title.length > 30) {
      title = title.substr(0, 30) + '…'
    }
    title = `${this.post.user.name}: ${title}`
    return {
      title
    }
  }
}
</script>
{'fraction_non_alphanumeric': 0.17767441860465116, 'fraction_numerical': 0.0037209302325581397, 'mean_word_length': 2.4862236628849272, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3666919', 'n_tokens_mistral': 764, 'n_tokens_neox': 762, 'n_words': 168}