tangled
alpha
login
or
join now
jollywhoppers.com
/
witchsky.app
103
fork
atom
Bluesky app fork with some witchin' additions 💫
witchsky.app
bluesky
fork
client
103
fork
atom
overview
issues
44
pulls
pipelines
add toggle for all External Media players
xan.lol
3 months ago
5314360d
e48f8a77
verified
This commit was signed with the committer's
known signature
.
xan.lol
SSH Key Fingerprint:
SHA256:7Zs+dcly5YqxBg7v8XsE1uPMYCobHKBw7CDiNxpmSrY=
0/1
deploy-web.yml
failed
4min
+27
-9
1 changed file
expand all
collapse all
unified
split
src
screens
Settings
ExternalMediaPreferences.tsx
+27
-9
src/screens/Settings/ExternalMediaPreferences.tsx
···
1
1
-
import {Fragment} from 'react'
1
1
+
import {Fragment, useCallback} from 'react'
2
2
import {View} from 'react-native'
3
3
import {Trans} from '@lingui/macro'
4
4
···
8
8
} from '#/lib/routes/types'
9
9
import {
10
10
type EmbedPlayerSource,
11
11
+
embedPlayerSources,
11
12
externalEmbedLabels,
12
13
} from '#/lib/strings/embed-player'
13
14
import {
···
53
54
</SettingsList.ItemText>
54
55
<View style={[a.mt_sm, a.w_full]}>
55
56
{native(<SettingsList.Divider style={[a.my_0]} />)}
57
57
+
<PrefSelector source="all" label="All" />
58
58
+
<SettingsList.Divider />
56
59
{Object.entries(externalEmbedLabels)
57
60
// TODO: Remove special case when we disable the old integration.
58
61
.filter(([key]) => key !== 'tenor')
···
78
81
source,
79
82
label,
80
83
}: {
81
81
-
source: EmbedPlayerSource
84
84
+
source: EmbedPlayerSource | 'all'
82
85
label: string
83
86
}) {
84
87
const setExternalEmbedPref = useSetExternalEmbedPref()
85
88
const sources = useExternalEmbedsPrefs()
86
89
90
90
+
const isChecked =
91
91
+
source === 'all'
92
92
+
? embedPlayerSources
93
93
+
.filter(key => key !== 'tenor')
94
94
+
.every(key => sources?.[key] === 'show')
95
95
+
: sources?.[source] === 'show'
96
96
+
97
97
+
const handleChange = useCallback(() => {
98
98
+
if (source === 'all') {
99
99
+
const newValue = isChecked ? 'hide' : 'show'
100
100
+
for (const key of embedPlayerSources) {
101
101
+
if (key !== 'tenor') {
102
102
+
setExternalEmbedPref(key, newValue)
103
103
+
}
104
104
+
}
105
105
+
} else {
106
106
+
setExternalEmbedPref(source, isChecked ? 'hide' : 'show')
107
107
+
}
108
108
+
}, [source, isChecked, setExternalEmbedPref])
109
109
+
87
110
return (
88
111
<Toggle.Item
89
112
name={label}
90
113
label={label}
91
114
type="checkbox"
92
92
-
value={sources?.[source] === 'show'}
93
93
-
onChange={() =>
94
94
-
setExternalEmbedPref(
95
95
-
source,
96
96
-
sources?.[source] === 'show' ? 'hide' : 'show',
97
97
-
)
98
98
-
}
115
115
+
value={isChecked}
116
116
+
onChange={handleChange}
99
117
style={[
100
118
a.flex_1,
101
119
a.py_md,