Add status / conversation component.
And wire it up.
This commit is contained in:
parent
18c11e405a
commit
e245074ef7
3 changed files with 63 additions and 1 deletions
48
src/components/conversation/conversation.js
Normal file
48
src/components/conversation/conversation.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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
|
12
src/components/conversation/conversation.vue
Normal file
12
src/components/conversation/conversation.vue
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<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 PublicTimeline from './components/public_timeline/public_timeline.vue'
|
||||||
import PublicAndExternalTimeline from './components/public_and_external_timeline/public_and_external_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 FriendsTimeline from './components/friends_timeline/friends_timeline.vue'
|
||||||
|
import Conversation from './components/conversation/conversation.vue'
|
||||||
|
|
||||||
import statusesModule from './modules/statuses.js'
|
import statusesModule from './modules/statuses.js'
|
||||||
import usersModule from './modules/users.js'
|
import usersModule from './modules/users.js'
|
||||||
|
@ -23,7 +24,8 @@ const routes = [
|
||||||
{ path: '/', redirect: '/main/all' },
|
{ path: '/', redirect: '/main/all' },
|
||||||
{ path: '/main/all', component: PublicAndExternalTimeline },
|
{ path: '/main/all', component: PublicAndExternalTimeline },
|
||||||
{ path: '/main/public', component: PublicTimeline },
|
{ 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({
|
const router = new VueRouter({
|
||||||
|
|
Loading…
Reference in a new issue