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:
Paul Frazee 2023-04-28 20:03:13 -05:00 committed by GitHub
parent e68aa75429
commit a95c03e280
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 974 additions and 291 deletions

View file

@ -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
// =