Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add summary to sidebar #2305

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/App/SideBar/AiSummary/AiSources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const _AiSources = ({ sourceIds }: Props) => {
image_url: imageUrl,
date,
boost,
episode_title: episodeTitle,
show_title: showTitle,
node_type: nodeType,
text,
Expand All @@ -82,7 +81,6 @@ const _AiSources = ({ sourceIds }: Props) => {
key={index.toString()}
boostCount={boost || 0}
date={date || 0}
episodeTitle={formatDescription(episodeTitle)}
imageUrl={imageUrl || ''}
name={name || ''}
node={n}
Expand Down
3 changes: 0 additions & 3 deletions src/components/App/SideBar/Media/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Flex } from '~/components/common/Flex'
import { useAppStore } from '~/stores/useAppStore'
import { useSelectedNode } from '~/stores/useGraphStore'
import { NodeExtended } from '~/types'
import { formatDescription } from '~/utils/formatDescription'
import { BoostAmt } from '../../Helper/BoostAmt'
import { Description } from '../Description'
import { Episode } from '../Relevance/Episode'
Expand All @@ -28,7 +27,6 @@ export const Media = ({ node }: Props) => {
node_type: nodeType,
id,
show_title: showTitle,
episode_title: episodeTitle,
ref_id: refId,
} = node || selectedNode || {}

Expand All @@ -51,7 +49,6 @@ export const Media = ({ node }: Props) => {
<StyledEpisode
boostCount={boostAmount || 0}
date={date || 0}
episodeTitle={formatDescription(episodeTitle)}
imageUrl={imageUrl}
node={currentNode}
onClick={() => null}
Expand Down
23 changes: 6 additions & 17 deletions src/components/App/SideBar/Relevance/Episode/Default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { useAppStore } from '~/stores/useAppStore'
import { useSchemaStore } from '~/stores/useSchemaStore'
import { NodeExtended } from '~/types'
import { colors } from '~/utils/colors'
import { truncateText } from '~/utils/truncateText'

export type Props = {
boostCount: number
date: number
episodeTitle: string
imageUrl?: string
showTitle?: string
sourceLink?: string
Expand All @@ -24,34 +24,21 @@ export type Props = {
node: NodeExtended
}

export const Default = ({
boostCount,
date,
episodeTitle,
imageUrl,
showTitle,
type,
newName,
sourceLink,
node,
}: Props) => {
export const Default = ({ boostCount, date, imageUrl, showTitle, type, newName, sourceLink, node }: Props) => {
const searchTerm = useAppStore((s) => s.currentSearch)
const { getNodeKeysByType } = useSchemaStore((s) => s)
const descriptionSource = type === 'show' ? showTitle : episodeTitle
const subtitleSource = type === 'show' ? '' : showTitle
const subtitle = highlightSearchTerm(String(subtitleSource), searchTerm) as string

const nodeKeys = type ? (getNodeKeysByType(type) || '').split('-') : []

const { properties = {} } = node

const [titleDraft = '', subtitleDraft = ''] = nodeKeys.map((key) => properties[key] || '')
const [titleDraft = ''] = nodeKeys.map((key) => properties[key] || '')

const nameDraft = titleDraft || newName
const descriptionDraft = subtitleDraft || descriptionSource

const name = highlightSearchTerm(String(nameDraft), searchTerm) as string
const description = highlightSearchTerm(String(descriptionDraft), searchTerm) as string

return (
<Flex align="center" direction="row" justify="center">
Expand All @@ -78,7 +65,9 @@ export const Default = ({
</Flex>

{name && <Description data-testid="episode-name">{name}</Description>}
{description && <Description data-testid="episode-description">{description}</Description>}
{node?.properties?.summary && (
<Description data-testid="episode-description">{truncateText(node?.properties?.summary, 20)}</Description>
)}
<Flex align="center" direction="row" justify="flex-start">
{Boolean(date) && <Date>{moment.unix(date).fromNow()}</Date>}
{Boolean(subtitle) && <Title>{subtitle}</Title>}
Expand Down
3 changes: 0 additions & 3 deletions src/components/App/SideBar/Relevance/Episode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const EpisodeWrapper = styled(Flex).attrs({
export type Props = {
boostCount: number
date: number
episodeTitle: string
imageUrl?: string
showTitle?: string
text?: string
Expand All @@ -58,7 +57,6 @@ export type Props = {
export const Episode = ({
boostCount,
date,
episodeTitle,
imageUrl,
showTitle,
type,
Expand All @@ -85,7 +83,6 @@ export const Episode = ({
<Default
boostCount={boostCount}
date={date}
episodeTitle={episodeTitle}
imageUrl={imageUrl}
newName={newName}
node={node}
Expand Down
2 changes: 0 additions & 2 deletions src/components/App/SideBar/Relevance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const _Relevance = ({ isSearchResult }: Props) => {
image_url: imageUrl,
date,
boost,
episode_title: episodeTitle,
show_title: showTitle,
node_type: nodeType,
text,
Expand All @@ -100,7 +99,6 @@ const _Relevance = ({ isSearchResult }: Props) => {
key={adaptedNode.ref_id}
boostCount={boost || 0}
date={date || 0}
episodeTitle={formatDescription(episodeTitle)}
imageUrl={imageUrl || ''}
name={name || ''}
node={n}
Expand Down
Loading