-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(replay): Move some project code into useReplayProjectSlug (#82516)
Extract some code that converts a projectId into a projectSlug. I'm extracting it because it's something to be reused between `components/replays/replayPlayer.tsx` and `components/replays/player/replayPlayer.tsx`. Also, relying on the ProjectStore as this does is something that'll need to be refactored in the future because loading the ProjectStore is slow, so it's nice to separate this out.
- Loading branch information
Showing
2 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {useMemo} from 'react'; | ||
|
||
import useProjects from 'sentry/utils/useProjects'; | ||
import type {ReplayRecord} from 'sentry/views/replays/types'; | ||
|
||
interface Props { | ||
replayRecord: ReplayRecord | undefined; | ||
} | ||
|
||
export function useReplayProjectSlug({replayRecord}: Props) { | ||
const projects = useProjects(); | ||
return useMemo(() => { | ||
if (!replayRecord) { | ||
return null; | ||
} | ||
return projects.projects.find(p => p.id === replayRecord.project_id)?.slug ?? null; | ||
}, [replayRecord, projects]); | ||
} |