mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix Highlight type attributes
This commit is contained in:
parent
7f8c794dfc
commit
45d4a99d17
3 changed files with 6 additions and 56 deletions
|
|
@ -15,7 +15,6 @@ import { removeHighlights } from '../../../lib/highlights/deleteHighlight'
|
|||
import { createHighlight } from '../../../lib/highlights/createHighlight'
|
||||
import { HighlightNoteModal } from './HighlightNoteModal'
|
||||
import { ShareHighlightModal } from './ShareHighlightModal'
|
||||
import { HighlightPostToFeedModal } from './HighlightPostToFeedModal'
|
||||
import { HighlightsModal } from './HighlightsModal'
|
||||
import { useCanShareNative } from '../../../lib/hooks/useCanShareNative'
|
||||
import toast from 'react-hot-toast'
|
||||
|
|
@ -35,7 +34,7 @@ type HighlightsLayerProps = {
|
|||
articleMutations: ArticleMutations
|
||||
}
|
||||
|
||||
type HighlightModalAction = 'none' | 'addComment' | 'postToFeed' | 'share'
|
||||
type HighlightModalAction = 'none' | 'addComment' | 'share'
|
||||
|
||||
type HighlightActionProps = {
|
||||
highlight?: Highlight
|
||||
|
|
@ -113,32 +112,6 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
[highlights, highlightLocations]
|
||||
)
|
||||
|
||||
const postToFeedCallback = useCallback(
|
||||
async (highlight: Highlight, annotation: string | undefined) => {
|
||||
await shareHighlightToFeedMutation({
|
||||
id: highlight.id,
|
||||
share: highlight.sharedAt == undefined,
|
||||
})
|
||||
|
||||
await shareHighlightCommentMutation({
|
||||
highlightId: highlight.id,
|
||||
annotation,
|
||||
})
|
||||
|
||||
// Toggle the sharedAt field after mutating the highlight
|
||||
const mutatedHighlight = highlight
|
||||
mutatedHighlight.sharedAt = highlight.sharedAt
|
||||
? undefined
|
||||
: new Date().toISOString()
|
||||
mutatedHighlight.annotation = annotation
|
||||
const unmutatedHighlights = highlights.filter(
|
||||
($0) => $0.id !== highlight.id
|
||||
)
|
||||
setHighlights([...unmutatedHighlights, mutatedHighlight])
|
||||
},
|
||||
[highlights]
|
||||
)
|
||||
|
||||
const handleNativeShare = useCallback(
|
||||
(highlightID: string) => {
|
||||
navigator
|
||||
|
|
@ -348,16 +321,6 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
createHighlightCallback('share')
|
||||
}
|
||||
break
|
||||
case 'post':
|
||||
if (focusedHighlight) {
|
||||
setHighlightModalAction({
|
||||
highlight: focusedHighlight,
|
||||
highlightModalAction: 'postToFeed',
|
||||
})
|
||||
} else {
|
||||
createHighlightCallback('postToFeed')
|
||||
}
|
||||
break
|
||||
case 'unshare':
|
||||
console.log('unshare')
|
||||
break // TODO: implement -- need to show confirmation dialog
|
||||
|
|
@ -460,23 +423,6 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
)
|
||||
}
|
||||
|
||||
if (
|
||||
highlightModalAction?.highlightModalAction == 'postToFeed' &&
|
||||
highlightModalAction.highlight
|
||||
) {
|
||||
return (
|
||||
<HighlightPostToFeedModal
|
||||
highlight={highlightModalAction.highlight}
|
||||
author={props.articleAuthor}
|
||||
title={props.articleTitle}
|
||||
onCommit={postToFeedCallback}
|
||||
onOpenChange={() =>
|
||||
setHighlightModalAction({ highlightModalAction: 'none' })
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
highlightModalAction?.highlightModalAction == 'share' &&
|
||||
highlightModalAction.highlight
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { UpdateHighlightInput } from "./networking/mutations/updateHighlightMuta
|
|||
export type ArticleMutations = {
|
||||
createHighlightMutation: (input: CreateHighlightInput) => Promise<Highlight | undefined>
|
||||
deleteHighlightMutation: (highlightId: string) => Promise<boolean>
|
||||
mergeHighlightMutation: (input: MergeHighlightInput) => Promise<MergeHighlightOutput | undefined>
|
||||
mergeHighlightMutation: (input: MergeHighlightInput) => Promise<Highlight | undefined>
|
||||
updateHighlightMutation: (input: UpdateHighlightInput) => Promise<string | undefined>
|
||||
articleReadingProgressMutation: (input: ArticleReadingProgressMutationInput) => Promise<boolean>
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ export const highlightFragment = gql`
|
|||
patch
|
||||
annotation
|
||||
createdByMe
|
||||
updatedAt
|
||||
sharedAt
|
||||
}
|
||||
`
|
||||
|
||||
|
|
@ -22,6 +24,8 @@ export type Highlight = {
|
|||
patch: string
|
||||
annotation?: string
|
||||
createdByMe: boolean
|
||||
updatedAt: string
|
||||
sharedAt: string
|
||||
}
|
||||
|
||||
export type User = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue