mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
* Use more neutral language for content * Add sfw mode setting * Make configuration context mandatory * Add sfw class when sfw mode active * Hide nsfw performer fields in sfw mode * Hide nsfw sort options * Hide nsfw filter/sort options in sfw mode * Replace o-count with like counter in sfw mode * Use sfw label for o-counter filter in sfw mode * Use likes instead of o-count in sfw mode in other places * Rename sfw mode to sfw content mode * Use sfw image for default performers in sfw mode * Document SFW content mode * Add SFW mode setting to setup * Clarify README * Change wording of sfw mode description * Handle configuration loading error correctly * Hide age in performer cards
40 lines
861 B
TypeScript
40 lines
861 B
TypeScript
import React from "react";
|
|
import * as GQL from "src/core/generated-graphql";
|
|
|
|
export interface IContext {
|
|
configuration: GQL.ConfigDataFragment;
|
|
}
|
|
|
|
export const ConfigurationContext = React.createContext<IContext | null>(null);
|
|
|
|
export const useConfigurationContext = () => {
|
|
const context = React.useContext(ConfigurationContext);
|
|
|
|
if (context === null) {
|
|
throw new Error(
|
|
"useConfigurationContext must be used within a ConfigurationProvider"
|
|
);
|
|
}
|
|
|
|
return context;
|
|
};
|
|
|
|
export const useConfigurationContextOptional = () => {
|
|
return React.useContext(ConfigurationContext);
|
|
};
|
|
|
|
export const ConfigurationProvider: React.FC<IContext> = ({
|
|
configuration,
|
|
children,
|
|
}) => {
|
|
return (
|
|
<ConfigurationContext.Provider
|
|
value={{
|
|
configuration,
|
|
}}
|
|
>
|
|
{children}
|
|
</ConfigurationContext.Provider>
|
|
);
|
|
};
|