diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-06-12 01:22:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-11 15:22:21 -0700 |
commit | 18b258d060e51af1890809cee271af5362e24207 (patch) | |
tree | 19631f5d770d4126087c2aa0efb4c5c033ac7ecc /src/state/unstable-post-source.tsx | |
parent | 093454f5b21b8b2e6cbe7948c788ffc234b969fc (diff) | |
download | voidsky-18b258d060e51af1890809cee271af5362e24207.tar.zst |
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>
Diffstat (limited to 'src/state/unstable-post-source.tsx')
-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) + } } } } |