/**
 * ThreadTip component
 *
 * Generated by coz on 2017-01-03,
 * from a template provided by apeman-asset-templates.
 *
 * @function ThreadTip
 */
'use strict'

import React, { Component } from 'react'
import defineDebug from 'debug'
import ThreadCard from '../cards/thread_card'
import { asConnected, asLocaled, asServed, forSpin, forOne, ofThread, combine } from '../../wrappers'

const debug = defineDebug('project:fragment:thread-tip')

/** @lends ThreadTip */
class ThreadTip extends Component {
  render () {
    const s = this
    const { props, l } = s
    let { thread } = props
    let color = thread && thread.color
    return (
      <div className='thread-tip' style={ { borderColor: color } }>
        {
          thread ? (
              <ThreadCard thread={ thread }/>
            ) : (
              <div className="thread-tip-loading">{ l('messages.NOW_LOADING') }</div>
            )
        }
      </div>
    )
  }

  threadDidLoad () {
    const s = this
    s.forceUpdate()
  }
}

export default combine(
  forSpin(),
  forOne(),
  ofThread(),
  asLocaled(),
  asServed(),
  asServed.proxy(),
  asConnected()
)(ThreadTip)
