Add profile menu items for hiding/showing reposts
This commit is contained in:
parent
b98e2db452
commit
838f76b17d
2 changed files with 27 additions and 3 deletions
|
@ -9,15 +9,18 @@ export interface Relationship {
|
||||||
requested: boolean,
|
requested: boolean,
|
||||||
subscription_to: boolean,
|
subscription_to: boolean,
|
||||||
subscription_from: boolean,
|
subscription_from: boolean,
|
||||||
|
showing_reblogs: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function follow(
|
export async function follow(
|
||||||
authToken: string,
|
authToken: string,
|
||||||
profileId: string,
|
profileId: string,
|
||||||
|
showReposts: 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 },
|
||||||
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()"
|
v-if="!isLocalUser() || canConnectWallet() || canConfigureSubscription() || canSubscribe() || canHideReposts() || canShowReposts()"
|
||||||
class="dropdown-menu-wrapper"
|
class="dropdown-menu-wrapper"
|
||||||
v-click-away="hideProfileMenu"
|
v-click-away="hideProfileMenu"
|
||||||
>
|
>
|
||||||
|
@ -58,6 +58,12 @@
|
||||||
Pay for subscription
|
Pay for subscription
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="canHideReposts()">
|
||||||
|
<a @click="follow(false)">Hide reposts</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="canShowReposts()">
|
||||||
|
<a @click="follow(true)">Show reposts</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -266,13 +272,28 @@ export default class ProfileView extends Vue {
|
||||||
return this.relationship.requested
|
return this.relationship.requested
|
||||||
}
|
}
|
||||||
|
|
||||||
async follow() {
|
canHideReposts(): boolean {
|
||||||
if (!this.store.currentUser || !this.profile) {
|
if (!this.relationship) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return (this.relationship.following || this.relationship.requested) && this.relationship.showing_reblogs
|
||||||
|
}
|
||||||
|
|
||||||
|
canShowReposts(): boolean {
|
||||||
|
if (!this.relationship) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return (this.relationship.following || this.relationship.requested) && !this.relationship.showing_reblogs
|
||||||
|
}
|
||||||
|
|
||||||
|
async follow(showReposts?: boolean) {
|
||||||
|
if (!this.store.currentUser || !this.profile || !this.relationship) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.relationship = await follow(
|
this.relationship = await follow(
|
||||||
this.store.ensureAuthToken(),
|
this.store.ensureAuthToken(),
|
||||||
this.profile.id,
|
this.profile.id,
|
||||||
|
showReposts ?? this.relationship.showing_reblogs,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue