Merge pull request #3333 from omnivore-app/fix/android-library-labels
Open the labels sheet from the library on Android
This commit is contained in:
@ -83,8 +83,8 @@ const App = () => {
|
||||
articleMutations={{
|
||||
createHighlightMutation: (input) =>
|
||||
mutation('createHighlight', input),
|
||||
deleteHighlightMutation: (highlightId) =>
|
||||
mutation('deleteHighlight', { highlightId }),
|
||||
deleteHighlightMutation: (libraryItemId, highlightId) =>
|
||||
mutation('deleteHighlight', { libraryItemId, highlightId }),
|
||||
mergeHighlightMutation: (input) =>
|
||||
mutation('mergeHighlight', input),
|
||||
updateHighlightMutation: (input) =>
|
||||
|
||||
@ -82,6 +82,7 @@ export function HighlightViewNote(props: HighlightViewNoteProps): JSX.Element {
|
||||
;(async () => {
|
||||
const success = await updateHighlightMutation({
|
||||
annotation: text,
|
||||
libraryItemId: props.targetId,
|
||||
highlightId: props.highlight?.id,
|
||||
})
|
||||
if (success) {
|
||||
|
||||
@ -52,6 +52,7 @@ export function HighlightViewNote(props: HighlightViewNoteProps): JSX.Element {
|
||||
;(async () => {
|
||||
const success = await updateHighlightMutation({
|
||||
annotation: text,
|
||||
libraryItemId: props.targetId,
|
||||
highlightId: props.highlight?.id,
|
||||
})
|
||||
if (success) {
|
||||
|
||||
@ -310,6 +310,7 @@ export default function EpubContainer(props: EpubContainerProps): JSX.Element {
|
||||
{noteTarget && (
|
||||
<HighlightNoteModal
|
||||
highlight={noteTarget}
|
||||
libraryItemId={props.article.id}
|
||||
author={props.article.author ?? ''}
|
||||
title={props.article.title}
|
||||
onUpdate={(highlight: Highlight) => {
|
||||
|
||||
@ -16,6 +16,7 @@ type HighlightNoteModalProps = {
|
||||
author: string
|
||||
title: string
|
||||
highlight?: Highlight
|
||||
libraryItemId: string
|
||||
onUpdate: (updatedHighlight: Highlight) => void
|
||||
onOpenChange: (open: boolean) => void
|
||||
createHighlightForNote?: (note?: string) => Promise<Highlight | undefined>
|
||||
@ -38,6 +39,7 @@ export function HighlightNoteModal(
|
||||
const saveNoteChanges = useCallback(async () => {
|
||||
if (noteContent != props.highlight?.annotation && props.highlight?.id) {
|
||||
const result = await updateHighlightMutation({
|
||||
libraryItemId: props.libraryItemId,
|
||||
highlightId: props.highlight?.id,
|
||||
annotation: noteContent,
|
||||
color: props.highlight?.color,
|
||||
|
||||
@ -187,7 +187,10 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
||||
}
|
||||
|
||||
const didDeleteHighlight =
|
||||
await props.articleMutations.deleteHighlightMutation(highlightId)
|
||||
await props.articleMutations.deleteHighlightMutation(
|
||||
props.articleId,
|
||||
highlightId
|
||||
)
|
||||
|
||||
if (didDeleteHighlight) {
|
||||
removeHighlights(
|
||||
@ -222,6 +225,7 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
||||
updateHighlightsCallback(highlight)
|
||||
;(async () => {
|
||||
const update = await props.articleMutations.updateHighlightMutation({
|
||||
libraryItemId: props.articleId,
|
||||
highlightId: highlight.id,
|
||||
color: color,
|
||||
})
|
||||
@ -705,6 +709,7 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
||||
const annotation = event.annotation ?? ''
|
||||
|
||||
const result = await props.articleMutations.updateHighlightMutation({
|
||||
libraryItemId: props.articleId,
|
||||
highlightId: focusedHighlight.id,
|
||||
annotation: event.annotation ?? '',
|
||||
})
|
||||
@ -788,6 +793,7 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
||||
highlight={highlightModalAction.highlight}
|
||||
author={props.articleAuthor}
|
||||
title={props.articleTitle}
|
||||
libraryItemId={props.articleId}
|
||||
onUpdate={updateHighlightsCallback}
|
||||
onOpenChange={() =>
|
||||
setHighlightModalAction({ highlightModalAction: 'none' })
|
||||
|
||||
@ -76,6 +76,7 @@ export function NotebookContent(props: NotebookContentProps): JSX.Element {
|
||||
(note: Highlight, text: string, startTime: Date) => {
|
||||
;(async () => {
|
||||
const result = await updateHighlightMutation({
|
||||
libraryItemId: props.item.id,
|
||||
highlightId: note.id,
|
||||
annotation: text,
|
||||
})
|
||||
@ -195,7 +196,7 @@ export function NotebookContent(props: NotebookContentProps): JSX.Element {
|
||||
highlights
|
||||
?.filter((h) => h.type === 'NOTE')
|
||||
.forEach(async (h) => {
|
||||
const result = await deleteHighlightMutation(h.id)
|
||||
const result = await deleteHighlightMutation(props.item.id, h.id)
|
||||
if (!result) {
|
||||
showErrorToast('Error deleting note')
|
||||
}
|
||||
@ -325,6 +326,7 @@ export function NotebookContent(props: NotebookContentProps): JSX.Element {
|
||||
;(async () => {
|
||||
const highlightId = showConfirmDeleteHighlightId
|
||||
const success = await deleteHighlightMutation(
|
||||
props.item.id,
|
||||
showConfirmDeleteHighlightId
|
||||
)
|
||||
mutate()
|
||||
|
||||
@ -113,7 +113,7 @@ export default function PdfArticleContainer(
|
||||
.delete(annotation)
|
||||
.then(() => {
|
||||
if (annotationId) {
|
||||
return deleteHighlightMutation(annotationId)
|
||||
return deleteHighlightMutation(props.article.id, annotationId)
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
@ -229,7 +229,7 @@ export default function PdfArticleContainer(
|
||||
}
|
||||
const annotationId = annotationOmnivoreId(annotation)
|
||||
if (annotationId) {
|
||||
await deleteHighlightMutation(annotationId)
|
||||
await deleteHighlightMutation(props.article.id, annotationId)
|
||||
}
|
||||
})
|
||||
|
||||
@ -512,7 +512,7 @@ export default function PdfArticleContainer(
|
||||
const storedId = annotationOmnivoreId(annotation)
|
||||
if (storedId == annotationId) {
|
||||
await instance.delete(annotation)
|
||||
await deleteHighlightMutation(annotationId)
|
||||
await deleteHighlightMutation(props.article.id, annotationId)
|
||||
|
||||
const highlightIdx = highlightsRef.current.findIndex((value) => {
|
||||
return value.id == annotationId
|
||||
@ -576,6 +576,7 @@ export default function PdfArticleContainer(
|
||||
{noteTarget && (
|
||||
<HighlightNoteModal
|
||||
highlight={noteTarget}
|
||||
libraryItemId={props.article.id}
|
||||
author={props.article.author ?? ''}
|
||||
title={props.article.title}
|
||||
onUpdate={(highlight: Highlight) => {
|
||||
|
||||
@ -8,7 +8,10 @@ export type ArticleMutations = {
|
||||
createHighlightMutation: (
|
||||
input: CreateHighlightInput
|
||||
) => Promise<Highlight | undefined>
|
||||
deleteHighlightMutation: (highlightId: string) => Promise<boolean>
|
||||
deleteHighlightMutation: (
|
||||
libraryItemId: string,
|
||||
highlightId: string
|
||||
) => Promise<boolean>
|
||||
mergeHighlightMutation: (
|
||||
input: MergeHighlightInput
|
||||
) => Promise<Highlight | undefined>
|
||||
|
||||
@ -2,6 +2,7 @@ import { gql } from 'graphql-request'
|
||||
import { gqlFetcher } from '../networkHelpers'
|
||||
|
||||
export async function deleteHighlightMutation(
|
||||
libraryItemId: string,
|
||||
highlightId: string
|
||||
): Promise<boolean> {
|
||||
const mutation = gql`
|
||||
|
||||
@ -3,6 +3,7 @@ import { gqlFetcher } from '../networkHelpers'
|
||||
|
||||
export type UpdateHighlightInput = {
|
||||
highlightId: string
|
||||
libraryItemId?: string
|
||||
annotation?: string
|
||||
sharedAt?: string
|
||||
color?: string
|
||||
|
||||
Reference in New Issue
Block a user