profile-header.ts 911 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Component, Input } from "@angular/core";
  2. import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
  3. /**
  4. * Generated class for the ProfileHeaderComponent component.
  5. *
  6. * See https://angular.io/api/core/Component for more info on Angular
  7. * Components.
  8. */
  9. @Component({
  10. selector: "profile-header",
  11. templateUrl: "profile-header.html"
  12. })
  13. export class ProfileHeaderComponent {
  14. @Input()
  15. user: any;
  16. constructor(private twitter: TwitterApiProvider) {}
  17. get banner() {
  18. if (this.user.profile_banner_url) {
  19. return this.user.profile_banner_url + "/1500x500";
  20. } else {
  21. return this.user.profile_background_image_url_https;
  22. }
  23. }
  24. async follow(userId) {
  25. await this.twitter.createFriendship(userId);
  26. this.user.following = true;
  27. }
  28. async unfollow(userId) {
  29. await this.twitter.destroyFriendship(userId);
  30. this.user.following = false;
  31. }
  32. }