2020-04-15 05:42:18 +02:00
|
|
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
2024-03-07 06:59:00 +01:00
|
|
|
import { faLink, faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons";
|
2020-04-15 04:12:07 +02:00
|
|
|
|
2023-08-12 23:59:34 +02:00
|
|
|
import { SettingsService } from '../../../../../services/settings.service';
|
2020-04-15 04:12:07 +02:00
|
|
|
import { Attachment } from '../../../../../services/models/mastodon.interfaces';
|
2024-03-07 06:59:00 +01:00
|
|
|
import { StatusWrapper } from '../../../../../models/common.model';
|
|
|
|
import { OpenThreadEvent } from '../../../../../services/tools.service';
|
2020-04-15 04:12:07 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-attachement-image',
|
|
|
|
templateUrl: './attachement-image.component.html',
|
|
|
|
styleUrls: ['./attachement-image.component.scss']
|
|
|
|
})
|
|
|
|
export class AttachementImageComponent implements OnInit {
|
2020-04-15 06:42:51 +02:00
|
|
|
faLink = faLink;
|
2024-03-07 06:59:00 +01:00
|
|
|
faExternalLinkAlt = faExternalLinkAlt;
|
2023-08-12 23:59:34 +02:00
|
|
|
displayAltLabel: boolean;
|
2020-04-15 06:42:51 +02:00
|
|
|
|
2020-04-15 04:12:07 +02:00
|
|
|
@Input() attachment: Attachment;
|
2024-03-07 06:59:00 +01:00
|
|
|
@Input() status: StatusWrapper;
|
2020-04-15 05:42:18 +02:00
|
|
|
@Output() openEvent = new EventEmitter();
|
2024-03-07 06:59:00 +01:00
|
|
|
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
|
2020-04-15 04:12:07 +02:00
|
|
|
|
2023-08-12 23:59:34 +02:00
|
|
|
constructor(
|
|
|
|
private readonly settingsService: SettingsService
|
|
|
|
) {
|
|
|
|
this.displayAltLabel = this.settingsService.getSettings().enableAltLabel;
|
|
|
|
}
|
2020-04-15 04:12:07 +02:00
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:42:18 +02:00
|
|
|
attachmentSelected(): boolean {
|
|
|
|
this.openEvent.next();
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 06:42:51 +02:00
|
|
|
|
|
|
|
openExternal(): boolean {
|
|
|
|
window.open(this.attachment.url, '_blank');
|
|
|
|
return false;
|
|
|
|
}
|
2024-03-07 06:59:00 +01:00
|
|
|
|
|
|
|
openStatus(): boolean {
|
|
|
|
if(!this.status) return false;
|
|
|
|
|
|
|
|
const openThreadEvent = new OpenThreadEvent(this.status.status, this.status.provider);
|
|
|
|
this.browseThreadEvent.next(openThreadEvent);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-15 04:12:07 +02:00
|
|
|
}
|