Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork

add toggle for all External Media players

xan.lol 5314360d e48f8a77

verified
Changed files
+27 -9
src
screens
+27 -9
src/screens/Settings/ExternalMediaPreferences.tsx
··· 1 - import {Fragment} from 'react' 2 import {View} from 'react-native' 3 import {Trans} from '@lingui/macro' 4 ··· 8 } from '#/lib/routes/types' 9 import { 10 type EmbedPlayerSource, 11 externalEmbedLabels, 12 } from '#/lib/strings/embed-player' 13 import { ··· 53 </SettingsList.ItemText> 54 <View style={[a.mt_sm, a.w_full]}> 55 {native(<SettingsList.Divider style={[a.my_0]} />)} 56 {Object.entries(externalEmbedLabels) 57 // TODO: Remove special case when we disable the old integration. 58 .filter(([key]) => key !== 'tenor') ··· 78 source, 79 label, 80 }: { 81 - source: EmbedPlayerSource 82 label: string 83 }) { 84 const setExternalEmbedPref = useSetExternalEmbedPref() 85 const sources = useExternalEmbedsPrefs() 86 87 return ( 88 <Toggle.Item 89 name={label} 90 label={label} 91 type="checkbox" 92 - value={sources?.[source] === 'show'} 93 - onChange={() => 94 - setExternalEmbedPref( 95 - source, 96 - sources?.[source] === 'show' ? 'hide' : 'show', 97 - ) 98 - } 99 style={[ 100 a.flex_1, 101 a.py_md,
··· 1 + import {Fragment, useCallback} from 'react' 2 import {View} from 'react-native' 3 import {Trans} from '@lingui/macro' 4 ··· 8 } from '#/lib/routes/types' 9 import { 10 type EmbedPlayerSource, 11 + embedPlayerSources, 12 externalEmbedLabels, 13 } from '#/lib/strings/embed-player' 14 import { ··· 54 </SettingsList.ItemText> 55 <View style={[a.mt_sm, a.w_full]}> 56 {native(<SettingsList.Divider style={[a.my_0]} />)} 57 + <PrefSelector source="all" label="All" /> 58 + <SettingsList.Divider /> 59 {Object.entries(externalEmbedLabels) 60 // TODO: Remove special case when we disable the old integration. 61 .filter(([key]) => key !== 'tenor') ··· 81 source, 82 label, 83 }: { 84 + source: EmbedPlayerSource | 'all' 85 label: string 86 }) { 87 const setExternalEmbedPref = useSetExternalEmbedPref() 88 const sources = useExternalEmbedsPrefs() 89 90 + const isChecked = 91 + source === 'all' 92 + ? embedPlayerSources 93 + .filter(key => key !== 'tenor') 94 + .every(key => sources?.[key] === 'show') 95 + : sources?.[source] === 'show' 96 + 97 + const handleChange = useCallback(() => { 98 + if (source === 'all') { 99 + const newValue = isChecked ? 'hide' : 'show' 100 + for (const key of embedPlayerSources) { 101 + if (key !== 'tenor') { 102 + setExternalEmbedPref(key, newValue) 103 + } 104 + } 105 + } else { 106 + setExternalEmbedPref(source, isChecked ? 'hide' : 'show') 107 + } 108 + }, [source, isChecked, setExternalEmbedPref]) 109 + 110 return ( 111 <Toggle.Item 112 name={label} 113 label={label} 114 type="checkbox" 115 + value={isChecked} 116 + onChange={handleChange} 117 style={[ 118 a.flex_1, 119 a.py_md,