From 482cd52f77fa514ace73a7e17f169c0518f000b1 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Fri, 30 Aug 2019 12:58:48 -0400
Subject: [PATCH] stop fetching whole conversation when change highlighted
status
---
src/components/conversation/conversation.js | 22 ++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js
index 398b7638..dc58cd58 100644
--- a/src/components/conversation/conversation.js
+++ b/src/components/conversation/conversation.js
@@ -1,4 +1,4 @@
-import { reduce, filter, findIndex, clone } from 'lodash'
+import { reduce, filter, findIndex, clone, get } from 'lodash'
import Status from '../status/status.vue'
const sortById = (a, b) => {
@@ -61,11 +61,7 @@ const conversation = {
}
},
conversationId () {
- if (this.status.retweeted_status) {
- return this.status.retweeted_status.statusnet_conversation_id
- } else {
- return this.status.statusnet_conversation_id
- }
+ return this.getConversationId(this.statusoid)
},
conversation () {
if (!this.status) {
@@ -110,7 +106,15 @@ const conversation = {
Status
},
watch: {
- status: 'fetchConversation',
+ statusoid (newVal, oldVal) {
+ const newConversationId = this.getConversationId(newVal)
+ const oldConversationId = this.getConversationId(oldVal)
+ if (newConversationId && oldConversationId && newConversationId === oldConversationId) {
+ this.setHighlight(this.statusId)
+ } else {
+ this.fetchConversation()
+ }
+ },
expanded (value) {
if (value) {
this.fetchConversation()
@@ -150,6 +154,10 @@ const conversation = {
},
toggleExpanded () {
this.expanded = !this.expanded
+ },
+ getConversationId (statusId) {
+ const status = this.$store.state.statuses.allStatusesObject[statusId]
+ return get(status, 'retweeted_status.statusnet_conversation_id', get(status, 'statusnet_conversation_id'))
}
}
}