Commit e245074e authored by lain's avatar lain
Browse files

Add status / conversation component.

And wire it up.
parent 18c11e40
import { find, filter, sortBy, toInteger } from 'lodash'
import Status from '../status/status.vue'
import apiService from '../../services/api/api.service.js'
const conversation = {
computed: {
status () {
const id = toInteger(this.$route.params.id)
const statuses = this.$store.state.statuses.allStatuses
const status = find(statuses, {id})
return status
},
conversation () {
if (!this.status) {
return false
}
const conversationId = this.status.statusnet_conversation_id
const statuses = this.$store.state.statuses.allStatuses
const conversation = filter(statuses, { statusnet_conversation_id: conversationId })
return sortBy(conversation, 'id')
}
},
components: {
Status
},
created () {
this.fetchConversation()
},
methods: {
fetchConversation () {
if (this.status) {
const conversationId = this.status.statusnet_conversation_id
apiService.fetchConversation({id: conversationId})
.then((statuses) => this.$store.dispatch('addNewStatuses', { statuses }))
.then(() => this.$store.commit('updateTimestamps'))
} else {
const id = this.$route.params.id
apiService.fetchStatus({id})
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
.then(() => this.fetchConversation())
}
}
}
}
export default conversation
<template>
<div class="timeline panel panel-default">
<div class="panel-heading">Status</div>
<div class="panel-body">
<div class="timeline">
<status v-for="status in conversation" :key="status.id" v-bind:statusoid="status"></status>
</div>
</div>
</div>
</template>
<script src="./conversation.js"></script>
......@@ -5,6 +5,7 @@ import App from './App.vue'
import PublicTimeline from './components/public_timeline/public_timeline.vue'
import PublicAndExternalTimeline from './components/public_and_external_timeline/public_and_external_timeline.vue'
import FriendsTimeline from './components/friends_timeline/friends_timeline.vue'
import Conversation from './components/conversation/conversation.vue'
import statusesModule from './modules/statuses.js'
import usersModule from './modules/users.js'
......@@ -23,7 +24,8 @@ const routes = [
{ path: '/', redirect: '/main/all' },
{ path: '/main/all', component: PublicAndExternalTimeline },
{ path: '/main/public', component: PublicTimeline },
{ path: '/main/friends', component: FriendsTimeline }
{ path: '/main/friends', component: FriendsTimeline },
{ name: 'conversation', path: '/notice/:id', component: Conversation }
]
const router = new VueRouter({
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment