2018-12-21 16:33:29 +00:00
|
|
|
<!--
|
|
|
|
- @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
|
|
|
|
-
|
|
|
|
- @author Julius Härtl <jus@bitgrid.net>
|
|
|
|
-
|
|
|
|
- @license GNU AGPL version 3 or any later version
|
|
|
|
-
|
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
|
|
|
-
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU Affero General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
2019-10-04 13:07:24 +00:00
|
|
|
<!-- Show button only if user is authenticated and she is not the same as the account viewed -->
|
2019-10-25 11:26:16 +00:00
|
|
|
<div v-if="!serverData.public && accountInfo && accountInfo.viewerLink!='viewer'">
|
2023-01-11 17:05:42 +00:00
|
|
|
<div v-if="isCurrentUserFollowing"
|
|
|
|
class="follow-button-container">
|
|
|
|
<NcButton :disabled="loading"
|
|
|
|
class="follow-button follow-button--following"
|
|
|
|
type="success">
|
|
|
|
<template #icon>
|
|
|
|
<Check :size="32" />
|
|
|
|
</template>
|
|
|
|
{{ t('social', 'Following') }}
|
|
|
|
</NcButton>
|
|
|
|
<NcButton :disabled="loading"
|
|
|
|
class="follow-button follow-button--unfollow"
|
|
|
|
type="error"
|
|
|
|
@click="unfollow()">
|
|
|
|
<template #icon>
|
|
|
|
<CloseOctagon :size="32" />
|
|
|
|
</template>
|
|
|
|
{{ t('social', 'Unfollow') }}
|
|
|
|
</NcButton>
|
|
|
|
</div>
|
2022-10-27 13:47:14 +00:00
|
|
|
<NcButton v-else
|
2023-01-11 17:05:42 +00:00
|
|
|
:disabled="loading"
|
|
|
|
type="primary"
|
|
|
|
class="follow-button"
|
2019-01-09 14:59:59 +00:00
|
|
|
@click="follow">
|
2022-10-27 13:47:14 +00:00
|
|
|
{{ t('social', 'Follow') }}
|
|
|
|
</NcButton>
|
2018-12-21 16:33:29 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-09-12 13:42:18 +00:00
|
|
|
import accountMixins from '../mixins/accountMixins.js'
|
|
|
|
import currentUser from '../mixins/currentUserMixin.js'
|
2022-10-27 13:47:14 +00:00
|
|
|
import Check from 'vue-material-design-icons/Check.vue'
|
2023-01-11 17:05:42 +00:00
|
|
|
import CloseOctagon from 'vue-material-design-icons/CloseOctagon.vue'
|
2022-10-27 13:47:14 +00:00
|
|
|
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
|
2018-12-21 16:33:29 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'FollowButton',
|
2022-10-27 13:47:14 +00:00
|
|
|
components: {
|
|
|
|
Check,
|
2023-01-11 17:05:42 +00:00
|
|
|
CloseOctagon,
|
2022-10-27 13:47:14 +00:00
|
|
|
NcButton,
|
|
|
|
},
|
2018-12-21 16:33:29 +00:00
|
|
|
mixins: [
|
2019-10-07 09:10:16 +00:00
|
|
|
accountMixins,
|
2022-10-27 13:07:12 +00:00
|
|
|
currentUser,
|
2018-12-21 16:33:29 +00:00
|
|
|
],
|
|
|
|
props: {
|
|
|
|
account: {
|
|
|
|
type: String,
|
2022-10-27 13:07:12 +00:00
|
|
|
default: '',
|
2019-10-25 11:26:16 +00:00
|
|
|
},
|
|
|
|
uid: {
|
|
|
|
type: String,
|
2022-10-27 13:07:12 +00:00
|
|
|
default: '',
|
|
|
|
},
|
2018-12-21 16:33:29 +00:00
|
|
|
},
|
2022-10-27 13:07:12 +00:00
|
|
|
data() {
|
2018-12-21 16:33:29 +00:00
|
|
|
return {
|
2023-01-11 17:05:42 +00:00
|
|
|
loading: false,
|
2018-12-21 16:33:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isCurrentUserFollowing() {
|
|
|
|
return this.$store.getters.isFollowingUser(this.account)
|
2022-10-27 13:07:12 +00:00
|
|
|
},
|
2018-12-21 16:33:29 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-01-11 17:05:42 +00:00
|
|
|
async follow() {
|
|
|
|
try {
|
|
|
|
this.loading = true
|
|
|
|
await this.$store.dispatch('followAccount', { currentAccount: this.cloudId, accountToFollow: this.account })
|
|
|
|
} catch {
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
2018-12-21 16:33:29 +00:00
|
|
|
},
|
2023-01-11 17:05:42 +00:00
|
|
|
async unfollow() {
|
|
|
|
try {
|
|
|
|
this.loading = true
|
|
|
|
await this.$store.dispatch('unfollowAccount', { currentAccount: this.cloudId, accountToUnfollow: this.account })
|
|
|
|
} catch {
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
2022-10-27 13:07:12 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-21 16:33:29 +00:00
|
|
|
}
|
|
|
|
</script>
|
2023-01-11 17:05:42 +00:00
|
|
|
<style scoped lang="scss">
|
|
|
|
.follow-button {
|
|
|
|
width: 150px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.follow-button-container {
|
|
|
|
.follow-button--following {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
.follow-button--unfollow {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.follow-button--following {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.follow-button--unfollow {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 16:33:29 +00:00
|
|
|
.user-entry {
|
|
|
|
padding: 20px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-avatar {
|
|
|
|
margin: 5px;
|
|
|
|
margin-right: 10px;
|
|
|
|
border-radius: 50%;
|
|
|
|
flex-shrink: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.post-author {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.entry-content {
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-details {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-description {
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
|
|
|
min-width: 110px;
|
|
|
|
}
|
|
|
|
|
|
|
|
button * {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
</style>
|