mirror of
https://github.com/outline/outline.git
synced 2026-12-03 10:00:13 +03:00
* Migrations, models, commands * ui * Move starred hint to location state * lint * tsc * refactor * Add collection empty state in expanded sidebar * Add empty placeholder within starred collections * Drag and drop improves, Relative refactor * fix: Starring untitled draft leaves empty space * fix: Creating draft in starred collection shouldnt open main * fix: Dupe drop cursor * Final fixes * fix: Canonical redirect replaces starred location state * fix: Don't show reorder cursor at the top of collection with no permission to edit when dragging
40 lines
1017 B
TypeScript
40 lines
1017 B
TypeScript
import * as React from "react";
|
|
import { sortNavigationNodes } from "@shared/utils/collections";
|
|
import Collection from "~/models/Collection";
|
|
import Document from "~/models/Document";
|
|
|
|
export default function useCollectionDocuments(
|
|
collection: Collection | undefined,
|
|
activeDocument: Document | undefined
|
|
) {
|
|
return React.useMemo(() => {
|
|
if (!collection) {
|
|
return [];
|
|
}
|
|
|
|
if (
|
|
activeDocument?.isActive &&
|
|
activeDocument?.isDraft &&
|
|
activeDocument?.collectionId === collection.id &&
|
|
!activeDocument?.parentDocumentId
|
|
) {
|
|
return sortNavigationNodes(
|
|
[activeDocument.asNavigationNode, ...collection.documents],
|
|
collection.sort
|
|
);
|
|
}
|
|
|
|
return collection.documents;
|
|
}, [
|
|
activeDocument?.isActive,
|
|
activeDocument?.isDraft,
|
|
activeDocument?.collectionId,
|
|
activeDocument?.parentDocumentId,
|
|
activeDocument?.asNavigationNode,
|
|
collection,
|
|
collection?.documents,
|
|
collection?.id,
|
|
collection?.sort,
|
|
]);
|
|
}
|