/* * 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 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { BooleanParam, useQueryParam, StringParam } from 'use-query-params'; interface IUseLibraryOptions { downloaded: NullAndUndefined setDownloaded: (downloaded: NullAndUndefined)=>void unread: NullAndUndefined setUnread: (unread: NullAndUndefined) => void query: NullAndUndefined setQuery: (query: NullAndUndefined) => void active: boolean } export default function useLibraryOptions(): IUseLibraryOptions { const [downloaded, setDownloaded] = useQueryParam('downloaded', BooleanParam); const [unread, setUnread] = useQueryParam('unread', BooleanParam); const [query, setQuery] = useQueryParam('query', StringParam); // eslint-disable-next-line eqeqeq const active = !(unread == undefined) || !(downloaded == undefined); return { downloaded, setDownloaded, unread, setUnread, query, setQuery, active, }; }