summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-12-05 11:44:19 +0100
committerGitHub <noreply@github.com>2018-12-05 11:44:19 +0100
commit2059a5f6cd9c5ea85479e48e381322e856fc527b (patch)
tree4742ccd0d998f1f8bf223b9a99e14a31e4eb3278 /src
parent107d8b28fbfd948f671019ff7d7babf0a2a368bd (diff)
parent8184dbd70583e79686322f5b551167168e283392 (diff)
Merge pull request #135 from nextcloud-gmbh/fix/do-not-follow-your-own-account
exception when following yourself
Diffstat (limited to 'src')
-rw-r--r--src/components/ProfileInfo.vue8
-rw-r--r--src/components/UserEntry.vue18
-rw-r--r--src/mixins/currentUserMixin.js9
-rw-r--r--src/mixins/follow.js4
4 files changed, 25 insertions, 14 deletions
diff --git a/src/components/ProfileInfo.vue b/src/components/ProfileInfo.vue
index 983a7fe1..9a4ba0f1 100644
--- a/src/components/ProfileInfo.vue
+++ b/src/components/ProfileInfo.vue
@@ -27,7 +27,7 @@
<h2>{{ displayName }}</h2>
<p>{{ accountInfo.account }}</p>
<p v-if="accountInfo.website">Website: <a :href="accountInfo.website.value">{{ accountInfo.website.value }}</a></p>
- <template v-if="currentUser.uid !== accountInfo.preferredUsername">
+ <template v-if="cloudId !== accountInfo.account">
<button v-if="accountInfo.details && accountInfo.details.following" :class="{'icon-loading-small': followLoading}"
@click="unfollow()"
@mouseover="followingText=t('social', 'Unfollow')" @mouseleave="followingText=t('social', 'Following')">
@@ -100,7 +100,11 @@ export default {
components: {
Avatar
},
- mixins: [serverData, currentUser, follow],
+ mixins: [
+ serverData,
+ currentUser,
+ follow
+ ],
props: {
uid: {
type: String,
diff --git a/src/components/UserEntry.vue b/src/components/UserEntry.vue
index b583921e..42031ba4 100644
--- a/src/components/UserEntry.vue
+++ b/src/components/UserEntry.vue
@@ -36,12 +36,14 @@
<!-- TODO check where the html is coming from to avoid security issues -->
<p v-html="item.summary" />
</div>
- <button v-if="item.details && item.details.following" :class="{'icon-loading-small': followLoading}"
- @click="unfollow()"
- @mouseover="followingText=t('social', 'Unfollow')" @mouseleave="followingText=t('social', 'Following')">
- <span><span class="icon-checkmark" />{{ followingText }}</span></button>
- <button v-else-if="item.details" :class="{'icon-loading-small': followLoading}" class="primary"
- @click="follow"><span>{{ t('social', 'Follow') }}</span></button>
+ <template v-if="cloudId !== item.account">
+ <button v-if="item.details && item.details.following" :class="{'icon-loading-small': followLoading}"
+ @click="unfollow()"
+ @mouseover="followingText=t('social', 'Unfollow')" @mouseleave="followingText=t('social', 'Following')">
+ <span><span class="icon-checkmark" />{{ followingText }}</span></button>
+ <button v-else-if="item.details" :class="{'icon-loading-small': followLoading}" class="primary"
+ @click="follow"><span>{{ t('social', 'Follow') }}</span></button>
+ </template>
</div>
</div>
</template>
@@ -49,6 +51,7 @@
<script>
import { Avatar } from 'nextcloud-vue'
import follow from '../mixins/follow'
+import currentUser from '../mixins/currentUserMixin'
export default {
name: 'UserEntry',
@@ -56,7 +59,8 @@ export default {
Avatar
},
mixins: [
- follow
+ follow,
+ currentUser
],
props: {
item: { type: Object, default: () => {} }
diff --git a/src/mixins/currentUserMixin.js b/src/mixins/currentUserMixin.js
index 8bc5adfa..1678b3f3 100644
--- a/src/mixins/currentUserMixin.js
+++ b/src/mixins/currentUserMixin.js
@@ -26,13 +26,16 @@ export default {
serverData
],
computed: {
- currentUser: function() {
+ currentUser() {
return OC.getCurrentUser()
},
- socialId: function() {
+ socialId() {
+ return '@' + this.cloudId
+ },
+ cloudId() {
const url = document.createElement('a')
url.setAttribute('href', this.serverData.cloudAddress)
- return '@' + OC.getCurrentUser().uid + '@' + url.hostname
+ return this.currentUser.uid + '@' + url.hostname
}
}
}
diff --git a/src/mixins/follow.js b/src/mixins/follow.js
index 2a9a3aa9..43e5e541 100644
--- a/src/mixins/follow.js
+++ b/src/mixins/follow.js
@@ -48,7 +48,7 @@ export default {
}).catch((error) => {
this.followLoading = false
OC.Notification.showTemporary(`Failed to follow user ${this.item.account}`)
- console.error(`Failed to follow user ${this.item.account}`, error)
+ console.error(`Failed to follow user ${this.item.account}`, error.response.data)
})
},
@@ -63,7 +63,7 @@ export default {
}).catch((error) => {
this.followLoading = false
OC.Notification.showTemporary(`Failed to unfollow user ${this.item.account}`)
- console.error(`Failed to unfollow user ${this.item.account}`, error)
+ console.error(`Failed to unfollow user ${this.item.account}`, error.response.data)
})
}
}