Hack-modify avi path to use smaller thumbs behind gate (#4816)
* Hack-modify avi path to use smaller thumbs behind gate * Only use small thumbs on smaller renderingzio/stable
parent
67ce18a113
commit
4af6bcb11a
|
@ -14,3 +14,4 @@ export type Gate =
|
||||||
| 'suggested_follows_interstitial'
|
| 'suggested_follows_interstitial'
|
||||||
| 'ungroup_follow_backs'
|
| 'ungroup_follow_backs'
|
||||||
| 'videos'
|
| 'videos'
|
||||||
|
| 'small_avi_thumb'
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {
|
import {
|
||||||
|
@ -179,6 +180,7 @@ let UserAvatar = ({
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const backgroundColor = pal.colors.backgroundLight
|
const backgroundColor = pal.colors.backgroundLight
|
||||||
const finalShape = overrideShape ?? (type === 'user' ? 'circle' : 'square')
|
const finalShape = overrideShape ?? (type === 'user' ? 'circle' : 'square')
|
||||||
|
const gate = useGate()
|
||||||
|
|
||||||
const aviStyle = useMemo(() => {
|
const aviStyle = useMemo(() => {
|
||||||
if (finalShape === 'square') {
|
if (finalShape === 'square') {
|
||||||
|
@ -221,7 +223,12 @@ let UserAvatar = ({
|
||||||
testID="userAvatarImage"
|
testID="userAvatarImage"
|
||||||
style={aviStyle}
|
style={aviStyle}
|
||||||
resizeMode="cover"
|
resizeMode="cover"
|
||||||
source={{uri: avatar}}
|
source={{
|
||||||
|
uri: hackModifyThumbnailPath(
|
||||||
|
avatar,
|
||||||
|
size < 90 && gate('small_avi_thumb'),
|
||||||
|
),
|
||||||
|
}}
|
||||||
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
|
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
@ -229,7 +236,12 @@ let UserAvatar = ({
|
||||||
testID="userAvatarImage"
|
testID="userAvatarImage"
|
||||||
style={aviStyle}
|
style={aviStyle}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
source={{uri: avatar}}
|
source={{
|
||||||
|
uri: hackModifyThumbnailPath(
|
||||||
|
avatar,
|
||||||
|
size < 90 && gate('small_avi_thumb'),
|
||||||
|
),
|
||||||
|
}}
|
||||||
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
|
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -433,6 +445,16 @@ let PreviewableUserAvatar = ({
|
||||||
PreviewableUserAvatar = memo(PreviewableUserAvatar)
|
PreviewableUserAvatar = memo(PreviewableUserAvatar)
|
||||||
export {PreviewableUserAvatar}
|
export {PreviewableUserAvatar}
|
||||||
|
|
||||||
|
// HACK
|
||||||
|
// We have started serving smaller avis but haven't updated lexicons to give the data properly
|
||||||
|
// manually string-replace to use the smaller ones
|
||||||
|
// -prf
|
||||||
|
function hackModifyThumbnailPath(uri: string, isEnabled: boolean): string {
|
||||||
|
return isEnabled
|
||||||
|
? uri.replace('/img/avatar/plain/', '/img/avatar_thumbnail/plain/')
|
||||||
|
: uri
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
editButtonContainer: {
|
editButtonContainer: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|
Loading…
Reference in New Issue