~cytrogen/masto-fe

ref: bb131c994569a8fbb139054be656f107dda0abe3 masto-fe/app/javascript/flavours/glitch/components/quoted_status.jsx -rw-r--r-- 1.5 KiB
bb131c99 — Cytrogen [feature] Quote post UI 8 days ago
                                                                                
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
53
54
55
56
57
58
59
60
61
62
63
import PropTypes from 'prop-types';
import { PureComponent } from 'react';

import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';

import { makeGetStatus } from 'flavours/glitch/selectors';

import { Avatar } from './avatar';
import { DisplayName } from './display_name';
import StatusContent from './status_content';
import Permalink from './permalink';

const makeMapStateToProps = () => {
  const getStatus = makeGetStatus();

  const mapStateToProps = (state, { statusId }) => ({
    status: getStatus(state, { id: statusId }),
  });

  return mapStateToProps;
};

class QuotedStatus extends PureComponent {

  static propTypes = {
    statusId: PropTypes.string.isRequired,
    status: ImmutablePropTypes.map,
  };

  render () {
    const { status } = this.props;

    if (!status) {
      return (
        <div className='quoted-status quoted-status--unavailable'>
          <p>This post is unavailable.</p>
        </div>
      );
    }

    const account = status.get('account');

    return (
      <div className='quoted-status'>
        <div className='quoted-status__header'>
          <Permalink href={account.get('url')} to={`/@${account.get('acct')}`} className='quoted-status__account'>
            <Avatar account={account} size={18} />
            <DisplayName account={account} />
          </Permalink>
        </div>
        <StatusContent
          status={status}
          expanded
          collapsible={false}
        />
      </div>
    );
  }

}

export default connect(makeMapStateToProps)(QuotedStatus);