Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Loosen post source constraints (#8478)

* Loosen post source constraints

* logger warn if failed to find source

* Tweak assertion logic

---------

Co-authored-by: Eric Bailey <git@esb.lol>

authored by

Samuel Newman
Eric Bailey
and committed by
GitHub
18b258d0 093454f5

+10 -5
+10 -5
src/state/unstable-post-source.tsx
··· 34 34 * Used for FeedFeedback and other ephemeral non-critical systems. 35 35 */ 36 36 export function setUnstablePostSource(key: string, source: PostSource) { 37 - assertValid( 37 + assertValidDevOnly( 38 38 key, 39 39 `setUnstablePostSource key should be a URI containing a handle, received ${key} — use buildPostSourceKey`, 40 40 ) ··· 51 51 export function useUnstablePostSource(key: string) { 52 52 const id = useId() 53 53 const [source] = useState(() => { 54 - assertValid( 54 + assertValidDevOnly( 55 55 key, 56 - `consumeUnstablePostSource key should be a URI containing a handle, received ${key} — use buildPostSourceKey`, 56 + `consumeUnstablePostSource key should be a URI containing a handle, received ${key} — be sure to use buildPostSourceKey when setting the source`, 57 + true, 57 58 ) 58 59 const source = consumedSources.get(id) || transientSources.get(key) 59 60 if (source) { ··· 87 88 /** 88 89 * Just a lil dev helper 89 90 */ 90 - function assertValid(key: string, message: string) { 91 + function assertValidDevOnly(key: string, message: string, beChill = false) { 91 92 if (__DEV__) { 92 93 const urip = new AtUri(key) 93 94 if (urip.host.startsWith('did:')) { 94 - throw new Error(message) 95 + if (beChill) { 96 + logger.warn(message) 97 + } else { 98 + throw new Error(message) 99 + } 95 100 } 96 101 } 97 102 }