45f0f7eefe
* Direct port of embeds to new arch (cherry picked from commit cc3fa1f6cea396dd9222486c633a508bfee1ecd6) * Re-org * Split out ListEmbed and FeedEmbed * Split out ImageEmbed * DRY up a bit * Port over ExternalLinkEmbed * Port over Player and Gif embeds * Migrate ComposerReplyTo * Replace other usages of old post-embeds * Migrate view contexts * Copy pasta VideoEmbed * Copy pasta GifEmbed * Swap in new file location * Clean up * Fix up native * Add back in correct moderation on List and Feed embeds * Format * Prettier * delete old video utils * move bandwidth-estimate.ts * Remove log * Add LazyQuoteEmbed for composer use * Clean up unused things * Remove remaining items * Prettier * Fix imports * Handle nested quotes same as prod * Add back silenced error handling * Fix lint --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
28 lines
666 B
TypeScript
28 lines
666 B
TypeScript
import React from 'react'
|
|
|
|
import {type ContextType, type ItemContextType} from '#/components/Menu/types'
|
|
|
|
export const Context = React.createContext<ContextType | null>(null)
|
|
|
|
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
|
|
|
export function useMenuContext() {
|
|
const context = React.useContext(Context)
|
|
|
|
if (!context) {
|
|
throw new Error('useMenuContext must be used within a Context.Provider')
|
|
}
|
|
|
|
return context
|
|
}
|
|
|
|
export function useMenuItemContext() {
|
|
const context = React.useContext(ItemContext)
|
|
|
|
if (!context) {
|
|
throw new Error('useMenuItemContext must be used within a Context.Provider')
|
|
}
|
|
|
|
return context
|
|
}
|