Use asPredicate

This commit is contained in:
Eric Bailey
2025-02-05 11:22:20 -06:00
parent 06be7f887c
commit 707bb3a2c4
@@ -1,6 +1,6 @@
import React from 'react'
import {View} from 'react-native'
import {$Typed, ComAtprotoLabelDefs} from '@atproto/api'
import {$Typed, asPredicate,ComAtprotoLabelDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
@@ -33,13 +33,14 @@ export function PwiOptOut() {
profile,
updates: existing => {
// create labels attr if needed
const labels: $Typed<ComAtprotoLabelDefs.SelfLabels> =
ComAtprotoLabelDefs.isValidSelfLabels(existing.labels)
? existing.labels
: {
$type: 'com.atproto.label.defs#selfLabels',
values: [],
}
const labels: $Typed<ComAtprotoLabelDefs.SelfLabels> = asPredicate(
ComAtprotoLabelDefs.validateSelfLabels,
)(existing.labels)
? existing.labels
: {
$type: 'com.atproto.label.defs#selfLabels',
values: [],
}
// toggle the label
const hasLabel = labels.values.some(