Update to use new SDK appLabelers semantics
This commit is contained in:
@@ -54,16 +54,16 @@ export function lookupLabelValueDefinition(
|
|||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isModAuthority(
|
export function isAppLabeler(
|
||||||
labeler:
|
labeler:
|
||||||
| string
|
| string
|
||||||
| AppBskyLabelerDefs.LabelerView
|
| AppBskyLabelerDefs.LabelerView
|
||||||
| AppBskyLabelerDefs.LabelerViewDetailed,
|
| AppBskyLabelerDefs.LabelerViewDetailed,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (typeof labeler === 'string') {
|
if (typeof labeler === 'string') {
|
||||||
return BskyAgent.modAuthoritiesHeader.includes(labeler)
|
return BskyAgent.appLabelers.includes(labeler)
|
||||||
}
|
}
|
||||||
return BskyAgent.modAuthoritiesHeader.includes(labeler.creator.did)
|
return BskyAgent.appLabelers.includes(labeler.creator.did)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isLabelerSubscribed(
|
export function isLabelerSubscribed(
|
||||||
@@ -74,7 +74,7 @@ export function isLabelerSubscribed(
|
|||||||
modOpts: ModerationOpts,
|
modOpts: ModerationOpts,
|
||||||
) {
|
) {
|
||||||
labeler = typeof labeler === 'string' ? labeler : labeler.creator.did
|
labeler = typeof labeler === 'string' ? labeler : labeler.creator.did
|
||||||
if (isModAuthority(labeler)) {
|
if (isAppLabeler(labeler)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return modOpts.prefs.labelers.find(l => l.did === labeler)
|
return modOpts.prefs.labelers.find(l => l.did === labeler)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {useLikeMutation, useUnlikeMutation} from '#/state/queries/like'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {Haptics} from '#/lib/haptics'
|
import {Haptics} from '#/lib/haptics'
|
||||||
import {pluralize} from '#/lib/strings/helpers'
|
import {pluralize} from '#/lib/strings/helpers'
|
||||||
import {isModAuthority} from '#/lib/moderation'
|
import {isAppLabeler} from '#/lib/moderation'
|
||||||
|
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
@@ -174,7 +174,7 @@ let ProfileHeaderLabeler = ({
|
|||||||
<Trans>Edit Profile</Trans>
|
<Trans>Edit Profile</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
) : !isModAuthority(profile.did) ? (
|
) : !isAppLabeler(profile.did) ? (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
testID="toggleSubscribeBtn"
|
testID="toggleSubscribeBtn"
|
||||||
@@ -219,7 +219,7 @@ let ProfileHeaderLabeler = ({
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
{!isModAuthority(profile.did) && (
|
{!isAppLabeler(profile.did) && (
|
||||||
<View style={[a.flex_row, a.gap_xs, a.align_center, a.pt_lg]}>
|
<View style={[a.flex_row, a.gap_xs, a.align_center, a.pt_lg]}>
|
||||||
<Button
|
<Button
|
||||||
testID="toggleLikeBtn"
|
testID="toggleLikeBtn"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function useMyLabelers() {
|
|||||||
const prefs = usePreferencesQuery()
|
const prefs = usePreferencesQuery()
|
||||||
const dids = Array.from(
|
const dids = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
BskyAgent.modAuthoritiesHeader.concat(
|
BskyAgent.appLabelers.concat(
|
||||||
prefs.data?.moderationPrefs.labelers.map(l => l.did) || [],
|
prefs.data?.moderationPrefs.labelers.map(l => l.did) || [],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -664,9 +664,9 @@ async function configureModeration(agent: BskyAgent, account: SessionAccount) {
|
|||||||
console.warn('USING TEST ENV MODERATION')
|
console.warn('USING TEST ENV MODERATION')
|
||||||
const did = (await agent.resolveHandle({handle: 'mod-authority.test'})).data
|
const did = (await agent.resolveHandle({handle: 'mod-authority.test'})).data
|
||||||
.did
|
.did
|
||||||
BskyAgent.configure({modAuthorities: [did]})
|
BskyAgent.configure({appLabelers: [did]})
|
||||||
} else {
|
} else {
|
||||||
BskyAgent.configure({modAuthorities: [BSKY_LABELER_DID]})
|
BskyAgent.configure({appLabelers: [BSKY_LABELER_DID]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user