Implement blocks (#554)
* Quick fix to prompt * Add blocked accounts screen * Add blocking tools to profile * Blur avis/banners of blocked users * Factor blocking state into moderation dsl * Filter post slices from the feed if any are hidden * Handle various block UIs * Filter in the client on blockedBy * Implement block list * Fix some copy * Bump deps * Fix lint
This commit is contained in:
parent
e68aa75429
commit
a95c03e280
24 changed files with 974 additions and 291 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {makeAutoObservable, runInAction} from 'mobx'
|
||||
import {
|
||||
AtUri,
|
||||
ComAtprotoLabelDefs,
|
||||
AppBskyActorGetProfile as GetProfile,
|
||||
AppBskyActorProfile,
|
||||
|
|
@ -23,6 +24,8 @@ export class ProfileViewerModel {
|
|||
muted?: boolean
|
||||
following?: string
|
||||
followedBy?: string
|
||||
blockedBy?: boolean
|
||||
blocking?: string
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
|
|
@ -86,6 +89,8 @@ export class ProfileModel {
|
|||
accountLabels: filterAccountLabels(this.labels),
|
||||
profileLabels: filterProfileLabels(this.labels),
|
||||
isMuted: this.viewer?.muted || false,
|
||||
isBlocking: !!this.viewer?.blocking || false,
|
||||
isBlockedBy: !!this.viewer?.blockedBy || false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +190,33 @@ export class ProfileModel {
|
|||
await this.refresh()
|
||||
}
|
||||
|
||||
async blockAccount() {
|
||||
const res = await this.rootStore.agent.app.bsky.graph.block.create(
|
||||
{
|
||||
repo: this.rootStore.me.did,
|
||||
},
|
||||
{
|
||||
subject: this.did,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
)
|
||||
this.viewer.blocking = res.uri
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
async unblockAccount() {
|
||||
if (!this.viewer.blocking) {
|
||||
return
|
||||
}
|
||||
const {rkey} = new AtUri(this.viewer.blocking)
|
||||
await this.rootStore.agent.app.bsky.graph.block.delete({
|
||||
repo: this.rootStore.me.did,
|
||||
rkey,
|
||||
})
|
||||
this.viewer.blocking = undefined
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
// state transitions
|
||||
// =
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue