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:
Jackson Harper
2024-01-09 19:24:13 +08:00
committed by GitHub
30 changed files with 422 additions and 229 deletions

View File

@ -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) =>

View File

@ -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) {

View File

@ -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) {

View File

@ -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) => {

View File

@ -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,

View File

@ -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' })

View File

@ -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()

View File

@ -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) => {

View File

@ -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>

View File

@ -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`

View File

@ -3,6 +3,7 @@ import { gqlFetcher } from '../networkHelpers'
export type UpdateHighlightInput = {
highlightId: string
libraryItemId?: string
annotation?: string
sharedAt?: string
color?: string