16 lines
445 B
TypeScript
16 lines
445 B
TypeScript
import { useContext } from "react";
|
|
import { DialogStateContext } from "./DialogStateProvider";
|
|
|
|
export function useDialogPin(dialog_id: string){
|
|
const context = useContext(DialogStateContext);
|
|
if(!context){
|
|
throw new Error("useDialogState must be used within a DialogStateProvider");
|
|
}
|
|
|
|
const isPinned = context.pinned.includes(dialog_id);
|
|
|
|
return {
|
|
isPinned,
|
|
pinToggle: context.pinToggle
|
|
}
|
|
} |