TimelineOnboarding.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="timeline-onboarding">
  3. <div class="card card-body shadow-sm mb-3 p-5" style="border-radius: 15px;">
  4. <h1 class="text-center mb-4">✨ {{ $t('timeline.onboarding.welcome') }}</h1>
  5. <p class="text-center mb-3" style="font-size: 22px;">
  6. {{ $t('timeline.onboarding.thisIsYourHomeFeed') }}
  7. </p>
  8. <p class="text-center lead">{{ $t('timeline.onboarding.letUsHelpYouFind') }}</p>
  9. <p v-if="newlyFollowed" class="text-center mb-0">
  10. <a href="/i/web" class="btn btn-primary btn-lg primary font-weight-bold rounded-pill px-4" onclick="location.reload()">
  11. {{ $t('timeline.onboarding.refreshFeed') }}
  12. </a>
  13. </p>
  14. </div>
  15. <div class="row">
  16. <div class="col-12 col-md-6 mb-3" v-for="(profile, index) in popularAccounts">
  17. <div class="card shadow-sm border-0 rounded-px">
  18. <div class="card-body p-2">
  19. <profile-card
  20. :key="'pfc' + index"
  21. :profile="profile"
  22. class="w-100"
  23. v-on:follow="follow(index)"
  24. v-on:unfollow="unfollow(index)"
  25. />
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script type="text/javascript">
  33. import ProfileCard from './../profile/ProfileHoverCard.vue';
  34. export default {
  35. props: {
  36. profile: {
  37. type: Object
  38. }
  39. },
  40. components: {
  41. "profile-card": ProfileCard
  42. },
  43. data() {
  44. return {
  45. popularAccounts: [],
  46. newlyFollowed: 0
  47. };
  48. },
  49. mounted() {
  50. this.fetchPopularAccounts();
  51. },
  52. methods: {
  53. fetchPopularAccounts() {
  54. axios.get('/api/pixelfed/discover/accounts/popular')
  55. .then(res => {
  56. this.popularAccounts = res.data;
  57. })
  58. },
  59. follow(index) {
  60. axios.post('/api/v1/accounts/' + this.popularAccounts[index].id + '/follow')
  61. .then(res => {
  62. this.newlyFollowed++;
  63. this.$store.commit('updateRelationship', [res.data]);
  64. this.$emit('update-profile', {
  65. 'following_count': this.profile.following_count + 1
  66. })
  67. });
  68. },
  69. unfollow(index) {
  70. axios.post('/api/v1/accounts/' + this.popularAccounts[index].id + '/unfollow')
  71. .then(res => {
  72. this.newlyFollowed--;
  73. this.$store.commit('updateRelationship', [res.data]);
  74. this.$emit('update-profile', {
  75. 'following_count': this.profile.following_count - 1
  76. })
  77. });
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. .timeline-onboarding {
  84. .profile-hover-card-inner {
  85. width: 100%;
  86. .d-flex {
  87. max-width: 100% !important;
  88. }
  89. }
  90. }
  91. </style>