From 707bb3a2c47837ea32c50a210de3f6a3ed0a4f8e Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 5 Feb 2025 11:22:20 -0600 Subject: [PATCH] Use asPredicate --- src/screens/Settings/components/PwiOptOut.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/screens/Settings/components/PwiOptOut.tsx b/src/screens/Settings/components/PwiOptOut.tsx index 23a466e3e9..e0581da7fa 100644 --- a/src/screens/Settings/components/PwiOptOut.tsx +++ b/src/screens/Settings/components/PwiOptOut.tsx @@ -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.isValidSelfLabels(existing.labels) - ? existing.labels - : { - $type: 'com.atproto.label.defs#selfLabels', - values: [], - } + const labels: $Typed = asPredicate( + ComAtprotoLabelDefs.validateSelfLabels, + )(existing.labels) + ? existing.labels + : { + $type: 'com.atproto.label.defs#selfLabels', + values: [], + } // toggle the label const hasLabel = labels.values.some(