import { Component, linkEvent } from 'inferno'; import { PrivateMessage as PrivateMessageI, DeletePrivateMessageForm, MarkPrivateMessageAsReadForm, UserView, } from 'lemmy-js-client'; import { WebSocketService, UserService } from '../services'; import { mdToHtml, toast } from '../utils'; import { MomentTime } from './moment-time'; import { PrivateMessageForm } from './private-message-form'; import { UserListing } from './user-listing'; import { i18n } from '../i18next'; interface PrivateMessageState { showReply: boolean; showEdit: boolean; collapsed: boolean; viewSource: boolean; } interface PrivateMessageProps { privateMessage: PrivateMessageI; } export class PrivateMessage extends Component< PrivateMessageProps, PrivateMessageState > { private emptyState: PrivateMessageState = { showReply: false, showEdit: false, collapsed: false, viewSource: false, }; constructor(props: any, context: any) { super(props, context); this.state = this.emptyState; this.handleReplyCancel = this.handleReplyCancel.bind(this); this.handlePrivateMessageCreate = this.handlePrivateMessageCreate.bind( this ); this.handlePrivateMessageEdit = this.handlePrivateMessageEdit.bind(this); } get mine(): boolean { return ( UserService.Instance.user && UserService.Instance.user.id == this.props.privateMessage.creator_id ); } render() { let message = this.props.privateMessage; let userOther: UserView = this.mine ? { name: message.recipient_name, preferred_username: message.recipient_preferred_username, id: message.recipient_id, avatar: message.recipient_avatar, local: message.recipient_local, actor_id: message.recipient_actor_id, published: message.published, number_of_posts: 0, post_score: 0, number_of_comments: 0, comment_score: 0, banned: false, } : { name: message.creator_name, preferred_username: message.creator_preferred_username, id: message.creator_id, avatar: message.creator_avatar, local: message.creator_local, actor_id: message.creator_actor_id, published: message.published, number_of_posts: 0, post_score: 0, number_of_comments: 0, comment_score: 0, banned: false, }; return (
{this.messageUnlessRemoved}) : ( )}