Add list un/subscribe
This commit is contained in:
+23
-1
@@ -91,6 +91,7 @@ async function main() {
|
||||
'always-warn-profile',
|
||||
'always-warn-posts',
|
||||
'muted-account',
|
||||
'muted-by-list-account',
|
||||
]) {
|
||||
await server.mocker.createUser(user)
|
||||
await server.mocker.follow('alice', user)
|
||||
@@ -258,11 +259,32 @@ async function main() {
|
||||
await server.mocker.createPost('muted-account', 'muted post')
|
||||
await server.mocker.createQuotePost(
|
||||
'muted-account',
|
||||
'account quote post',
|
||||
'muted quote post',
|
||||
anchorPost,
|
||||
)
|
||||
await server.mocker.createReply(
|
||||
'muted-account',
|
||||
'muted reply',
|
||||
anchorPost,
|
||||
)
|
||||
|
||||
const list = await server.mocker.createMuteList(
|
||||
'alice',
|
||||
'Muted Users',
|
||||
)
|
||||
await server.mocker.addToMuteList(
|
||||
'alice',
|
||||
list,
|
||||
server.mocker.users['muted-by-list-account'].did,
|
||||
)
|
||||
await server.mocker.createPost('muted-by-list-account', 'muted post')
|
||||
await server.mocker.createQuotePost(
|
||||
'muted-by-list-account',
|
||||
'account quote post',
|
||||
anchorPost,
|
||||
)
|
||||
await server.mocker.createReply(
|
||||
'muted-by-list-account',
|
||||
'account reply',
|
||||
anchorPost,
|
||||
)
|
||||
|
||||
@@ -337,6 +337,32 @@ class Mocker {
|
||||
])
|
||||
.execute()
|
||||
}
|
||||
|
||||
async createMuteList(user: string, name: string): Promise<string> {
|
||||
const res = await this.users[user]?.agent.app.bsky.graph.list.create(
|
||||
{repo: this.users[user]?.did},
|
||||
{
|
||||
purpose: 'app.bsky.graph.defs#modlist',
|
||||
name,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
)
|
||||
await this.users[user]?.agent.app.bsky.graph.subscribeMuteList({
|
||||
list: res.uri,
|
||||
})
|
||||
return res.uri
|
||||
}
|
||||
|
||||
async addToMuteList(owner: string, list: string, subject: string) {
|
||||
await this.users[owner]?.agent.app.bsky.graph.listitem.create(
|
||||
{repo: this.users[owner]?.did},
|
||||
{
|
||||
list,
|
||||
subject,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const checkAvailablePort = (port: number) =>
|
||||
|
||||
@@ -194,6 +194,20 @@ export class ListModel {
|
||||
})
|
||||
}
|
||||
|
||||
async subscribe() {
|
||||
await this.rootStore.agent.app.bsky.graph.subscribeMuteList({
|
||||
list: this.list.uri,
|
||||
})
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
async unsubscribe() {
|
||||
await this.rootStore.agent.app.bsky.graph.unsubscribeMuteList({
|
||||
list: this.list.uri,
|
||||
})
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load more again after a failure
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ export class NotificationsFeedItemModel {
|
||||
addedInfo?.profileLabels || [],
|
||||
),
|
||||
isMuted: this.author.viewer?.muted || addedInfo?.isMuted || false,
|
||||
mutedByList: this.author.viewer?.mutedByList || addedInfo.mutedByList,
|
||||
mutedByList: this.author.viewer?.mutedByList || addedInfo?.mutedByList,
|
||||
isBlocking:
|
||||
!!this.author.viewer?.blocking || addedInfo?.isBlocking || false,
|
||||
isBlockedBy:
|
||||
|
||||
@@ -43,11 +43,12 @@ export const ProfileListScreen = withAuthRequired(
|
||||
const onToggleSubscribed = React.useCallback(async () => {
|
||||
try {
|
||||
if (list.list?.viewer?.muted) {
|
||||
await store.agent.app.bsky.graph.unsubscribeMuteList({list: list.uri})
|
||||
Toast.show('List unsubscribed')
|
||||
await list.unsubscribe()
|
||||
Toast.show('Unsubscribed from the mute list')
|
||||
} else {
|
||||
await list.subscribe()
|
||||
await store.agent.app.bsky.graph.subscribeMuteList({list: list.uri})
|
||||
Toast.show('List subscribed')
|
||||
Toast.show('Subscribed to the mute list')
|
||||
}
|
||||
} catch (err) {
|
||||
Toast.show(
|
||||
|
||||
Reference in New Issue
Block a user