diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index f6c02b64..66d8e9a6 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -535,7 +535,9 @@ class LocalController extends Controller {
$avatar = $actor->getIcon();
$document = $this->documentService->getFromCache($avatar->getId());
- return new FileDisplayResponse($document);
+ $response = new FileDisplayResponse($document);
+ $response->cacheFor(86400);
+ return $response;
}
return new NotFoundResponse();
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php
index 72fd8450..b021a5a6 100644
--- a/lib/Db/CoreRequestBuilder.php
+++ b/lib/Db/CoreRequestBuilder.php
@@ -565,6 +565,7 @@ class CoreRequestBuilder {
->selectAlias('ca.public_key', 'cacheactor_public_key')
->selectAlias('ca.source', 'cacheactor_source')
->selectAlias('ca.creation', 'cacheactor_creation')
+ ->selectAlias('ca.local', 'cacheactor_local')
->leftJoin(
$this->defaultSelectAlias, CoreRequestBuilder::TABLE_CACHE_ACTORS, 'ca',
$expr->eq($pf . '.' . $fieldActorId, 'ca.id')
diff --git a/src/components/ProfileInfo.vue b/src/components/ProfileInfo.vue
index 6506e125..0ca1aeb1 100644
--- a/src/components/ProfileInfo.vue
+++ b/src/components/ProfileInfo.vue
@@ -25,21 +25,27 @@
{{ displayName }}
-
{{ accountInfo.cloudId }}
+
{{ accountInfo.account }}
Website: {{ accountInfo.website.value }}
-
-
+
+
+
+
-
+
-
- {{ accountInfo.posts }} posts
+ {{ accountInfo.details.count.post }} {{ t('social', 'Posts') }}
-
- {{ accountInfo.following }} following
+ {{ accountInfo.details.count.following }} {{ t('social', 'Following') }}
-
- {{ accountInfo.followers }} followers
+ {{ accountInfo.details.count.followers }} {{ t('social', 'Followers') }}
@@ -82,22 +88,31 @@
import { Avatar } from 'nextcloud-vue'
import serverData from '../mixins/serverData'
+import currentUser from '../mixins/currentUserMixin'
+import follow from '../mixins/follow'
export default {
name: 'ProfileInfo',
components: {
Avatar
},
- mixins: [serverData],
+ mixins: [serverData, currentUser, follow],
props: {
uid: {
type: String,
default: ''
}
},
+ data: function() {
+ return {
+ followingText: t('social', 'Following')
+ }
+ },
computed: {
displayName() {
- if (typeof this.accountInfo.displayname !== 'undefined') { return this.accountInfo.displayname.value || '' }
+ if (typeof this.accountInfo.name !== 'undefined' && this.accountInfo.name !== '') {
+ return this.accountInfo.name
+ }
return this.uid
},
accountInfo: function() {
diff --git a/src/components/UserEntry.vue b/src/components/UserEntry.vue
index 601aadcc..95a94c4a 100644
--- a/src/components/UserEntry.vue
+++ b/src/components/UserEntry.vue
@@ -25,10 +25,10 @@
-
+
{{ item.preferredUsername }}
-
-
@@ -65,6 +65,17 @@ export default {
return {
followingText: t('social', 'Following')
}
+ },
+ computed: {
+ id() {
+ if (this.item.actor_info) {
+ return this.item.actor_info.id
+ }
+ return this.item.id
+ },
+ avatarUrl() {
+ return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.id)
+ }
}
}
diff --git a/src/store/account.js b/src/store/account.js
index 6af8ab14..b423a369 100644
--- a/src/store/account.js
+++ b/src/store/account.js
@@ -24,22 +24,54 @@ import axios from 'nextcloud-axios'
import Vue from 'vue'
const state = {
- accounts: {}
+ accounts: {},
+ accountsFollowers: {},
+ accountsFollowing: {}
}
const mutations = {
addAccount(state, { uid, data }) {
Vue.set(state.accounts, uid, data)
+ },
+ addFollowers(state, { uid, data }) {
+ let users = []
+ for (var index in data) {
+ users.push(data[index].actor_info)
+ }
+ Vue.set(state.accountsFollowers, uid, users)
+ },
+ addFollowing(state, { uid, data }) {
+ let users = []
+ for (var index in data) {
+ users.push(data[index].actor_info)
+ }
+ Vue.set(state.accountsFollowing, uid, users)
}
}
const getters = {
getAccount(state) {
return (uid) => state.accounts[uid]
+ },
+ getAccountFollowers(state) {
+ return (uid) => state.accountsFollowers[uid]
+ },
+ getAccountFollowing(state) {
+ return (uid) => state.accountsFollowing[uid]
}
}
const actions = {
fetchAccountInfo(context, uid) {
- axios.get(OC.generateUrl('apps/social/local/account/' + uid)).then((response) => {
- context.commit('addAccount', { uid: uid, data: response.data })
+ axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => {
+ context.commit('addAccount', { uid: uid, data: response.data.result.account })
+ })
+ },
+ fetchAccountFollowers(context, uid) {
+ axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => {
+ context.commit('addFollowers', { uid: uid, data: response.data.result })
+ })
+ },
+ fetchAccountFollowing(context, uid) {
+ axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => {
+ context.commit('addFollowing', { uid: uid, data: response.data.result })
})
}
}
diff --git a/src/views/ProfileFollowers.vue b/src/views/ProfileFollowers.vue
index 862163df..f7dabcc7 100644
--- a/src/views/ProfileFollowers.vue
+++ b/src/views/ProfileFollowers.vue
@@ -31,6 +31,7 @@
max-width: 700px;
margin: 15px auto;
display: flex;
+ flex-wrap: wrap;
}
.user-entry {
width: 50%;
@@ -46,24 +47,19 @@ export default {
UserEntry
},
computed: {
- timeline: function() {
- return this.$store.getters.getTimeline
- },
- users() {
- return [
- {
- id: 'admin',
- displayName: 'Administrator',
- description: 'My social account',
- following: true
- },
- {
- id: 'admin',
- displayName: 'Administrator',
- description: 'My social account',
- following: false
- }
- ]
+ users: function() {
+ if (this.$route.name === 'profile.followers') {
+ return this.$store.getters.getAccountFollowers(this.$route.params.account)
+ } else {
+ return this.$store.getters.getAccountFollowing(this.$route.params.account)
+ }
+ }
+ },
+ beforeMount() {
+ if (this.$route.name === 'profile.followers') {
+ this.$store.dispatch('fetchAccountFollowers', this.$route.params.account)
+ } else {
+ this.$store.dispatch('fetchAccountFollowing', this.$route.params.account)
}
}
}