mirror of https://github.com/fantasticit/think.git
fix: fix get active documents ids
This commit is contained in:
parent
2d9f7f202a
commit
59b5fc3539
|
@ -16,11 +16,15 @@ interface IProps {
|
||||||
export const Documents: React.FC<IProps> = ({ wikiId }) => {
|
export const Documents: React.FC<IProps> = ({ wikiId }) => {
|
||||||
const { data: wiki, loading: wikiLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
|
const { data: wiki, loading: wikiLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
|
||||||
const { data: tocs, loading } = useWikiTocs(wikiId);
|
const { data: tocs, loading } = useWikiTocs(wikiId);
|
||||||
const documents = flattenTree2Array(tocs).map((d) => {
|
const documents = useMemo(
|
||||||
|
() =>
|
||||||
|
flattenTree2Array(tocs).map((d) => {
|
||||||
d.label = d.title;
|
d.label = d.title;
|
||||||
d.value = d.id;
|
d.value = d.id;
|
||||||
return d;
|
return d;
|
||||||
});
|
}),
|
||||||
|
[tocs]
|
||||||
|
);
|
||||||
const [nextStatus, setNextStatus] = useState('');
|
const [nextStatus, setNextStatus] = useState('');
|
||||||
const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]);
|
const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]);
|
||||||
const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的
|
const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的
|
||||||
|
@ -47,7 +51,6 @@ export const Documents: React.FC<IProps> = ({ wikiId }) => {
|
||||||
}}
|
}}
|
||||||
key={item.label}
|
key={item.label}
|
||||||
checked={item.checked}
|
checked={item.checked}
|
||||||
style={{ height: 52 }}
|
|
||||||
>
|
>
|
||||||
<Text>{item.title}</Text>
|
<Text>{item.title}</Text>
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
@ -77,7 +80,7 @@ export const Documents: React.FC<IProps> = ({ wikiId }) => {
|
||||||
if (!documents.length) return;
|
if (!documents.length) return;
|
||||||
const activeIds = documents.filter((doc) => isPublicDocument(doc.status)).map((doc) => doc.id);
|
const activeIds = documents.filter((doc) => isPublicDocument(doc.status)).map((doc) => doc.id);
|
||||||
setPublicDocumentIds(activeIds);
|
setPublicDocumentIds(activeIds);
|
||||||
}, [tocs, documents]);
|
}, [documents]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
|
|
Loading…
Reference in New Issue