2021-11-30 21:27:37 -05:00
|
|
|
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChange, SimpleChanges, } from "@angular/core";
|
2017-12-15 23:22:34 -05:00
|
|
|
import { DomSanitizer, SafeResourceUrl } from "@angular/platform-browser";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { FE_Integration } from "../shared/models/integration";
|
2018-10-23 00:10:28 -04:00
|
|
|
import { MediaService } from "../shared/services/media.service";
|
2017-12-15 23:22:34 -05:00
|
|
|
|
|
|
|
@Component({
|
2021-09-01 19:29:24 -04:00
|
|
|
selector: "my-integration-bag",
|
2017-12-15 23:22:34 -05:00
|
|
|
templateUrl: "./integration-bag.component.html",
|
|
|
|
styleUrls: ["./integration-bag.component.scss"],
|
|
|
|
})
|
2018-10-23 00:10:28 -04:00
|
|
|
export class IntegrationBagComponent implements OnChanges {
|
2017-12-24 04:02:57 -05:00
|
|
|
@Input() integrations: FE_Integration[];
|
2021-09-01 19:01:01 -04:00
|
|
|
@Output() integrationClicked: EventEmitter<FE_Integration> =
|
|
|
|
new EventEmitter<FE_Integration>();
|
2017-12-15 23:22:34 -05:00
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
constructor(private sanitizer: DomSanitizer, private media: MediaService) {}
|
2018-10-23 00:10:28 -04:00
|
|
|
|
|
|
|
public ngOnChanges(changes: SimpleChanges) {
|
|
|
|
const change: SimpleChange = changes.integrations;
|
|
|
|
|
|
|
|
(<FE_Integration[]>change.currentValue).map(async (i) => {
|
|
|
|
if (i.avatarUrl.startsWith("mxc://")) {
|
2021-09-01 19:01:01 -04:00
|
|
|
i.avatarUrl = await this.media.getThumbnailUrl(
|
|
|
|
i.avatarUrl,
|
|
|
|
128,
|
|
|
|
128,
|
|
|
|
"scale",
|
|
|
|
true
|
|
|
|
);
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
});
|
2017-12-15 23:22:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public getSafeUrl(url: string): SafeResourceUrl {
|
|
|
|
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
|
|
|
|
}
|
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
public onClick(integration: FE_Integration) {
|
2017-12-15 23:22:34 -05:00
|
|
|
this.integrationClicked.emit(integration);
|
|
|
|
}
|
|
|
|
}
|