aboutsummaryrefslogtreecommitdiff
path: root/src/components/thread_tree/thread_tree.js
blob: 4f95122a52cee230e38834cce817f3e1e55cf8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Status from '../status/status.vue'

const debug = console.log

const ThreadTree = {
  components: {
    Status
  },
  name: 'ThreadTree',
  props: {
    depth: Number,
    status: Object,
    inProfile: Boolean,
    conversation: Array,
    collapsable: Boolean,
    isExpanded: Boolean,
    pinnedStatusIdsObject: Object,
    profileUserId: String,

    focused: Function,
    getHighlight: Function,
    getReplies: Function,
    setHighlight: Function,
    toggleExpanded: Function
  },
  computed: {
    reverseLookupTable () {
      return this.conversation.reduce((table, status, index) => {
        table[status.id] = index
        return table
      }, {})
    },
    currentReplies () {
      debug('status:', this.status)
      debug('getReplies:', this.getReplies(this.status.id))
      return this.getReplies(this.status.id).map(({ id }) => this.statusById(id))
    },
  },
  methods: {
    statusById (id) {
      return this.conversation[this.reverseLookupTable[id]]
    },
    collapseThread () {
    },
    showThread () {
    },
    showAllSubthreads () {
    }
  }
}

export default ThreadTree