Implement thread locking (#4545)
* Add the ability to edit threadgates * Fix bottom border on mobile * Refresh thread after threadgate edit
This commit is contained in:
parent
4165a02b2d
commit
d6ce16d15a
8 changed files with 222 additions and 111 deletions
|
@ -70,7 +70,8 @@ export interface SelfLabelModal {
|
|||
export interface ThreadgateModal {
|
||||
name: 'threadgate'
|
||||
settings: ThreadgateSetting[]
|
||||
onChange: (settings: ThreadgateSetting[]) => void
|
||||
onChange?: (settings: ThreadgateSetting[]) => void
|
||||
onConfirm?: (settings: ThreadgateSetting[]) => void
|
||||
}
|
||||
|
||||
export interface ChangeHandleModal {
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
} from './util'
|
||||
|
||||
const REPLY_TREE_DEPTH = 10
|
||||
const RQKEY_ROOT = 'post-thread'
|
||||
export const RQKEY_ROOT = 'post-thread'
|
||||
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
||||
type ThreadViewNode = AppBskyFeedGetPostThread.OutputSchema['thread']
|
||||
|
||||
|
|
|
@ -1,5 +1,38 @@
|
|||
import {AppBskyFeedDefs, AppBskyFeedThreadgate} from '@atproto/api'
|
||||
|
||||
export type ThreadgateSetting =
|
||||
| {type: 'nobody'}
|
||||
| {type: 'mention'}
|
||||
| {type: 'following'}
|
||||
| {type: 'list'; list: string}
|
||||
|
||||
export function threadgateViewToSettings(
|
||||
threadgate: AppBskyFeedDefs.ThreadgateView | undefined,
|
||||
): ThreadgateSetting[] {
|
||||
const record =
|
||||
threadgate &&
|
||||
AppBskyFeedThreadgate.isRecord(threadgate.record) &&
|
||||
AppBskyFeedThreadgate.validateRecord(threadgate.record).success
|
||||
? threadgate.record
|
||||
: null
|
||||
if (!record) {
|
||||
return []
|
||||
}
|
||||
if (!record.allow?.length) {
|
||||
return [{type: 'nobody'}]
|
||||
}
|
||||
return record.allow
|
||||
.map(allow => {
|
||||
if (allow.$type === 'app.bsky.feed.threadgate#mentionRule') {
|
||||
return {type: 'mention'}
|
||||
}
|
||||
if (allow.$type === 'app.bsky.feed.threadgate#followingRule') {
|
||||
return {type: 'following'}
|
||||
}
|
||||
if (allow.$type === 'app.bsky.feed.threadgate#listRule') {
|
||||
return {type: 'list', list: allow.list}
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
.filter(Boolean) as ThreadgateSetting[]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue