#482 - add subscribe button

This commit is contained in:
jared 2019-04-16 10:13:26 -04:00 committed by taehoon
parent f2c95f9d0b
commit d5e8315e83
5 changed files with 174 additions and 248 deletions

View file

@ -0,0 +1,26 @@
export default {
props: [ 'user' ],
data () {
return {
inProgress: false
}
},
methods: {
subscribe () {
this.inProgress = true
this.$store.state.api.backendInteractor.subscribeUser(this.user.id)
.then((updated) => {
console.log(updated)
this.inProgress = false
})
},
unsubscribe () {
this.inProgress = true
this.$store.state.api.backendInteractor.unsubscribeUser(this.user.id)
.then((updated) => {
console.log(updated)
this.inProgress = false
})
}
}
}

View file

@ -0,0 +1,22 @@
<template>
<div>
<button
@click.prevent="subscribe"
class="btn btn-default follow-card-follow-button"
:disabled="inProgress"
v-if="!user.subscribing"
>
Subscribe
</button>
<button
@click.prevent="unsubscribe"
class="btn btn-default follow-card-follow-button pressed"
:disabled="inProgress"
v-else
>
Subscribing!
</button>
</div>
</template>
<script src="./subscribe_button.js"></script>

View file

@ -1,5 +1,6 @@
import UserAvatar from '../user_avatar/user_avatar.vue' import UserAvatar from '../user_avatar/user_avatar.vue'
import RemoteFollow from '../remote_follow/remote_follow.vue' import RemoteFollow from '../remote_follow/remote_follow.vue'
import SubscribeButton from '../subscribe_button/subscribe_button.vue'
import ModerationTools from '../moderation_tools/moderation_tools.vue' import ModerationTools from '../moderation_tools/moderation_tools.vue'
import { hex2rgb } from '../../services/color_convert/color_convert.js' import { hex2rgb } from '../../services/color_convert/color_convert.js'
import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'
@ -104,7 +105,8 @@ export default {
components: { components: {
UserAvatar, UserAvatar,
RemoteFollow, RemoteFollow,
ModerationTools ModerationTools,
SubscribeButton
}, },
methods: { methods: {
followUser () { followUser () {

View file

@ -1,260 +1,135 @@
<template> <template>
<div <div class="user-card" :class="classes" :style="style">
class="user-card" <div class="panel-heading">
:class="classes" <div class='user-info'>
:style="style" <div class='container'>
> <router-link :to="userProfileLink(user)">
<div class="panel-heading"> <UserAvatar :betterShadow="betterShadow" :user="user"/>
<div class="user-info"> </router-link>
<div class="container"> <div class="user-summary">
<router-link :to="userProfileLink(user)"> <div class="top-line">
<UserAvatar <div :title="user.name" class='user-name' v-if="user.name_html" v-html="user.name_html"></div>
:better-shadow="betterShadow" <div :title="user.name" class='user-name' v-else>{{user.name}}</div>
:user="user" <router-link :to="{ name: 'user-settings' }" v-if="!isOtherUser">
/> <i class="button-icon icon-wrench usersettings" :title="$t('tool_tip.user_settings')"></i>
</router-link> </router-link>
<div class="user-summary"> <a :href="user.statusnet_profile_url" target="_blank" v-if="isOtherUser && !user.is_local">
<div class="top-line"> <i class="icon-link-ext usersettings"></i>
<!-- eslint-disable vue/no-v-html --> </a>
<div </div>
v-if="user.name_html"
:title="user.name"
class="user-name"
v-html="user.name_html"
/>
<!-- eslint-enable vue/no-v-html -->
<div
v-else
:title="user.name"
class="user-name"
>
{{ user.name }}
</div>
<router-link
v-if="!isOtherUser"
:to="{ name: 'user-settings' }"
>
<i
class="button-icon icon-wrench usersettings"
:title="$t('tool_tip.user_settings')"
/>
</router-link>
<a
v-if="isOtherUser && !user.is_local"
:href="user.statusnet_profile_url"
target="_blank"
>
<i class="icon-link-ext usersettings" />
</a>
</div>
<div class="bottom-line"> <div class="bottom-line">
<router-link <router-link class="user-screen-name" :to="userProfileLink(user)">@{{user.screen_name}}</router-link>
class="user-screen-name" <span class="alert staff" v-if="!hideBio && !!visibleRole">{{visibleRole}}</span>
:to="userProfileLink(user)" <span v-if="user.locked"><i class="icon icon-lock"></i></span>
> <span v-if="!hideUserStatsLocal && !hideBio" class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span>
@{{ user.screen_name }}
</router-link>
<span
v-if="!hideBio && !!visibleRole"
class="alert staff"
>{{ visibleRole }}</span>
<span v-if="user.locked"><i class="icon icon-lock" /></span>
<span
v-if="!hideUserStatsLocal && !hideBio"
class="dailyAvg"
>{{ dailyAvg }} {{ $t('user_card.per_day') }}</span>
</div>
</div> </div>
</div> </div>
<div class="user-meta">
<div
v-if="user.follows_you && loggedIn && isOtherUser"
class="following"
>
{{ $t('user_card.follows_you') }}
</div>
<div
v-if="isOtherUser && (loggedIn || !switcher)"
class="highlighter"
>
<!-- id's need to be unique, otherwise vue confuses which user-card checkbox belongs to -->
<input
v-if="userHighlightType !== 'disabled'"
:id="'userHighlightColorTx'+user.id"
v-model="userHighlightColor"
class="userHighlightText"
type="text"
>
<input
v-if="userHighlightType !== 'disabled'"
:id="'userHighlightColor'+user.id"
v-model="userHighlightColor"
class="userHighlightCl"
type="color"
>
<label
for="style-switcher"
class="userHighlightSel select"
>
<select
:id="'userHighlightSel'+user.id"
v-model="userHighlightType"
class="userHighlightSel"
>
<option value="disabled">No highlight</option>
<option value="solid">Solid bg</option>
<option value="striped">Striped bg</option>
<option value="side">Side stripe</option>
</select>
<i class="icon-down-open" />
</label>
</div>
</div>
<div
v-if="isOtherUser"
class="user-interactions"
>
<div
v-if="loggedIn"
class="follow"
>
<span v-if="user.following">
<!--Following them!-->
<button
class="pressed"
:disabled="followRequestInProgress"
:title="$t('user_card.follow_unfollow')"
@click="unfollowUser"
>
<template v-if="followRequestInProgress">
{{ $t('user_card.follow_progress') }}
</template>
<template v-else>
{{ $t('user_card.following') }}
</template>
</button>
</span>
<span v-if="!user.following">
<button
:disabled="followRequestInProgress"
:title="followRequestSent ? $t('user_card.follow_again') : ''"
@click="followUser"
>
<template v-if="followRequestInProgress">
{{ $t('user_card.follow_progress') }}
</template>
<template v-else-if="followRequestSent">
{{ $t('user_card.follow_sent') }}
</template>
<template v-else>
{{ $t('user_card.follow') }}
</template>
</button>
</span>
</div>
<div
v-if="isOtherUser && loggedIn"
class="mute"
>
<span v-if="user.muted">
<button
class="pressed"
@click="unmuteUser"
>
{{ $t('user_card.muted') }}
</button>
</span>
<span v-if="!user.muted">
<button @click="muteUser">
{{ $t('user_card.mute') }}
</button>
</span>
</div>
<div v-if="!loggedIn && user.is_local">
<RemoteFollow :user="user" />
</div>
<div
v-if="isOtherUser && loggedIn"
class="block"
>
<span v-if="user.statusnet_blocking">
<button
class="pressed"
@click="unblockUser"
>
{{ $t('user_card.blocked') }}
</button>
</span>
<span v-if="!user.statusnet_blocking">
<button @click="blockUser">
{{ $t('user_card.block') }}
</button>
</span>
</div>
<div
v-if="isOtherUser && loggedIn"
class="block"
>
<span>
<button @click="reportUser">
{{ $t('user_card.report') }}
</button>
</span>
</div>
<ModerationTools
v-if="loggedIn.role === &quot;admin&quot;"
:user="user"
/>
</div>
</div> </div>
</div> <div class="user-meta">
<div <div v-if="user.follows_you && loggedIn && isOtherUser" class="following">
v-if="!hideBio" {{ $t('user_card.follows_you') }}
class="panel-body"
>
<div
v-if="!hideUserStatsLocal && switcher"
class="user-counts"
>
<div
class="user-count"
@click.prevent="setProfileView('statuses')"
>
<h5>{{ $t('user_card.statuses') }}</h5>
<span>{{ user.statuses_count }} <br></span>
</div> </div>
<div <div class="highlighter" v-if="isOtherUser && (loggedIn || !switcher)">
class="user-count" <!-- id's need to be unique, otherwise vue confuses which user-card checkbox belongs to -->
@click.prevent="setProfileView('friends')" <input class="userHighlightText" type="text" :id="'userHighlightColorTx'+user.id" v-if="userHighlightType !== 'disabled'" v-model="userHighlightColor"/>
> <input class="userHighlightCl" type="color" :id="'userHighlightColor'+user.id" v-if="userHighlightType !== 'disabled'" v-model="userHighlightColor"/>
<h5>{{ $t('user_card.followees') }}</h5> <label for="style-switcher" class='userHighlightSel select'>
<span>{{ user.friends_count }}</span> <select class="userHighlightSel" :id="'userHighlightSel'+user.id" v-model="userHighlightType">
</div> <option value="disabled">No highlight</option>
<div <option value="solid">Solid bg</option>
class="user-count" <option value="striped">Striped bg</option>
@click.prevent="setProfileView('followers')" <option value="side">Side stripe</option>
> </select>
<h5>{{ $t('user_card.followers') }}</h5> <i class="icon-down-open"/>
<span>{{ user.followers_count }}</span> </label>
</div> </div>
</div> </div>
<!-- eslint-disable vue/no-v-html --> <div v-if="isOtherUser" class="user-interactions">
<p <div class="follow" v-if="loggedIn">
v-if="!hideBio && user.description_html" <span v-if="user.following">
class="user-card-bio" <!--Following them!-->
@click.prevent="linkClicked" <button @click="unfollowUser" class="pressed" :disabled="followRequestInProgress" :title="$t('user_card.follow_unfollow')">
v-html="user.description_html" <template v-if="followRequestInProgress">
/> {{ $t('user_card.follow_progress') }}
<!-- eslint-enable vue/no-v-html --> </template>
<p <template v-else>
v-else-if="!hideBio" {{ $t('user_card.following') }}
class="user-card-bio" </template>
> </button>
{{ user.description }} </span>
</p> <span v-if="!user.following">
<button @click="followUser" :disabled="followRequestInProgress" :title="followRequestSent ? $t('user_card.follow_again') : ''">
<template v-if="followRequestInProgress">
{{ $t('user_card.follow_progress') }}
</template>
<template v-else-if="followRequestSent">
{{ $t('user_card.follow_sent') }}
</template>
<template v-else>
{{ $t('user_card.follow') }}
</template>
</button>
</span>
</div>
<SubscribeButton :user="user" />
<div class='mute' v-if='isOtherUser && loggedIn'>
<span v-if='user.muted'>
<button @click="unmuteUser" class="pressed">
{{ $t('user_card.muted') }}
</button>
</span>
<span v-if='!user.muted'>
<button @click="muteUser">
{{ $t('user_card.mute') }}
</button>
</span>
</div>
<div v-if='!loggedIn && user.is_local'>
<RemoteFollow :user="user" />
</div>
<div class='block' v-if='isOtherUser && loggedIn'>
<span v-if='user.statusnet_blocking'>
<button @click="unblockUser" class="pressed">
{{ $t('user_card.blocked') }}
</button>
</span>
<span v-if='!user.statusnet_blocking'>
<button @click="blockUser">
{{ $t('user_card.block') }}
</button>
</span>
</div>
<div class='block' v-if='isOtherUser && loggedIn'>
<span>
<button @click="reportUser">
{{ $t('user_card.report') }}
</button>
</span>
</div>
<ModerationTools :user='user' v-if='loggedIn.role === "admin"'/>
</div>
</div> </div>
</div> </div>
<div class="panel-body" v-if="!hideBio">
<div v-if="!hideUserStatsLocal && switcher" class="user-counts">
<div class="user-count" v-on:click.prevent="setProfileView('statuses')">
<h5>{{ $t('user_card.statuses') }}</h5>
<span>{{user.statuses_count}} <br></span>
</div>
<div class="user-count" v-on:click.prevent="setProfileView('friends')">
<h5>{{ $t('user_card.followees') }}</h5>
<span>{{user.friends_count}}</span>
</div>
<div class="user-count" v-on:click.prevent="setProfileView('followers')">
<h5>{{ $t('user_card.followers') }}</h5>
<span>{{user.followers_count}}</span>
</div>
</div>
<p @click.prevent="linkClicked" v-if="!hideBio && user.description_html" class="user-card-bio" v-html="user.description_html"></p>
<p v-else-if="!hideBio" class="user-card-bio">{{ user.description }}</p>
</div>
</div>
</template> </template>
<script src="./user_card.js"></script> <script src="./user_card.js"></script>

View file

@ -135,6 +135,7 @@ export const mutations = {
user.following = relationship.following user.following = relationship.following
user.muted = relationship.muting user.muted = relationship.muting
user.statusnet_blocking = relationship.blocking user.statusnet_blocking = relationship.blocking
user.subscribing = relationship.subscribing
} }
}) })
}, },