Merge branch 'refactor-recommendations' into 'develop'
remove unneeded numbered variables who_to_follow See merge request pleroma/pleroma-fe!436
This commit is contained in:
commit
a80c8fd24c
@ -2,62 +2,31 @@ import apiService from '../../services/api/api.service.js'
|
|||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
||||||
function showWhoToFollow (panel, reply) {
|
function showWhoToFollow (panel, reply) {
|
||||||
var users = reply
|
panel.usersToFollow.forEach((toFollow, index) => {
|
||||||
var cn
|
let randIndex = Math.floor(Math.random() * reply.length)
|
||||||
var index
|
let user = reply[randIndex]
|
||||||
var step = 7
|
let img = user.avatar || '/images/avi.png'
|
||||||
cn = Math.floor(Math.random() * step)
|
let name = user.acct
|
||||||
for (index = 0; index < 3; index++) {
|
|
||||||
var user
|
toFollow.img = img
|
||||||
user = users[cn]
|
toFollow.name = name
|
||||||
var img
|
|
||||||
if (user.avatar) {
|
panel.$store.state.api.backendInteractor.externalProfile(name)
|
||||||
img = user.avatar
|
.then((externalUser) => {
|
||||||
} else {
|
if (!externalUser.error) {
|
||||||
img = '/images/avi.png'
|
panel.$store.commit('addNewUsers', [externalUser])
|
||||||
}
|
toFollow.id = externalUser.id
|
||||||
var name = user.acct
|
}
|
||||||
if (index === 0) {
|
})
|
||||||
panel.img1 = img
|
})
|
||||||
panel.name1 = name
|
|
||||||
panel.$store.state.api.backendInteractor.externalProfile(name)
|
|
||||||
.then((externalUser) => {
|
|
||||||
if (!externalUser.error) {
|
|
||||||
panel.$store.commit('addNewUsers', [externalUser])
|
|
||||||
panel.id1 = externalUser.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (index === 1) {
|
|
||||||
panel.img2 = img
|
|
||||||
panel.name2 = name
|
|
||||||
panel.$store.state.api.backendInteractor.externalProfile(name)
|
|
||||||
.then((externalUser) => {
|
|
||||||
if (!externalUser.error) {
|
|
||||||
panel.$store.commit('addNewUsers', [externalUser])
|
|
||||||
panel.id2 = externalUser.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (index === 2) {
|
|
||||||
panel.img3 = img
|
|
||||||
panel.name3 = name
|
|
||||||
panel.$store.state.api.backendInteractor.externalProfile(name)
|
|
||||||
.then((externalUser) => {
|
|
||||||
if (!externalUser.error) {
|
|
||||||
panel.$store.commit('addNewUsers', [externalUser])
|
|
||||||
panel.id3 = externalUser.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
cn = (cn + step) % users.length
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWhoToFollow (panel) {
|
function getWhoToFollow (panel) {
|
||||||
var credentials = panel.$store.state.users.currentUser.credentials
|
var credentials = panel.$store.state.users.currentUser.credentials
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
panel.name1 = 'Loading...'
|
panel.usersToFollow.forEach(toFollow => {
|
||||||
panel.name2 = 'Loading...'
|
toFollow.name = 'Loading...'
|
||||||
panel.name3 = 'Loading...'
|
})
|
||||||
apiService.suggestions({credentials: credentials})
|
apiService.suggestions({credentials: credentials})
|
||||||
.then((reply) => {
|
.then((reply) => {
|
||||||
showWhoToFollow(panel, reply)
|
showWhoToFollow(panel, reply)
|
||||||
@ -67,27 +36,24 @@ function getWhoToFollow (panel) {
|
|||||||
|
|
||||||
const WhoToFollowPanel = {
|
const WhoToFollowPanel = {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
img1: '/images/avi.png',
|
usersToFollow: new Array(3).fill().map(x => (
|
||||||
name1: '',
|
{
|
||||||
id1: 0,
|
img: '/images/avi.png',
|
||||||
img2: '/images/avi.png',
|
name: '',
|
||||||
name2: '',
|
id: 0
|
||||||
id2: 0,
|
}
|
||||||
img3: '/images/avi.png',
|
))
|
||||||
name3: '',
|
|
||||||
id3: 0
|
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
user: function () {
|
user: function () {
|
||||||
return this.$store.state.users.currentUser.screen_name
|
return this.$store.state.users.currentUser.screen_name
|
||||||
},
|
},
|
||||||
moreUrl: function () {
|
moreUrl: function () {
|
||||||
var host = window.location.hostname
|
const host = window.location.hostname
|
||||||
var user = this.user
|
const user = this.user
|
||||||
var suggestionsWeb = this.$store.state.instance.suggestionsWeb
|
const suggestionsWeb = this.$store.state.instance.suggestionsWeb
|
||||||
var url
|
const url = suggestionsWeb.replace(/{{host}}/g, encodeURIComponent(host))
|
||||||
url = suggestionsWeb.replace(/{{host}}/g, encodeURIComponent(host))
|
.replace(/{{user}}/g, encodeURIComponent(user))
|
||||||
url = url.replace(/{{user}}/g, encodeURIComponent(user))
|
|
||||||
return url
|
return url
|
||||||
},
|
},
|
||||||
suggestionsEnabled () {
|
suggestionsEnabled () {
|
||||||
|
@ -8,9 +8,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body who-to-follow">
|
<div class="panel-body who-to-follow">
|
||||||
<p>
|
<p>
|
||||||
<img v-bind:src="img1"/> <router-link :to="userProfileLink(id1, name1)">{{ name1 }}</router-link><br>
|
<span v-for="user in usersToFollow">
|
||||||
<img v-bind:src="img2"/> <router-link :to="userProfileLink(id2, name2)">{{ name2 }}</router-link><br>
|
<img v-bind:src="user.img" />
|
||||||
<img v-bind:src="img3"/> <router-link :to="userProfileLink(id3, name3)">{{ name3 }}</router-link><br>
|
<router-link v-bind:to="userProfileLink(user.id, user.name)">
|
||||||
|
{{user.name}}
|
||||||
|
</router-link><br />
|
||||||
|
</span>
|
||||||
<img v-bind:src="$store.state.instance.logo"> <a v-bind:href="moreUrl" target="_blank">{{$t('who_to_follow.more')}}</a>
|
<img v-bind:src="$store.state.instance.logo"> <a v-bind:href="moreUrl" target="_blank">{{$t('who_to_follow.more')}}</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user