diff options
-rw-r--r-- | src/state/unstable-post-source.tsx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/state/unstable-post-source.tsx b/src/state/unstable-post-source.tsx index ac126d79c..450f2c120 100644 --- a/src/state/unstable-post-source.tsx +++ b/src/state/unstable-post-source.tsx @@ -34,7 +34,7 @@ const consumedSources = new Map<string, PostSource>() * Used for FeedFeedback and other ephemeral non-critical systems. */ export function setUnstablePostSource(key: string, source: PostSource) { - assertValid( + assertValidDevOnly( key, `setUnstablePostSource key should be a URI containing a handle, received ${key} — use buildPostSourceKey`, ) @@ -51,9 +51,10 @@ export function setUnstablePostSource(key: string, source: PostSource) { export function useUnstablePostSource(key: string) { const id = useId() const [source] = useState(() => { - assertValid( + assertValidDevOnly( key, - `consumeUnstablePostSource key should be a URI containing a handle, received ${key} — use buildPostSourceKey`, + `consumeUnstablePostSource key should be a URI containing a handle, received ${key} — be sure to use buildPostSourceKey when setting the source`, + true, ) const source = consumedSources.get(id) || transientSources.get(key) if (source) { @@ -87,11 +88,15 @@ export function buildPostSourceKey(key: string, handle: string) { /** * Just a lil dev helper */ -function assertValid(key: string, message: string) { +function assertValidDevOnly(key: string, message: string, beChill = false) { if (__DEV__) { const urip = new AtUri(key) if (urip.host.startsWith('did:')) { - throw new Error(message) + if (beChill) { + logger.warn(message) + } else { + throw new Error(message) + } } } } |