Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Update IS_PROD check (#2930)

* update is_prod check

* remove unused constants

* rename `IS_PROD` function to `IS_PROD_SERVICE`

authored by

Hailey and committed by
GitHub
5573c38c 943acd16

+23 -100
+7 -90
src/lib/constants.ts
··· 3 3 export const LOCAL_DEV_SERVICE = 4 4 Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583' 5 5 export const STAGING_SERVICE = 'https://staging.bsky.dev' 6 - export const PROD_SERVICE = 'https://bsky.social' 7 - export const DEFAULT_SERVICE = PROD_SERVICE 8 - 6 + export const BSKY_SERVICE = 'https://bsky.social' 7 + export const DEFAULT_SERVICE = BSKY_SERVICE 9 8 const HELP_DESK_LANG = 'en-us' 10 9 export const HELP_DESK_URL = `https://blueskyweb.zendesk.com/hc/${HELP_DESK_LANG}` 11 10 ··· 36 35 // but increasing limit per user feedback 37 36 export const MAX_ALT_TEXT = 1000 38 37 39 - export function IS_LOCAL_DEV(url: string) { 40 - return url.includes('localhost') 41 - } 42 - 43 - export function IS_STAGING(url: string) { 44 - return url.startsWith('https://staging.bsky.dev') 45 - } 46 - 47 - export function IS_PROD(url: string) { 48 - // NOTE 49 - // until open federation, "production" is defined as the main server 50 - // this definition will not work once federation is enabled! 51 - // -prf 52 - return ( 53 - url.startsWith('https://bsky.social') || 54 - url.startsWith('https://api.bsky.app') || 55 - /bsky\.network\/?$/.test(url) 56 - ) 38 + export function IS_PROD_SERVICE(url?: string) { 39 + return url && url !== STAGING_SERVICE && url !== LOCAL_DEV_SERVICE 57 40 } 58 41 59 - export const PROD_TEAM_HANDLES = [ 60 - 'jay.bsky.social', 61 - 'pfrazee.com', 62 - 'divy.zone', 63 - 'dholms.xyz', 64 - 'why.bsky.world', 65 - 'iamrosewang.bsky.social', 66 - ] 67 - export const STAGING_TEAM_HANDLES = [ 68 - 'arcalinea.staging.bsky.dev', 69 - 'paul.staging.bsky.dev', 70 - 'paul2.staging.bsky.dev', 71 - ] 72 - export const DEV_TEAM_HANDLES = ['alice.test', 'bob.test', 'carla.test'] 73 - 74 - export function TEAM_HANDLES(serviceUrl: string) { 75 - if (serviceUrl.includes('localhost')) { 76 - return DEV_TEAM_HANDLES 77 - } else if (serviceUrl.includes('staging')) { 78 - return STAGING_TEAM_HANDLES 79 - } else { 80 - return PROD_TEAM_HANDLES 81 - } 82 - } 83 - 84 - export const STAGING_DEFAULT_FEED = (rkey: string) => 85 - `at://did:plc:wqzurwm3kmaig6e6hnc2gqwo/app.bsky.feed.generator/${rkey}` 86 42 export const PROD_DEFAULT_FEED = (rkey: string) => 87 43 `at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}` 88 - export async function DEFAULT_FEEDS( 89 - serviceUrl: string, 90 - resolveHandle: (name: string) => Promise<string>, 91 - ) { 92 - // TODO: remove this when the test suite no longer relies on it 93 - if (IS_LOCAL_DEV(serviceUrl)) { 94 - // local dev 95 - const aliceDid = await resolveHandle('alice.test') 96 - return { 97 - pinned: [ 98 - `at://${aliceDid}/app.bsky.feed.generator/alice-favs`, 99 - `at://${aliceDid}/app.bsky.feed.generator/alice-favs2`, 100 - ], 101 - saved: [ 102 - `at://${aliceDid}/app.bsky.feed.generator/alice-favs`, 103 - `at://${aliceDid}/app.bsky.feed.generator/alice-favs2`, 104 - ], 105 - } 106 - } else if (IS_STAGING(serviceUrl)) { 107 - // staging 108 - return { 109 - pinned: [STAGING_DEFAULT_FEED('whats-hot')], 110 - saved: [ 111 - STAGING_DEFAULT_FEED('bsky-team'), 112 - STAGING_DEFAULT_FEED('with-friends'), 113 - STAGING_DEFAULT_FEED('whats-hot'), 114 - STAGING_DEFAULT_FEED('hot-classic'), 115 - ], 116 - } 117 - } else { 118 - // production 119 - return { 120 - pinned: [PROD_DEFAULT_FEED('whats-hot')], 121 - saved: [PROD_DEFAULT_FEED('whats-hot')], 122 - } 123 - } 124 - } 125 44 126 45 export const POST_IMG_MAX = { 127 46 width: 2000, ··· 135 54 export const PROD_LINK_META_PROXY = 'https://cardyb.bsky.app/v1/extract?url=' 136 55 137 56 export function LINK_META_PROXY(serviceUrl: string) { 138 - if (IS_LOCAL_DEV(serviceUrl)) { 139 - return STAGING_LINK_META_PROXY 140 - } else if (IS_STAGING(serviceUrl)) { 141 - return STAGING_LINK_META_PROXY 142 - } else { 57 + if (IS_PROD_SERVICE(serviceUrl)) { 143 58 return PROD_LINK_META_PROXY 144 59 } 60 + 61 + return STAGING_LINK_META_PROXY 145 62 } 146 63 147 64 export const STATUS_PAGE_URL = 'https://status.bsky.app/'
+2 -2
src/lib/strings/url-helpers.ts
··· 1 1 import {AtUri} from '@atproto/api' 2 - import {PROD_SERVICE} from 'lib/constants' 2 + import {BSKY_SERVICE} from 'lib/constants' 3 3 import TLDs from 'tlds' 4 4 import psl from 'psl' 5 5 ··· 28 28 export function toNiceDomain(url: string): string { 29 29 try { 30 30 const urlp = new URL(url) 31 - if (`https://${urlp.host}` === PROD_SERVICE) { 31 + if (`https://${urlp.host}` === BSKY_SERVICE) { 32 32 return 'Bluesky Social' 33 33 } 34 34 return urlp.host ? urlp.host : url
+9 -3
src/screens/Onboarding/StepTopicalFeeds.tsx
··· 3 3 import {useLingui} from '@lingui/react' 4 4 import {msg, Trans} from '@lingui/macro' 5 5 6 - import {IS_PROD} from '#/env' 7 6 import {atoms as a} from '#/alf' 8 7 import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron' 9 8 import {ListMagnifyingGlass_Stroke2_Corner0_Rounded as ListMagnifyingGlass} from '#/components/icons/ListMagnifyingGlass' ··· 22 21 import {FeedCard} from '#/screens/Onboarding/StepAlgoFeeds/FeedCard' 23 22 import {aggregateInterestItems} from '#/screens/Onboarding/util' 24 23 import {IconCircle} from '#/components/IconCircle' 24 + import {IS_PROD_SERVICE} from 'lib/constants' 25 + import {useSession} from 'state/session' 25 26 26 27 export function StepTopicalFeeds() { 27 28 const {_} = useLingui() 28 29 const {track} = useAnalytics() 30 + const {currentAccount} = useSession() 29 31 const {state, dispatch, interestsDisplayNames} = React.useContext(Context) 30 32 const [selectedFeedUris, setSelectedFeedUris] = React.useState<string[]>([]) 31 33 const [saving, setSaving] = React.useState(false) 32 34 const suggestedFeedUris = React.useMemo(() => { 33 - if (!IS_PROD) return [] 35 + if (!IS_PROD_SERVICE(currentAccount?.service)) return [] 34 36 return aggregateInterestItems( 35 37 state.interestsStepResults.selectedInterests, 36 38 state.interestsStepResults.apiResponse.suggestedFeedUris, 37 39 state.interestsStepResults.apiResponse.suggestedFeedUris.default, 38 40 ).slice(0, 10) 39 - }, [state.interestsStepResults]) 41 + }, [ 42 + currentAccount?.service, 43 + state.interestsStepResults.apiResponse.suggestedFeedUris, 44 + state.interestsStepResults.selectedInterests, 45 + ]) 40 46 41 47 const interestsText = React.useMemo(() => { 42 48 const i = state.interestsStepResults.selectedInterests.map(
+2 -2
src/view/com/auth/create/state.ts
··· 12 12 import {cleanError} from '#/lib/strings/errors' 13 13 import {useOnboardingDispatch} from '#/state/shell/onboarding' 14 14 import {useSessionApi} from '#/state/session' 15 - import {DEFAULT_SERVICE, IS_PROD} from '#/lib/constants' 15 + import {DEFAULT_SERVICE, IS_PROD_SERVICE} from '#/lib/constants' 16 16 import { 17 17 DEFAULT_PROD_FEEDS, 18 18 usePreferencesSetBirthDateMutation, ··· 147 147 : undefined, 148 148 }) 149 149 setBirthDate({birthDate: uiState.birthDate}) 150 - if (IS_PROD(uiState.serviceUrl)) { 150 + if (IS_PROD_SERVICE(uiState.serviceUrl)) { 151 151 setSavedFeeds(DEFAULT_PROD_FEEDS) 152 152 } 153 153 } catch (e: any) {
+3 -3
src/view/com/auth/server-input/index.tsx
··· 2 2 import {View} from 'react-native' 3 3 import {useLingui} from '@lingui/react' 4 4 import {Trans, msg} from '@lingui/macro' 5 - import {PROD_SERVICE} from 'lib/constants' 5 + import {BSKY_SERVICE} from 'lib/constants' 6 6 import * as persisted from '#/state/persisted' 7 7 8 8 import {atoms as a, useBreakpoints, useTheme} from '#/alf' ··· 26 26 const [pdsAddressHistory, setPdsAddressHistory] = React.useState<string[]>( 27 27 persisted.get('pdsAddressHistory') || [], 28 28 ) 29 - const [fixedOption, setFixedOption] = React.useState([PROD_SERVICE]) 29 + const [fixedOption, setFixedOption] = React.useState([BSKY_SERVICE]) 30 30 const [customAddress, setCustomAddress] = React.useState('') 31 31 32 32 const onClose = React.useCallback(() => { ··· 86 86 label="Preferences" 87 87 values={fixedOption} 88 88 onChange={setFixedOption}> 89 - <ToggleButton.Button name={PROD_SERVICE} label={_(msg`Bluesky`)}> 89 + <ToggleButton.Button name={BSKY_SERVICE} label={_(msg`Bluesky`)}> 90 90 {_(msg`Bluesky`)} 91 91 </ToggleButton.Button> 92 92 <ToggleButton.Button