remove starType

This commit is contained in:
hmacr committed 2024-12-05 16:41:55 +05:30
1 parent e45652211c
commit b749f7dd0e
1 file changed
+12 -18
@@ -40,35 +40,29 @@ function StarredLink({ star }: Props) {
const { documentId, collectionId } = star;
const collection = collections.get(collectionId);
const locationSidebarContext = useLocationState();
const starType = star.documentId ? "document" : "collection";
const sidebarContext = starredSidebarContext(
starType === "document" ? star.documentId! : star.collectionId
star.documentId ?? star.collectionId
);
const [expanded, setExpanded] = useState(
(starType === "document"
(star.documentId
? star.documentId === ui.activeDocumentId
: star.collectionId === ui.activeCollectionId) &&
sidebarContext === locationSidebarContext
);
React.useEffect(() => {
if (starType === "document") {
if (
star.documentId === ui.activeDocumentId &&
sidebarContext === locationSidebarContext
) {
setExpanded(true);
}
} else {
if (
star.collectionId === ui.activeCollectionId &&
sidebarContext === locationSidebarContext
) {
setExpanded(true);
}
if (
star.documentId === ui.activeDocumentId &&
sidebarContext === locationSidebarContext
) {
setExpanded(true);
} else if (
star.collectionId === ui.activeCollectionId &&
sidebarContext === locationSidebarContext
) {
setExpanded(true);
}
}, [
starType,
star.documentId,
star.collectionId,
ui.activeDocumentId,