mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Truncate post metrics and fix truncation on native (#4575)

* truncate post counts

* add numberformat polyfill

* Fix perf

* Simplify type shenanigans

* Bump versions to remove dupes

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by samuel.fm

Dan Abramov and committed by
GitHub
22c5aa4d ca17cf27

+68 -49
+3 -2
package.json
··· 58 58 "@expo/webpack-config": "^19.0.0", 59 59 "@floating-ui/dom": "^1.6.3", 60 60 "@floating-ui/react-dom": "^2.0.8", 61 - "@formatjs/intl-locale": "^3.4.3", 62 - "@formatjs/intl-pluralrules": "^5.2.10", 61 + "@formatjs/intl-locale": "^4.0.0", 62 + "@formatjs/intl-numberformat": "^8.10.3", 63 + "@formatjs/intl-pluralrules": "^5.2.14", 63 64 "@fortawesome/fontawesome-svg-core": "^6.1.1", 64 65 "@fortawesome/free-regular-svg-icons": "^6.1.1", 65 66 "@fortawesome/free-solid-svg-icons": "^6.1.1",
+6 -2
src/locale/i18n.ts
··· 1 - import '@formatjs/intl-locale/polyfill' 2 - import '@formatjs/intl-pluralrules/polyfill-force' // Don't remove -force because detection is very slow 1 + // Don't remove -force from these because detection is VERY slow on low-end Android. 2 + // https://github.com/formatjs/formatjs/issues/4463#issuecomment-2176070577 3 + import '@formatjs/intl-locale/polyfill-force' 4 + import '@formatjs/intl-pluralrules/polyfill-force' 5 + import '@formatjs/intl-numberformat/polyfill-force' 3 6 import '@formatjs/intl-pluralrules/locale-data/en' 7 + import '@formatjs/intl-numberformat/locale-data/en' 4 8 5 9 import {useEffect} from 'react' 6 10 import {i18n} from '@lingui/core'
+3 -2
src/view/com/util/post-ctrls/PostCtrls.tsx
··· 39 39 } from '#/components/icons/Heart2' 40 40 import * as Prompt from '#/components/Prompt' 41 41 import {PostDropdownBtn} from '../forms/PostDropdownBtn' 42 + import {formatCount} from '../numeric/format' 42 43 import {Text} from '../text/Text' 43 44 import {RepostButton} from './RepostButton' 44 45 ··· 226 227 big ? a.text_md : {fontSize: 15}, 227 228 a.user_select_none, 228 229 ]}> 229 - {post.replyCount} 230 + {formatCount(post.replyCount)} 230 231 </Text> 231 232 ) : undefined} 232 233 </Pressable> ··· 278 279 : defaultCtrlColor, 279 280 ], 280 281 ]}> 281 - {post.likeCount} 282 + {formatCount(post.likeCount)} 282 283 </Text> 283 284 ) : undefined} 284 285 </Pressable>
+2 -1
src/view/com/util/post-ctrls/RepostButton.tsx
··· 12 12 import {CloseQuote_Stroke2_Corner1_Rounded as Quote} from '#/components/icons/Quote' 13 13 import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost' 14 14 import {Text} from '#/components/Typography' 15 + import {formatCount} from '../numeric/format' 15 16 16 17 interface Props { 17 18 isReposted: boolean ··· 76 77 big ? a.text_md : {fontSize: 15}, 77 78 isReposted && a.font_bold, 78 79 ]}> 79 - {repostCount} 80 + {formatCount(repostCount)} 80 81 </Text> 81 82 ) : undefined} 82 83 </Button>
+20 -17
src/view/com/util/post-ctrls/RepostButton.web.tsx
··· 12 12 import * as Menu from '#/components/Menu' 13 13 import {Text} from '#/components/Typography' 14 14 import {EventStopper} from '../EventStopper' 15 + import {formatCount} from '../numeric/format' 15 16 16 17 interface Props { 17 18 isReposted: boolean ··· 115 116 color: {color: string} 116 117 repostCount?: number 117 118 big?: boolean 118 - }) => ( 119 - <View style={[a.flex_row, a.align_center, a.gap_xs, {padding: 5}]}> 120 - <Repost style={color} width={big ? 22 : 18} /> 121 - {typeof repostCount !== 'undefined' && repostCount > 0 ? ( 122 - <Text 123 - testID="repostCount" 124 - style={[ 125 - color, 126 - big ? a.text_md : {fontSize: 15}, 127 - isReposted && [a.font_bold], 128 - a.user_select_none, 129 - ]}> 130 - {repostCount} 131 - </Text> 132 - ) : undefined} 133 - </View> 134 - ) 119 + }) => { 120 + return ( 121 + <View style={[a.flex_row, a.align_center, a.gap_xs, {padding: 5}]}> 122 + <Repost style={color} width={big ? 22 : 18} /> 123 + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( 124 + <Text 125 + testID="repostCount" 126 + style={[ 127 + color, 128 + big ? a.text_md : {fontSize: 15}, 129 + isReposted && [a.font_bold], 130 + a.user_select_none, 131 + ]}> 132 + {formatCount(repostCount)} 133 + </Text> 134 + ) : undefined} 135 + </View> 136 + ) 137 + }
+34 -25
yarn.lock
··· 3897 3897 resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.1.tgz#16308cea045f0fc777b6ff20a9f25474dd8293d2" 3898 3898 integrity sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q== 3899 3899 3900 - "@formatjs/ecma402-abstract@1.18.0": 3901 - version "1.18.0" 3902 - resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.18.0.tgz#e2120e7101020140661b58430a7ff4262705a2f2" 3903 - integrity sha512-PEVLoa3zBevWSCZzPIM/lvPCi8P5l4G+NXQMc/CjEiaCWgyHieUoo0nM7Bs0n/NbuQ6JpXEolivQ9pKSBHaDlA== 3900 + "@formatjs/ecma402-abstract@2.0.0": 3901 + version "2.0.0" 3902 + resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-2.0.0.tgz#39197ab90b1c78b7342b129a56a7acdb8f512e17" 3903 + integrity sha512-rRqXOqdFmk7RYvj4khklyqzcfQl9vEL/usogncBHRZfZBDOwMGuSRNFl02fu5KGHXdbinju+YXyuR+Nk8xlr/g== 3904 3904 dependencies: 3905 - "@formatjs/intl-localematcher" "0.5.2" 3905 + "@formatjs/intl-localematcher" "0.5.4" 3906 3906 tslib "^2.4.0" 3907 3907 3908 - "@formatjs/intl-enumerator@1.4.3": 3909 - version "1.4.3" 3910 - resolved "https://registry.yarnpkg.com/@formatjs/intl-enumerator/-/intl-enumerator-1.4.3.tgz#8d278c273485d7c6219916509fbd51ce3142064d" 3911 - integrity sha512-0NpTmAQnDokPoB5aVtXvOdtrUq/uEuPPhBUAr57TYYDjI5MwfFXt8F6JCm6s6CPI0inL8+nxPLjjqH0qyNnP4Q== 3908 + "@formatjs/intl-enumerator@1.4.7": 3909 + version "1.4.7" 3910 + resolved "https://registry.yarnpkg.com/@formatjs/intl-enumerator/-/intl-enumerator-1.4.7.tgz#6ab697f3f8f18cf0cc6a6b028cb9c40db6001f3d" 3911 + integrity sha512-03RHnFqfpB4H/jwCwlzC+wkTDk2Fi24JmVIY2PVGvTUpikN2bSr9+8oTXfOC+y7B7VxjCArUnqWXVoctkmy85w== 3912 3912 dependencies: 3913 3913 tslib "^2.4.0" 3914 3914 ··· 3919 3919 dependencies: 3920 3920 tslib "^2.4.0" 3921 3921 3922 - "@formatjs/intl-locale@^3.4.3": 3923 - version "3.4.3" 3924 - resolved "https://registry.yarnpkg.com/@formatjs/intl-locale/-/intl-locale-3.4.3.tgz#fdd2a3978b03aa76965abbca86526bb1d02973b6" 3925 - integrity sha512-g/35yMikkkRmLYmqE4W74gvZyKa768oC9OmUFzfLmH3CVYF3v2kvAZI0WsxWLbxYj8TT7wBDeLIL3aIlRw4Osw== 3922 + "@formatjs/intl-locale@^4.0.0": 3923 + version "4.0.0" 3924 + resolved "https://registry.yarnpkg.com/@formatjs/intl-locale/-/intl-locale-4.0.0.tgz#c111a33078413eba2011e82140466261eb1d67cd" 3925 + integrity sha512-+4dbMEGsp1bvB3JB3UHH6YTjMnFTifnfdaHp4ROrCCu50NedA69RBsDCG3eivcZkbj57X9ehGhMWjLxlP+gyVw== 3926 3926 dependencies: 3927 - "@formatjs/ecma402-abstract" "1.18.0" 3928 - "@formatjs/intl-enumerator" "1.4.3" 3927 + "@formatjs/ecma402-abstract" "2.0.0" 3928 + "@formatjs/intl-enumerator" "1.4.7" 3929 3929 "@formatjs/intl-getcanonicallocales" "2.3.0" 3930 3930 tslib "^2.4.0" 3931 3931 3932 - "@formatjs/intl-localematcher@0.5.2": 3933 - version "0.5.2" 3934 - resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.2.tgz#5fcf029fd218905575e5080fa33facdcb623d532" 3935 - integrity sha512-txaaE2fiBMagLrR4jYhxzFO6wEdEG4TPMqrzBAcbr4HFUYzH/YC+lg6OIzKCHm8WgDdyQevxbAAV1OgcXctuGw== 3932 + "@formatjs/intl-localematcher@0.5.4": 3933 + version "0.5.4" 3934 + resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz#caa71f2e40d93e37d58be35cfffe57865f2b366f" 3935 + integrity sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g== 3936 3936 dependencies: 3937 3937 tslib "^2.4.0" 3938 3938 3939 - "@formatjs/intl-pluralrules@^5.2.10": 3940 - version "5.2.10" 3941 - resolved "https://registry.yarnpkg.com/@formatjs/intl-pluralrules/-/intl-pluralrules-5.2.10.tgz#379fc06133625df0cae715c1d902001974ff3279" 3942 - integrity sha512-wfJypePrbOByaZVPP1moLXHgS9LeAvi9coP95XZX7ySVrwdDGPnxz9Pw+o7J1o8AjLxjiqGrvAi74key5zzIjQ== 3939 + "@formatjs/intl-numberformat@^8.10.3": 3940 + version "8.10.3" 3941 + resolved "https://registry.yarnpkg.com/@formatjs/intl-numberformat/-/intl-numberformat-8.10.3.tgz#abc97cc6a7b7f1b20da9f07a976b5589c1192ab8" 3942 + integrity sha512-lH3liLMeIjZ19Zxt8RRPnBcpPweS1YNSXRURDiFfvFmRlDZUOd8+GlcVyECcPZPkIoSH/p4lfGrnaUzepxJ92g== 3943 + dependencies: 3944 + "@formatjs/ecma402-abstract" "2.0.0" 3945 + "@formatjs/intl-localematcher" "0.5.4" 3946 + tslib "^2.4.0" 3947 + 3948 + "@formatjs/intl-pluralrules@^5.2.14": 3949 + version "5.2.14" 3950 + resolved "https://registry.yarnpkg.com/@formatjs/intl-pluralrules/-/intl-pluralrules-5.2.14.tgz#7477bd2aa9bfde9e543d839707eff5460eb08026" 3951 + integrity sha512-l6Ev7aOGXJSh5EPDEqzsbyufdCCKXZk993QXRQebLsB0TXRhIyF4alqjdMEatLwIigK/Mka8kiVIOLeFP5Cj9Q== 3943 3952 dependencies: 3944 - "@formatjs/ecma402-abstract" "1.18.0" 3945 - "@formatjs/intl-localematcher" "0.5.2" 3953 + "@formatjs/ecma402-abstract" "2.0.0" 3954 + "@formatjs/intl-localematcher" "0.5.4" 3946 3955 tslib "^2.4.0" 3947 3956 3948 3957 "@fortawesome/fontawesome-common-types@6.4.2":