Hide media by default in notification requests (#29572)
This commit is contained in:
parent
71e5f0f48c
commit
a32a126cac
3 changed files with 65 additions and 29 deletions
|
@ -0,0 +1,28 @@
|
|||
import { createContext, useContext, useMemo } from 'react';
|
||||
|
||||
export const SensitiveMediaContext = createContext<{
|
||||
hideMediaByDefault: boolean;
|
||||
}>({
|
||||
hideMediaByDefault: false,
|
||||
});
|
||||
|
||||
export function useSensitiveMediaContext() {
|
||||
return useContext(SensitiveMediaContext);
|
||||
}
|
||||
|
||||
type ContextValue = React.ContextType<typeof SensitiveMediaContext>;
|
||||
|
||||
export const SensitiveMediaContextProvider: React.FC<
|
||||
React.PropsWithChildren<{ hideMediaByDefault: boolean }>
|
||||
> = ({ hideMediaByDefault, children }) => {
|
||||
const contextValue = useMemo<ContextValue>(
|
||||
() => ({ hideMediaByDefault }),
|
||||
[hideMediaByDefault],
|
||||
);
|
||||
|
||||
return (
|
||||
<SensitiveMediaContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</SensitiveMediaContext.Provider>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue