123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <template>
- <div class="discover-find-friends-component">
- <div v-if="isLoaded" class="container-fluid mt-3">
- <div class="row">
- <div class="col-md-4 col-lg-3">
- <sidebar :user="profile" />
- </div>
- <div class="col-md-6 col-lg-6">
- <b-breadcrumb class="font-default" :items="breadcrumbItems"></b-breadcrumb>
- <h1 class="font-default">Find Friends</h1>
- <!-- <p class="font-default lead">Posts from hashtags you follow</p> -->
- <hr>
- <b-spinner v-if="isLoading" />
- <div v-if="!isLoading" class="row justify-content-center">
- <div class="col-12 col-lg-10 mb-3" v-for="(profile, index) in popularAccounts">
- <div class="card shadow-sm border-0 rounded-px">
- <div class="card-body p-2">
- <profile-card
- :key="'pfc' + index"
- :profile="profile"
- class="w-100"
- v-on:follow="follow(index)"
- v-on:unfollow="unfollow(index)"
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script type="text/javascript">
- import Drawer from './../partials/drawer.vue';
- import Sidebar from './../partials/sidebar.vue';
- import StatusCard from './../partials/TimelineStatus.vue';
- import ProfileCard from './../partials/profile/ProfileHoverCard.vue';
- export default {
- components: {
- "drawer": Drawer,
- "sidebar": Sidebar,
- "status-card": StatusCard,
- "profile-card": ProfileCard
- },
- data() {
- return {
- isLoaded: true,
- isLoading: true,
- profile: window._sharedData.user,
- feed: [],
- popular: [],
- popularAccounts: [],
- popularLoaded: false,
- breadcrumbItems: [
- {
- text: 'Discover',
- href: '/i/web/discover'
- },
- {
- text: 'Find Friends',
- active: true
- }
- ]
- }
- },
- mounted() {
- this.fetchConfig();
- },
- methods: {
- fetchConfig() {
- axios.get('/api/pixelfed/v2/discover/meta')
- .then(res => {
- if(res.data.friends.enabled == false) {
- this.$router.push('/i/web/discover');
- } else {
- this.fetchPopularAccounts();
- }
- })
- .catch(e => {
- this.isLoading = false;
- })
- },
- fetchPopular() {
- axios.get('/api/pixelfed/v2/discover/account-insights')
- .then(res => {
- this.popular = res.data;
- this.popularLoaded = true;
- this.isLoading = false;
- })
- .catch(e => {
- this.isLoading = false;
- })
- },
- formatCount(val) {
- return App.util.format.count(val);
- },
- timeago(ts) {
- return App.util.format.timeAgo(ts);
- },
- fetchPopularAccounts() {
- axios.get('/api/pixelfed/discover/accounts/popular')
- .then(res => {
- this.popularAccounts = res.data;
- this.isLoading = false;
- })
- .catch(e => {
- this.isLoading = false;
- })
- },
- follow(index) {
- axios.post('/api/v1/accounts/' + this.popularAccounts[index].id + '/follow')
- .then(res => {
- this.newlyFollowed++;
- this.$store.commit('updateRelationship', [res.data]);
- this.$emit('update-profile', {
- 'following_count': this.profile.following_count + 1
- })
- });
- },
- unfollow(index) {
- axios.post('/api/v1/accounts/' + this.popularAccounts[index].id + '/unfollow')
- .then(res => {
- this.newlyFollowed--;
- this.$store.commit('updateRelationship', [res.data]);
- this.$emit('update-profile', {
- 'following_count': this.profile.following_count - 1
- })
- });
- }
- }
- }
- </script>
- <style lang="scss">
- .discover-find-friends-component {
- .bg-stellar {
- background: #7474BF;
- background: -webkit-linear-gradient(to right, #348AC7, #7474BF);
- background: linear-gradient(to right, #348AC7, #7474BF);
- }
- .bg-midnight {
- background: #232526;
- background: -webkit-linear-gradient(to right, #414345, #232526);
- background: linear-gradient(to right, #414345, #232526);
- }
- .font-default {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
- letter-spacing: -0.7px;
- }
- .active {
- font-weight: 700;
- }
- .profile-hover-card-inner {
- width: 100%;
- .d-flex {
- max-width: 100% !important;
- }
- }
- }
- </style>
|