Skip to content

Commit

Permalink
Merge pull request #581 from h3poteto/feat/notification-tag
Browse files Browse the repository at this point in the history
refs #14 Open tag timeline when clicking tag in notifications
  • Loading branch information
h3poteto authored Mar 28, 2023
2 parents 24d48b1 + b355f1a commit dc862e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/timelines/notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const notification = (props: Props) => {
updateStatus={props.updateStatus}
client={props.client}
openMedia={props.openMedia}
setTagDetail={(tag, serverId) => props.setTagDetail(tag, serverId, props.account?.id)}
setAccountDetail={account => props.setAccountDetail(account.id, props.server.id, props.account?.id)}
/>
)
Expand Down
11 changes: 10 additions & 1 deletion src/components/timelines/notification/Reaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { open } from '@tauri-apps/api/shell'

import Time from 'src/components/utils/Time'
import emojify from 'src/utils/emojify'
import { findLink, findAccount, accountMatch, ParsedAccount } from 'src/utils/statusParser'
import { findLink, findAccount, findTag, accountMatch, ParsedAccount } from 'src/utils/statusParser'
import Body from '../status/Body'
import Poll from '../status/Poll'
import { useTranslation } from 'react-i18next'
Expand All @@ -20,6 +20,7 @@ type Props = {
updateStatus: (status: Entity.Status) => void
openMedia: (media: Array<Entity.Attachment>, index: number) => void
setAccountDetail: (account: Entity.Account) => void
setTagDetail: (tag: string, serverId: number) => void
}

const actionIcon = (notification: Entity.Notification) => {
Expand Down Expand Up @@ -177,6 +178,14 @@ const Reaction: React.FC<Props> = props => {
return
}

// Check hashtag
const parsedTag = findTag(e.target as HTMLElement, 'status-body')
if (parsedTag) {
e.preventDefault()
props.setTagDetail(parsedTag, props.server.id)
return
}

// Check link
const url = findLink(e.target as HTMLElement, 'status-body')
if (url) {
Expand Down

0 comments on commit dc862e5

Please sign in to comment.