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

1.115.0 fast follows (#9743)

* Fix caching, fix attributes setting

* Use useCallOnce hook

* Update dismissal handling

* Update copy

authored by

Eric Bailey and committed by
GitHub
3523e7ce 967b3b49

+57 -38
+1 -1
src/analytics/features/index.ts
··· 16 16 return value != null ? JSON.parse(value) : null 17 17 }, 18 18 setItem: async (key, value) => { 19 - CACHE.set(key, JSON.stringify(value)) 19 + CACHE.set(key, value) 20 20 }, 21 21 }, 22 22 })
+7 -4
src/analytics/index.tsx
··· 180 180 }) { 181 181 const parentContext = useContext(Context) 182 182 183 + /** 184 + * Side-effect: we need to synchronously set this during the 185 + * same render cycle. It does not trigger a re-render, it just 186 + * sets properties on the singleton GrowthBook instance. 187 + */ 188 + setAttributes(parentContext.metadata) 189 + 183 190 useEffect(() => { 184 191 feats.setTrackingCallback((experiment, result) => { 185 192 parentContext.metric('experiment:viewed', { ··· 188 195 }) 189 196 }) 190 197 }, [parentContext.metric]) 191 - 192 - useEffect(() => { 193 - setAttributes(parentContext.metadata) 194 - }, [parentContext.metadata]) 195 198 196 199 const childContext = useMemo<AnalyticsContextType>(() => { 197 200 return {
+40 -20
src/features/liveEvents/components/DiscoverFeedLiveEventFeedsAndTrendingBanner.tsx
··· 1 1 import {View} from 'react-native' 2 - import {msg} from '@lingui/macro' 2 + import {msg, Trans} from '@lingui/macro' 3 3 import {useLingui} from '@lingui/react' 4 4 5 5 import {useTrendingSettings} from '#/state/preferences/trending' 6 6 import {atoms as a, useLayoutBreakpoints} from '#/alf' 7 7 import {Button} from '#/components/Button' 8 - import {DotGrid_Stroke2_Corner0_Rounded as EllipsisIcon} from '#/components/icons/DotGrid' 8 + import {TimesLarge_Stroke2_Corner0_Rounded as CloseIcon} from '#/components/icons/Times' 9 9 import {TrendingInterstitial} from '#/components/interstitials/Trending' 10 + import * as Toast from '#/components/Toast' 10 11 import {LiveEventFeedCardWide} from '#/features/liveEvents/components/LiveEventFeedCardWide' 11 - import { 12 - LiveEventFeedOptionsMenu, 13 - useDialogControl, 14 - } from '#/features/liveEvents/components/LiveEventFeedOptionsMenu' 15 12 import {useUserPreferencedLiveEvents} from '#/features/liveEvents/context' 13 + import {useUpdateLiveEventPreferences} from '#/features/liveEvents/preferences' 16 14 import {type LiveEventFeed} from '#/features/liveEvents/types' 17 15 18 16 export function DiscoverFeedLiveEventFeedsAndTrendingBanner() { ··· 38 36 39 37 function Inner({feed}: {feed: LiveEventFeed}) { 40 38 const {_} = useLingui() 41 - const optionsMenuControl = useDialogControl() 42 39 const layout = feed.layouts.wide 43 40 41 + const {mutate: update, variables} = useUpdateLiveEventPreferences({ 42 + feed, 43 + metricContext: 'discover', 44 + onUpdateSuccess({undoAction}) { 45 + Toast.show( 46 + <Toast.Outer> 47 + <Toast.Icon /> 48 + <Toast.Text> 49 + {undoAction ? ( 50 + <Trans>Live event hidden</Trans> 51 + ) : ( 52 + <Trans>Live event unhidden</Trans> 53 + )} 54 + </Toast.Text> 55 + {undoAction && ( 56 + <Toast.Action 57 + label={_(msg`Undo`)} 58 + onPress={() => { 59 + if (undoAction) { 60 + update(undoAction) 61 + } 62 + }}> 63 + <Trans>Undo</Trans> 64 + </Toast.Action> 65 + )} 66 + </Toast.Outer>, 67 + {type: 'success'}, 68 + ) 69 + }, 70 + }) 71 + 72 + if (variables) return null 73 + 44 74 return ( 45 75 <> 46 76 <View style={[a.px_lg, a.pt_md, a.pb_xs]}> ··· 48 78 <LiveEventFeedCardWide feed={feed} metricContext="discover" /> 49 79 50 80 <Button 51 - label={_(msg`Configure live event banner`)} 81 + label={_(msg`Dismiss live event banner`)} 52 82 size="tiny" 53 83 shape="round" 54 84 style={[a.absolute, a.z_10, {top: 6, right: 6}]} 55 85 onPress={() => { 56 - optionsMenuControl.open() 86 + update({type: 'hideFeed', id: feed.id}) 57 87 }}> 58 88 {({hovered, pressed}) => ( 59 89 <> ··· 68 98 }, 69 99 ]} 70 100 /> 71 - <EllipsisIcon 72 - size="sm" 73 - fill={layout.textColor} 74 - style={[a.z_20]} 75 - /> 101 + <CloseIcon size="xs" fill={layout.textColor} style={[a.z_20]} /> 76 102 </> 77 103 )} 78 104 </Button> 79 105 </View> 80 106 </View> 81 - 82 - <LiveEventFeedOptionsMenu 83 - feed={feed} 84 - control={optionsMenuControl} 85 - metricContext="discover" 86 - /> 87 107 </> 88 108 ) 89 109 }
+4 -4
src/features/liveEvents/components/LiveEventFeedCardCompact.tsx
··· 1 - import {useEffect, useMemo} from 'react' 1 + import {useMemo} from 'react' 2 2 import {View} from 'react-native' 3 3 import {Image} from 'expo-image' 4 4 import {LinearGradient} from 'expo-linear-gradient' 5 5 import {msg} from '@lingui/macro' 6 6 import {useLingui} from '@lingui/react' 7 7 8 + import {useCallOnce} from '#/lib/once' 8 9 import {isBskyCustomFeedUrl} from '#/lib/strings/url-helpers' 9 10 import {atoms as a, utils} from '#/alf' 10 11 import {Live_Stroke2_Corner0_Rounded as LiveIcon} from '#/components/icons/Live' ··· 39 40 return '/' 40 41 }, [feed.url]) 41 42 42 - useEffect(() => { 43 + useCallOnce(() => { 43 44 ax.metric('liveEvents:feedBanner:seen', { 44 45 feed: feed.url, 45 46 context: metricContext, 46 47 }) 47 - // eslint-disable-next-line react-hooks/exhaustive-deps 48 - }, []) 48 + })() 49 49 50 50 return ( 51 51 <Link
+4 -1
src/lib/hooks/useIsBskyTeam.ts
··· 4 4 5 5 export function useIsBskyTeam() { 6 6 const ax = useAnalytics() 7 - return useMemo(() => ax.features.enabled(ax.features.IsBskyTeam), [ax]) 7 + return useMemo( 8 + () => ax.features.enabled(ax.features.IsBskyTeam), 9 + [ax.features], 10 + ) 8 11 }
+1 -8
src/screens/Settings/ContentAndMediaSettings.tsx
··· 26 26 import * as Layout from '#/components/Layout' 27 27 import {useAnalytics} from '#/analytics' 28 28 import {IS_NATIVE} from '#/env' 29 - import {LiveEventFeedsSettingsToggle} from '#/features/liveEvents/components/LiveEventFeedsSettingsToggle' 30 29 31 30 type Props = NativeStackScreenProps< 32 31 CommonNavigatorParams, ··· 150 149 <Toggle.Platform /> 151 150 </SettingsList.Item> 152 151 </Toggle.Item> 153 - <LiveEventFeedsSettingsToggle /> 154 152 <Toggle.Item 155 153 name="show_trending_videos" 156 154 label={_(msg`Enable trending videos in your Discover feed`)} ··· 173 171 </SettingsList.Item> 174 172 </Toggle.Item> 175 173 </> 176 - ) : ( 177 - <> 178 - <SettingsList.Divider /> 179 - <LiveEventFeedsSettingsToggle /> 180 - </> 181 - )} 174 + ) : null} 182 175 </SettingsList.Container> 183 176 </Layout.Content> 184 177 </Layout.Screen>