2018-12-12 06:10:25 +01:00
|
|
|
import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
|
2018-10-27 02:20:01 +02:00
|
|
|
import { Status, Account } from "../../../services/models/mastodon.interfaces";
|
2018-10-02 05:46:12 +02:00
|
|
|
import { StatusWrapper } from "../stream.component";
|
2019-02-19 04:44:21 +01:00
|
|
|
import { OpenThreadEvent } from "../../../services/tools.service";
|
2018-09-16 04:08:59 +02:00
|
|
|
|
|
|
|
@Component({
|
2018-09-19 07:03:07 +02:00
|
|
|
selector: "app-status",
|
|
|
|
templateUrl: "./status.component.html",
|
|
|
|
styleUrls: ["./status.component.scss"]
|
2018-09-16 04:08:59 +02:00
|
|
|
})
|
|
|
|
export class StatusComponent implements OnInit {
|
2018-09-21 04:51:18 +02:00
|
|
|
displayedStatus: Status;
|
|
|
|
reblog: boolean;
|
2018-09-21 05:27:04 +02:00
|
|
|
hasAttachments: boolean;
|
2018-10-13 07:10:43 +02:00
|
|
|
replyingToStatus: boolean;
|
2018-09-21 04:51:18 +02:00
|
|
|
|
2018-12-12 07:08:29 +01:00
|
|
|
@Output() browseAccountEvent = new EventEmitter<string>();
|
|
|
|
@Output() browseHashtagEvent = new EventEmitter<string>();
|
2019-02-19 04:44:21 +01:00
|
|
|
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
|
2018-10-22 07:41:54 +02:00
|
|
|
|
2018-10-02 05:46:12 +02:00
|
|
|
private _statusWrapper: StatusWrapper;
|
|
|
|
status: Status;
|
|
|
|
@Input('statusWrapper')
|
|
|
|
set statusWrapper(value: StatusWrapper) {
|
|
|
|
this._statusWrapper = value;
|
|
|
|
this.status = value.status;
|
2018-09-21 04:51:18 +02:00
|
|
|
|
2018-10-27 02:20:01 +02:00
|
|
|
if (this.status.reblog) {
|
2018-09-21 04:51:18 +02:00
|
|
|
this.reblog = true;
|
2018-10-02 05:46:12 +02:00
|
|
|
this.displayedStatus = this.status.reblog;
|
2018-09-21 04:51:18 +02:00
|
|
|
} else {
|
2018-10-02 05:46:12 +02:00
|
|
|
this.displayedStatus = this.status;
|
2018-09-21 04:51:18 +02:00
|
|
|
}
|
2018-10-27 02:20:01 +02:00
|
|
|
|
|
|
|
if (!this.displayedStatus.account.display_name) {
|
2018-09-21 04:51:18 +02:00
|
|
|
this.displayedStatus.account.display_name = this.displayedStatus.account.username;
|
|
|
|
}
|
|
|
|
|
2018-10-27 02:20:01 +02:00
|
|
|
if (this.displayedStatus.media_attachments && this.displayedStatus.media_attachments.length > 0) {
|
2018-09-21 05:27:04 +02:00
|
|
|
this.hasAttachments = true;
|
|
|
|
}
|
2018-10-27 02:20:01 +02:00
|
|
|
}
|
|
|
|
get statusWrapper(): StatusWrapper {
|
2018-10-02 05:46:12 +02:00
|
|
|
return this._statusWrapper;
|
2018-09-21 04:51:18 +02:00
|
|
|
}
|
2018-10-27 02:20:01 +02:00
|
|
|
|
2018-12-12 06:10:25 +01:00
|
|
|
constructor() { }
|
2018-09-16 04:08:59 +02:00
|
|
|
|
2018-10-27 02:20:01 +02:00
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
openAccount(account: Account): boolean {
|
2019-01-28 05:08:43 +01:00
|
|
|
let accountName = account.acct;
|
|
|
|
if (!accountName.includes('@'))
|
|
|
|
accountName += `@${account.url.replace('https://', '').split('/')[0]}`;
|
2018-10-31 05:02:03 +01:00
|
|
|
|
2018-12-12 07:08:29 +01:00
|
|
|
this.browseAccountEvent.next(accountName);
|
2018-10-22 07:41:54 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-27 02:20:01 +02:00
|
|
|
openReply(): boolean {
|
2018-10-13 07:10:43 +02:00
|
|
|
this.replyingToStatus = !this.replyingToStatus;
|
2018-10-27 02:20:01 +02:00
|
|
|
|
2018-10-13 07:10:43 +02:00
|
|
|
return false;
|
|
|
|
}
|
2018-10-13 17:38:23 +02:00
|
|
|
|
|
|
|
closeReply(): boolean {
|
|
|
|
this.replyingToStatus = false;
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-27 02:20:01 +02:00
|
|
|
|
2018-10-31 04:27:20 +01:00
|
|
|
accountSelected(accountName: string): void {
|
2018-12-12 07:08:29 +01:00
|
|
|
this.browseAccountEvent.next(accountName);
|
2018-10-31 04:27:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hashtagSelected(hashtag: string): void {
|
2018-12-12 07:08:29 +01:00
|
|
|
this.browseHashtagEvent.next(hashtag);
|
2018-10-31 04:27:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
textSelected(): void {
|
2019-01-28 05:08:43 +01:00
|
|
|
const status = this._statusWrapper.status;
|
2019-02-19 04:44:21 +01:00
|
|
|
const accountInfo = this._statusWrapper.provider;
|
2019-01-28 05:08:43 +01:00
|
|
|
|
2019-02-19 04:44:21 +01:00
|
|
|
let openThread: OpenThreadEvent;
|
|
|
|
if (status.reblog) {
|
|
|
|
openThread = new OpenThreadEvent(status.reblog, accountInfo);
|
2019-01-28 05:08:43 +01:00
|
|
|
} else {
|
2019-02-19 04:44:21 +01:00
|
|
|
openThread = new OpenThreadEvent(status, accountInfo);
|
2019-01-28 05:08:43 +01:00
|
|
|
}
|
2019-02-19 04:44:21 +01:00
|
|
|
|
|
|
|
this.browseThreadEvent.next(openThread);
|
2018-10-27 02:20:01 +02:00
|
|
|
}
|
2018-09-16 04:08:59 +02:00
|
|
|
}
|