import { useContext } from "react";
import { DialogListContext } from "./DialogListProvider";

export function useDialogsList() {
    const context = useContext(DialogListContext);
    if(!context){
        throw new Error("useDialogList must be call in DialogListProvider");
    }
    const {dialogs, updateDialog, setDialogs, loadingDialogs} = context;

    return {
        dialogs,
        updateDialog,
        setDialogs,
        loadingDialogs
    };
}