Files
buzz/desktop/src/shared/lib/useRelayOrigin.ts
thomaspblock e30db7028f feat(projects): support multiple repositories (#4671)
## Summary
- adopt the finalized NIP-MP project model so one project can enumerate
and switch between multiple NIP-34 repositories
- add project and repository navigation, activity summaries,
existing-repository attachment, and repository access-channel management
- preserve privacy-safe activation provenance for agent-authored
patches, pull requests, issues, and associated commits

## Test plan
- [x] Run desktop typecheck and unit tests
- [x] Run focused NIP-MP, repository access, and provenance tests
- [x] Run Rust formatting and desktop lint checks
- [x] Run the complete pre-push suite after merging current `main`
- [ ] Manually verify project creation, repository attachment,
switching, and access repair on staging
- [ ] Manually verify public-channel and private-agent origin labels on
newly created Git activity

Related: [#4695](https://github.com/block/buzz/pull/4695)

---------

Signed-off-by: Thomas Petersen <thomasp@squareup.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
2026-08-04 17:30:12 -04:00

31 lines
1.0 KiB
TypeScript

import * as React from "react";
import {
ensureRelayOriginFetch,
getCachedRelayOrigin,
subscribeRelayOrigin,
} from "./mediaUrl";
/**
* The resolved relay origin, re-rendering when it resolves or changes.
*
* The origin is fetched asynchronously (see `mediaUrl.ts`) and is commonly
* still `null` on a component's first render. Reading it through this store
* subscription — rather than a bare synchronous `getCachedRelayOrigin()` —
* means download eligibility recomputes the moment the origin resolves and
* again on a workspace switch, instead of being frozen at first-render time.
*
* The server snapshot is `null`: there is no relay origin during SSR/prerender
* (no Tauri backend), and callers already treat an unresolved origin as
* "not yet downloadable" (fail closed).
*/
export function useRelayOrigin(): string | null {
const origin = React.useSyncExternalStore(
subscribeRelayOrigin,
getCachedRelayOrigin,
() => null,
);
React.useEffect(ensureRelayOriginFetch, []);
return origin;
}