2022-03-03 18:19:01 +05:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2022-03-03 18:19:01 +05:30
|
|
|
|
2023-02-08 18:19:26 +01:00
|
|
|
import LibraryOptionsContext, { DefaultLibraryOptions } from 'components/context/LibraryOptionsContext';
|
2023-03-11 18:05:58 +01:00
|
|
|
import React, { useMemo } from 'react';
|
2022-03-03 18:19:01 +05:30
|
|
|
import useLocalStorage from 'util/useLocalStorage';
|
2023-02-24 16:40:37 +01:00
|
|
|
import { LibraryOptions } from 'typings';
|
2022-03-03 18:19:01 +05:30
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 09:41:03 +01:00
|
|
|
const LibraryOptionsContextProvider: React.FC<IProps> = ({ children }) => {
|
2023-02-08 18:19:26 +01:00
|
|
|
const [options, setOptions] = useLocalStorage<LibraryOptions>('libraryOptions', DefaultLibraryOptions);
|
2022-04-07 12:53:14 +02:00
|
|
|
|
2023-03-11 18:05:58 +01:00
|
|
|
const value = useMemo(() => ({ options, setOptions }), [options, setOptions]);
|
|
|
|
|
|
|
|
|
|
return <LibraryOptionsContext.Provider value={value}>{children}</LibraryOptionsContext.Provider>;
|
2022-11-24 09:41:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LibraryOptionsContextProvider;
|