Add profile menu items for hiding/showing replies
This commit is contained in:
parent
606c9412ce
commit
37819231d6
2 changed files with 31 additions and 5 deletions
|
@ -10,17 +10,22 @@ export interface Relationship {
|
||||||
subscription_to: boolean,
|
subscription_to: boolean,
|
||||||
subscription_from: boolean,
|
subscription_from: boolean,
|
||||||
showing_reblogs: boolean,
|
showing_reblogs: boolean,
|
||||||
|
showing_replies: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function follow(
|
export async function follow(
|
||||||
authToken: string,
|
authToken: string,
|
||||||
profileId: string,
|
profileId: string,
|
||||||
showReposts: boolean,
|
showReposts: boolean,
|
||||||
|
showReplies: boolean,
|
||||||
): Promise<Relationship> {
|
): Promise<Relationship> {
|
||||||
const url = `${BACKEND_URL}/api/v1/accounts/${profileId}/follow`
|
const url = `${BACKEND_URL}/api/v1/accounts/${profileId}/follow`
|
||||||
const response = await http(url, {
|
const response = await http(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
json: { reblogs: showReposts },
|
json: {
|
||||||
|
reblogs: showReposts,
|
||||||
|
replies: showReplies,
|
||||||
|
},
|
||||||
authToken,
|
authToken,
|
||||||
})
|
})
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="!isLocalUser() || canConnectWallet() || canConfigureSubscription() || canSubscribe() || canHideReposts() || canShowReposts()"
|
v-if="!isLocalUser() || canConnectWallet() || canConfigureSubscription() || canSubscribe() || canHideReposts() || canShowReposts() || canHideReplies() || canShowReplies()"
|
||||||
class="dropdown-menu-wrapper"
|
class="dropdown-menu-wrapper"
|
||||||
v-click-away="hideProfileMenu"
|
v-click-away="hideProfileMenu"
|
||||||
>
|
>
|
||||||
|
@ -59,10 +59,16 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="canHideReposts()">
|
<li v-if="canHideReposts()">
|
||||||
<a @click="follow(false)">Hide reposts</a>
|
<a @click="follow(false, undefined)">Hide reposts</a>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="canShowReposts()">
|
<li v-if="canShowReposts()">
|
||||||
<a @click="follow(true)">Show reposts</a>
|
<a @click="follow(true, undefined)">Show reposts</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="canHideReplies()">
|
||||||
|
<a @click="follow(undefined, false)">Hide replies</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="canShowReplies()">
|
||||||
|
<a @click="follow(undefined, true)">Show replies</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -286,7 +292,21 @@ export default class ProfileView extends Vue {
|
||||||
return (this.relationship.following || this.relationship.requested) && !this.relationship.showing_reblogs
|
return (this.relationship.following || this.relationship.requested) && !this.relationship.showing_reblogs
|
||||||
}
|
}
|
||||||
|
|
||||||
async follow(showReposts?: boolean) {
|
canHideReplies(): boolean {
|
||||||
|
if (!this.relationship) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return (this.relationship.following || this.relationship.requested) && this.relationship.showing_replies
|
||||||
|
}
|
||||||
|
|
||||||
|
canShowReplies(): boolean {
|
||||||
|
if (!this.relationship) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return (this.relationship.following || this.relationship.requested) && !this.relationship.showing_replies
|
||||||
|
}
|
||||||
|
|
||||||
|
async follow(showReposts?: boolean, showReplies?: boolean) {
|
||||||
if (!this.store.currentUser || !this.profile || !this.relationship) {
|
if (!this.store.currentUser || !this.profile || !this.relationship) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -294,6 +314,7 @@ export default class ProfileView extends Vue {
|
||||||
this.store.ensureAuthToken(),
|
this.store.ensureAuthToken(),
|
||||||
this.profile.id,
|
this.profile.id,
|
||||||
showReposts ?? this.relationship.showing_reblogs,
|
showReposts ?? this.relationship.showing_reblogs,
|
||||||
|
showReplies ?? this.relationship.showing_replies,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue