Skip to content

Commit

Permalink
Merge pull request #2305 from stakwork/feature/summary-to-sidebar
Browse files Browse the repository at this point in the history
feat: add summary to sidebar
  • Loading branch information
Rassl authored Oct 7, 2024
2 parents 5874ca0 + bbafe3c commit 6bec15b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 27 deletions.
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

0 comments on commit 6bec15b

Please sign in to comment.