Skip to content

Commit

Permalink
Fixes for code review
Browse files Browse the repository at this point in the history
  • Loading branch information
riazaia authored and essential-randomness committed Jul 25, 2023
1 parent df7cfb9 commit d0cfb1a
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/components/thread/ThreadSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import {
TagType,
TagsFilterSection,
} from "@bobaboard/ui-components";
import { ThreadPageDetails, usePageDetails } from 'utils/router-utils';

import { DisplayManager } from "components/hooks/useDisplayMananger";
import React from "react";
import { THREAD_VIEW_MODE } from "contexts/ThreadViewContext";
import { UNCATEGORIZED_LABEL } from "utils/thread-utils";
import classnames from "classnames";
import { formatDistanceToNow } from "date-fns";
import { useFilterableContext } from "components/core/feeds/FilterableContext";
import { useCachedLinks } from 'components/hooks/useCachedLinks';
import { useFilterableContext } from "components/core/feeds/FilterableContext";
import { useForceHideIdentity } from "components/hooks/useForceHideIdentity";
import { useThreadContext } from "components/thread/ThreadContext";

Expand All @@ -26,15 +27,26 @@ export interface ThreadSidebarProps {

const ThreadSidebar: React.FC<ThreadSidebarProps> = (props) => {
const { forceHideIdentity } = useForceHideIdentity();
const { threadRoot, categories, contentNotices, parentBoardSlug, threadId } = useThreadContext();
const { threadRoot, categories, contentNotices } = useThreadContext();
const { getLinkToThread } = useCachedLinks();

const linkToThread = getLinkToThread({
// @ts-ignore
slug: parentBoardSlug,
// @ts-ignore
threadId: threadId,
});
const {threadId, slug} = usePageDetails<ThreadPageDetails>();

const linkToThread = getLinkToThread({
slug,
threadId,
view: "thread"
}).href;
const linkToGallery = getLinkToThread({
slug,
threadId,
view: "gallery"
}).href;
const linkToTimeline = getLinkToThread({
slug,
threadId,
view: "timeline"
}).href;

const {
activeCategories,
Expand Down Expand Up @@ -68,23 +80,23 @@ const ThreadSidebar: React.FC<ThreadSidebarProps> = (props) => {
label: "Thread",
link: {
onClick: () => props.onViewChange(THREAD_VIEW_MODE.THREAD),
href: `${linkToThread.href}?thread`
href: `${linkToThread}`
},
},
{
id: THREAD_VIEW_MODE.MASONRY,
label: "Gallery",
link: {
onClick: () => props.onViewChange(THREAD_VIEW_MODE.MASONRY),
href: `${linkToThread.href}?all&gallery`
href: `${linkToGallery}`
},
},
{
id: THREAD_VIEW_MODE.TIMELINE,
label: "Timeline",
link: {
onClick: () => props.onViewChange(THREAD_VIEW_MODE.TIMELINE),
href: `${linkToThread.href}?all&timeline`
href: `${linkToTimeline}`
},
},
]}
Expand Down

0 comments on commit d0cfb1a

Please sign in to comment.