mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: npub1qvn3cujt28pg06ehlstrxyz6ayzp06t4uc7r566vxwwgrv24hglq9zju0n <03271c724b51c287eb37fc1633105ae90417e975e63c3a6b4c339c81b155ba3e@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1qvn3cujt28pg06ehlstrxyz6ayzp06t4uc7r566vxwwgrv24hglq9zju0n <03271c724b51c287eb37fc1633105ae90417e975e63c3a6b4c339c81b155ba3e@sprout-oss.stage.blox.sqprod.co>
40 lines
990 B
TypeScript
40 lines
990 B
TypeScript
import * as React from "react";
|
|
|
|
import type { BrowseDialogType } from "@/app/AppShellOverlays";
|
|
|
|
type CreatedCallback = (channelId: string) => void;
|
|
|
|
export function useChannelBrowserDialog(onOpen: () => void) {
|
|
const [browseDialogType, setBrowseDialogType] =
|
|
React.useState<BrowseDialogType>(null);
|
|
const createSuccessRef = React.useRef<CreatedCallback | null>(null);
|
|
|
|
const openBrowseChannels = React.useCallback(
|
|
(onCreated?: CreatedCallback) => {
|
|
createSuccessRef.current = onCreated ?? null;
|
|
setBrowseDialogType("stream");
|
|
onOpen();
|
|
},
|
|
[onOpen],
|
|
);
|
|
|
|
const onBrowseDialogOpenChange = React.useCallback((open: boolean) => {
|
|
if (!open) {
|
|
createSuccessRef.current = null;
|
|
setBrowseDialogType(null);
|
|
}
|
|
}, []);
|
|
|
|
const getCreateSuccess = React.useCallback(
|
|
() => createSuccessRef.current,
|
|
[],
|
|
);
|
|
|
|
return {
|
|
browseDialogType,
|
|
openBrowseChannels,
|
|
onBrowseDialogOpenChange,
|
|
getCreateSuccess,
|
|
};
|
|
}
|