#433: persistency of status form

This commit is contained in:
dave 2019-03-11 16:24:37 -04:00
parent 19015a4ae7
commit 63d7c7bd80
7 changed files with 60 additions and 82 deletions

View file

@ -1,4 +1,4 @@
import { reduce, filter } from 'lodash'
import { reduce, filter, findIndex } from 'lodash'
import Status from '../status/status.vue'
const sortById = (a, b) => {
@ -25,13 +25,13 @@ const sortAndFilterConversation = (conversation) => {
const conversation = {
data () {
return {
highlight: null
highlight: null,
expanded: false
}
},
props: [
'statusoid',
'collapsable',
'replying'
'collapsable'
],
computed: {
status () {
@ -49,9 +49,18 @@ const conversation = {
return []
}
if (!this.expanded) {
return [this.status]
}
const conversationId = this.status.statusnet_conversation_id
const statuses = this.$store.state.statuses.allStatuses
const conversation = filter(statuses, { statusnet_conversation_id: conversationId })
const statusIndex = findIndex(conversation, { id: this.statusId })
if (statusIndex !== -1) {
conversation[statusIndex] = this.status
}
return sortAndFilterConversation(conversation)
},
replies () {
@ -75,11 +84,13 @@ const conversation = {
components: {
Status
},
created () {
this.fetchConversation()
},
watch: {
'$route': 'fetchConversation'
'$route': 'fetchConversation',
expanded (value) {
if (value) {
this.fetchConversation()
}
}
},
methods: {
fetchConversation () {
@ -99,13 +110,16 @@ const conversation = {
return this.replies[id] || []
},
focused (id) {
return id === this.statusId
return this.expanded && id === this.statusId
},
setHighlight (id) {
this.highlight = id
},
toggleReplying () {
this.$emit('toggleReplying')
getHighlight () {
return this.expanded ? this.highlight : null
},
toggleExpanded () {
this.expanded = !this.expanded
}
}
}

View file

@ -1,9 +1,9 @@
<template>
<div class="timeline panel panel-default">
<div class="panel-heading conversation-heading">
<div class="timeline panel-default" :class="[expanded ? 'panel' : 'panel-disabled']">
<div v-if="expanded" class="panel-heading conversation-heading">
<span class="title"> {{ $t('timeline.conversation') }} </span>
<span v-if="collapsable">
<a href="#" @click.prevent="$emit('toggleExpanded')">{{ $t('timeline.collapse') }}</a>
<a href="#" @click.prevent="toggleExpanded">{{ $t('timeline.collapse') }}</a>
</span>
</div>
<div class="panel-body">
@ -11,15 +11,14 @@
<status
v-for="status in conversation"
@goto="setHighlight"
@toggleReplying="toggleReplying"
:replying="replying && status.id === statusId"
@toggleExpanded="toggleExpanded"
:key="status.id"
:inlineExpanded="collapsable"
:statusoid="status"
:expandable='false'
:expandable='!expanded'
:focused="focused(status.id)"
:inConversation='true'
:highlight="highlight"
:inConversation="expanded"
:highlight="getHighlight()"
:replies="getReplies(status.id)"
class="status-fadein"
/>
@ -29,3 +28,19 @@
</template>
<script src="./conversation.js"></script>
<style lang="scss">
@import '../../_variables.scss';
.timeline {
.panel-disabled {
.status-el {
border-left: none;
border-bottom-width: 1px;
border-bottom-style: solid;
border-color: var(--border, $fallback--border);
border-radius: 0;
}
}
}
</style>