import { ReactNode, memo, useEffect, useMemo, useState } from "react"; import { NonIdealState, Slider, SliderProps, Spinner, Switch } from "@blueprintjs/core"; import { ListWrapper, Toolbar } from "Components/DataList"; import { ErrorBoundary } from "Components/Errors"; import { useRequestsSettings } from "Components/UserSettings"; import LogItem from "./LogItem"; import { useItems } from "@clients/zotero"; import { useBool } from "@hooks"; import { makeLogFromItems } from "./utils"; import { CustomClasses } from "../../../constants"; import { categorizeLibraryItems } from "../../../utils"; import { ZDataViewContents, ZLibraryContents, ZLogItem } from "Types/transforms"; import "./_index.sass"; type LogViewSublistProps = { allAbstractsShown: boolean, items: ZLogItem[], label: ReactNode, onClose: () => void }; const LogViewSublist = memo(function LogViewSublist({ allAbstractsShown, items, label, onClose }){ return items.length == 0 ? null : <>
{label}
{items.map(it => )} ; }); const logViewSliderStaticProps: Partial = { labelRenderer: (num, renderingOptions = { isHandleTooltip: false }) => { return renderingOptions.isHandleTooltip ? `Last ${num} days` : ""; }, min: 3, max: 30, stepSize: 1 }; type LogViewProps = { itemList: ZLibraryContents, onClose: () => void }; const LogView = memo(function LogView({ itemList, onClose }){ const [asRecentAs, setAsRecentAs] = useState(7); const [allAbstractsShown, { toggle: toggleAbstracts }] = useBool(false); const [itemsLog, setItemsLog] = useState(null); useEffect(() => { if(itemList){ makeLogFromItems(itemList, asRecentAs) .then(data => setItemsLog(data)); } }, [asRecentAs, itemList]); return ( itemsLog == null ? :
{itemsLog.numItems == 0 ? : }
); }); type RecentItemsProps = { onClose: () => void }; const RecentItems = memo(function RecentItems({ onClose }){ const [{ dataRequests }] = useRequestsSettings(); const itemQueries = useItems(dataRequests, { notifyOnChangeProps: ["data"], select: (datastore) => datastore.data }); const isLoading = itemQueries.some(q => q.isLoading); const data = useMemo(() => itemQueries.map(q => q.data || []).flat(1), [itemQueries]); const itemList = useMemo(() => categorizeLibraryItems(data), [data]); return
{isLoading ? : }
; }); export default RecentItems;