diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-07-23 16:57:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 16:57:51 -0700 |
commit | 4af6bcb11ad78f993318f4b5f7b5029af4951866 (patch) | |
tree | 749b913d5d7c8a904ad778252c8c4f8886acb214 /src/view/com/util/UserAvatar.tsx | |
parent | 67ce18a113c8598521b60cede4e0e2fc05dd5da7 (diff) | |
download | voidsky-4af6bcb11ad78f993318f4b5f7b5029af4951866.tar.zst |
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 rendering
Diffstat (limited to 'src/view/com/util/UserAvatar.tsx')
-rw-r--r-- | src/view/com/util/UserAvatar.tsx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index e9aa62580..b72723409 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -8,6 +8,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' +import {useGate} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {usePalette} from 'lib/hooks/usePalette' import { @@ -179,6 +180,7 @@ let UserAvatar = ({ const pal = usePalette('default') const backgroundColor = pal.colors.backgroundLight const finalShape = overrideShape ?? (type === 'user' ? 'circle' : 'square') + const gate = useGate() const aviStyle = useMemo(() => { if (finalShape === 'square') { @@ -221,7 +223,12 @@ let UserAvatar = ({ testID="userAvatarImage" style={aviStyle} resizeMode="cover" - source={{uri: avatar}} + source={{ + uri: hackModifyThumbnailPath( + avatar, + size < 90 && gate('small_avi_thumb'), + ), + }} blurRadius={moderation?.blur ? BLUR_AMOUNT : 0} /> ) : ( @@ -229,7 +236,12 @@ let UserAvatar = ({ testID="userAvatarImage" style={aviStyle} contentFit="cover" - source={{uri: avatar}} + source={{ + uri: hackModifyThumbnailPath( + avatar, + size < 90 && gate('small_avi_thumb'), + ), + }} blurRadius={moderation?.blur ? BLUR_AMOUNT : 0} /> )} @@ -433,6 +445,16 @@ let PreviewableUserAvatar = ({ PreviewableUserAvatar = memo(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({ editButtonContainer: { position: 'absolute', |