refs #2209 Add subscribe/unsubscribe button in account profile
This commit is contained in:
parent
1f9d6736db
commit
c696d05365
|
@ -356,8 +356,10 @@
|
||||||
"follows_you": "Follows you",
|
"follows_you": "Follows you",
|
||||||
"doesnt_follow_you": "Doesn't follow you",
|
"doesnt_follow_you": "Doesn't follow you",
|
||||||
"detail": "Detail",
|
"detail": "Detail",
|
||||||
"follow": "Follow",
|
"follow": "Follow this user",
|
||||||
"unfollow": "Unfollow",
|
"unfollow": "Unfollow this user",
|
||||||
|
"subscribe": "Subscribe this user",
|
||||||
|
"unsubscribe": "Unsubscribe this user",
|
||||||
"follow_requested": "Follow requested",
|
"follow_requested": "Follow requested",
|
||||||
"open_in_browser": "Open in Browser",
|
"open_in_browser": "Open in Browser",
|
||||||
"manage_list_memberships": "Manage List Memberships",
|
"manage_list_memberships": "Manage List Memberships",
|
||||||
|
@ -436,6 +438,8 @@
|
||||||
"toot_fetch_error": "Failed to fetch the toot detail",
|
"toot_fetch_error": "Failed to fetch the toot detail",
|
||||||
"follow_error": "Failed to follow the user",
|
"follow_error": "Failed to follow the user",
|
||||||
"unfollow_error": "Failed to unfollow the user",
|
"unfollow_error": "Failed to unfollow the user",
|
||||||
|
"subscribe_error": "Failed to subscribe the user",
|
||||||
|
"unsubscribe_error": "Failed to unsubscribe the user",
|
||||||
"lists_fetch_error": "Failed to fetch lists",
|
"lists_fetch_error": "Failed to fetch lists",
|
||||||
"list_create_error": "Failed to create a list",
|
"list_create_error": "Failed to create a list",
|
||||||
"members_fetch_error": "Failed to fetch members",
|
"members_fetch_error": "Failed to fetch members",
|
||||||
|
|
|
@ -10,12 +10,26 @@
|
||||||
>
|
>
|
||||||
<div class="header-background" v-bind:style="{ backgroundImage: 'url(' + account.header + ')' }">
|
<div class="header-background" v-bind:style="{ backgroundImage: 'url(' + account.header + ')' }">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="follow-follower" v-if="relationship !== null && relationship !== '' && !isOwnProfile">
|
<div class="relationship" v-if="relationship !== null && relationship !== '' && !isOwnProfile">
|
||||||
<div class="follower-status">
|
<div class="follower-status">
|
||||||
<el-tag class="status" size="small" v-if="relationship.followed_by">{{ $t('side_bar.account_profile.follows_you') }}</el-tag>
|
<el-tag class="status" size="small" v-if="relationship.followed_by">{{ $t('side_bar.account_profile.follows_you') }}</el-tag>
|
||||||
<el-tag class="status" size="medium" v-else>{{ $t('side_bar.account_profile.doesnt_follow_you') }}</el-tag>
|
<el-tag class="status" size="medium" v-else>{{ $t('side_bar.account_profile.doesnt_follow_you') }}</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="notify" v-if="relationship !== null && relationship !== '' && !isOwnProfile">
|
||||||
|
<div
|
||||||
|
v-if="relationship.notifying"
|
||||||
|
class="unsubscribe"
|
||||||
|
@click="unsubscribe(account)"
|
||||||
|
:title="$t('side_bar.account_profile.unsubscribe')"
|
||||||
|
>
|
||||||
|
<icon name="bell" scale="1.3"></icon>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="subscribe" @click="subscribe(account)" :title="$t('side_bar.account_profile.subscribe')">
|
||||||
|
<icon name="regular/bell" scale="1.3"></icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<div class="more" v-if="relationship !== null && relationship !== '' && !isOwnProfile">
|
<div class="more" v-if="relationship !== null && relationship !== '' && !isOwnProfile">
|
||||||
<popper trigger="click" :options="{ placement: 'bottom' }" ref="popper">
|
<popper trigger="click" :options="{ placement: 'bottom' }" ref="popper">
|
||||||
|
@ -243,6 +257,32 @@ export default {
|
||||||
},
|
},
|
||||||
identityOpen(link) {
|
identityOpen(link) {
|
||||||
return window.shell.openExternal(link)
|
return window.shell.openExternal(link)
|
||||||
|
},
|
||||||
|
subscribe(account) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||||
|
try {
|
||||||
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/subscribe', account)
|
||||||
|
} catch (err) {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.subscribe_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unsubscribe(account) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||||
|
try {
|
||||||
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unsubscribe', account)
|
||||||
|
} catch (err) {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.unsubscribe_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,8 +303,9 @@ export default {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-size: var(--base-font-size);
|
font-size: var(--base-font-size);
|
||||||
|
|
||||||
.follow-follower {
|
.relationship {
|
||||||
text-align: left;
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
.follower-status {
|
.follower-status {
|
||||||
.status {
|
.status {
|
||||||
|
@ -273,6 +314,14 @@ export default {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notify {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
.unsubscribe {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-info {
|
.user-info {
|
||||||
|
|
|
@ -208,6 +208,26 @@ const actions: ActionTree<AccountProfileState, RootState> = {
|
||||||
)
|
)
|
||||||
const res = await client.getIdentityProof(account.id)
|
const res = await client.getIdentityProof(account.id)
|
||||||
commit(MUTATION_TYPES.CHANGE_IDENTITY_PROOFS, res.data)
|
commit(MUTATION_TYPES.CHANGE_IDENTITY_PROOFS, res.data)
|
||||||
|
},
|
||||||
|
subscribe: async ({ rootState, commit }, account: Entity.Account) => {
|
||||||
|
const client = generator(
|
||||||
|
rootState.TimelineSpace.sns,
|
||||||
|
rootState.TimelineSpace.account.baseURL,
|
||||||
|
rootState.TimelineSpace.account.accessToken,
|
||||||
|
rootState.App.userAgent
|
||||||
|
)
|
||||||
|
const res = await client.subscribeAccount(account.id)
|
||||||
|
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
|
||||||
|
},
|
||||||
|
unsubscribe: async ({ rootState, commit }, account: Entity.Account) => {
|
||||||
|
const client = generator(
|
||||||
|
rootState.TimelineSpace.sns,
|
||||||
|
rootState.TimelineSpace.account.baseURL,
|
||||||
|
rootState.TimelineSpace.account.accessToken,
|
||||||
|
rootState.App.userAgent
|
||||||
|
)
|
||||||
|
const res = await client.unsubscribeAccount(account.id)
|
||||||
|
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue