diff --git a/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift b/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift new file mode 100644 index 000000000..0e6f331b8 --- /dev/null +++ b/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Jackson Harper on 6/29/23. +// + +import Foundation diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/BookOpen.png b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/BookOpen.png new file mode 100644 index 000000000..e512b518a Binary files /dev/null and b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/BookOpen.png differ diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/Contents.json new file mode 100644 index 000000000..fe6282129 --- /dev/null +++ b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "BookOpen.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/BookmarksSimple.png b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/BookmarksSimple.png new file mode 100644 index 000000000..e5b2fdd18 Binary files /dev/null and b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/BookmarksSimple.png differ diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/Contents.json new file mode 100644 index 000000000..f33fd33bd --- /dev/null +++ b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "BookmarksSimple.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/Contents.json new file mode 100644 index 000000000..16a80219f --- /dev/null +++ b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "HighlighterCircle.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/HighlighterCircle.png b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/HighlighterCircle.png new file mode 100644 index 000000000..e71fa3e49 Binary files /dev/null and b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/HighlighterCircle.png differ diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/Contents.json deleted file mode 100644 index fe4b9ab76..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "home-tab.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/home-tab.svg b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/home-tab.svg deleted file mode 100644 index 1f75ebdc9..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/home-tab.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/Contents.json deleted file mode 100644 index ea90531ef..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "home-tab-selected.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/home-tab-selected.svg b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/home-tab-selected.svg deleted file mode 100644 index 43315a5d0..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/home-tab-selected.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/Contents.json deleted file mode 100644 index dd565e8a2..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "moon-stars.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/moon-stars.svg b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/moon-stars.svg deleted file mode 100644 index 15a6ae7d5..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/moon-stars.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/Contents.json deleted file mode 100644 index 6ddb81705..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "moon.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/moon.svg b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/moon.svg deleted file mode 100644 index ac7510e86..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/moon.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/Contents.json b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/Contents.json deleted file mode 100644 index b67f93f31..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "mountains.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/mountains.svg b/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/mountains.svg deleted file mode 100644 index 248bbca56..000000000 --- a/apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/mountains.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/packages/web/components/templates/article/HighlightNoteModal.tsx b/packages/web/components/templates/article/HighlightNoteModal.tsx index a2049506e..f933112ab 100644 --- a/packages/web/components/templates/article/HighlightNoteModal.tsx +++ b/packages/web/components/templates/article/HighlightNoteModal.tsx @@ -69,6 +69,11 @@ export function HighlightNoteModal( onPointerDownOutside={(event) => { event.preventDefault() }} + onEscapeKeyDown={(event) => { + props.onOpenChange(false) + event.preventDefault() + event.stopPropagation() + }} >
{ diff --git a/packages/web/components/templates/article/SetLabelsControl.tsx b/packages/web/components/templates/article/SetLabelsControl.tsx index 75b9507dc..94355c61e 100644 --- a/packages/web/components/templates/article/SetLabelsControl.tsx +++ b/packages/web/components/templates/article/SetLabelsControl.tsx @@ -174,6 +174,9 @@ type FooterProps = { filterText: string selectedLabels: Label[] availableLabels: Label[] + + createEnteredLabel: () => Promise + selectEnteredLabel: () => Promise } function Footer(props: FooterProps): JSX.Element { @@ -233,7 +236,17 @@ function Footer(props: FooterProps): JSX.Element { { + switch (textMatch) { + case 'available': + await props.selectEnteredLabel() + return + case 'none': + await props.createEnteredLabel() + return + } + }} > {textMatch === 'available' && ( <> @@ -273,7 +286,6 @@ export function SetLabelsControl(props: SetLabelsControlProps): JSX.Element { const [focusedIndex, setFocusedIndex] = useState(0) useEffect(() => { - console.log('setting focused index: ', inputValue) setFocusedIndex(undefined) }, [inputValue]) @@ -398,6 +410,22 @@ export function SetLabelsControl(props: SetLabelsControlProps): JSX.Element { ] ) + const createEnteredLabel = useCallback(() => { + const _filterText = inputValue + setInputValue('') + return createLabelFromFilterText(_filterText) + }, [inputValue]) + + const selectEnteredLabel = useCallback(() => { + const label = labels.find( + (l: Label) => l.name.toLowerCase() == inputValue.toLowerCase() + ) + if (!label) { + return Promise.resolve() + } + return toggleLabel(label) + }, [labels, inputValue]) + return ( )} diff --git a/packages/web/lib/hooks/useSetPageLabels.tsx b/packages/web/lib/hooks/useSetPageLabels.tsx index 339fe7a06..1205c3e4f 100644 --- a/packages/web/lib/hooks/useSetPageLabels.tsx +++ b/packages/web/lib/hooks/useSetPageLabels.tsx @@ -13,7 +13,7 @@ export type LabelsDispatcher = (action: { export const useSetPageLabels = ( articleId?: string ): [{ labels: Label[] }, LabelsDispatcher] => { - const saveLabels = (labels: Label[]) => { + const saveLabels = (labels: Label[], articleId: string) => { ;(async () => { const labelIds = labels.map((l) => l.id) if (articleId) { @@ -30,11 +30,13 @@ export const useSetPageLabels = ( const labelsReducer = ( state: { labels: Label[] - throttledSave: (labels: Label[]) => void + articleId: string | undefined + throttledSave: (labels: Label[], articleId: string) => void }, action: { type: string labels: Label[] + articleId?: string } ) => { switch (action.type) { @@ -51,8 +53,8 @@ export const useSetPageLabels = ( } } case 'SAVE': { - if (articleId) { - state.throttledSave(action.labels) + if (state.articleId) { + state.throttledSave(action.labels, state.articleId) } else { showErrorToast('Unable to update labels', { position: 'bottom-right', @@ -63,17 +65,36 @@ export const useSetPageLabels = ( labels: action.labels, } } + case 'UPDATE_ARTICLE_ID': { + return { + ...state, + articleId: action.articleId, + } + } default: return state } } const debouncedSave = useCallback( - throttle((labels: Label[]) => saveLabels(labels), 2000), + throttle( + (labels: Label[], articleId: string) => saveLabels(labels, articleId), + 2000 + ), [] ) + + useEffect(() => { + dispatchLabels({ + type: 'UPDATE_ARTICLE_ID', + labels: [], + articleId: articleId, + }) + }, [articleId]) + const [labels, dispatchLabels] = useReducer(labelsReducer, { labels: [], + articleId: articleId, throttledSave: debouncedSave, }) diff --git a/packages/web/pages/[username]/[slug]/index.tsx b/packages/web/pages/[username]/[slug]/index.tsx index f544a7e6a..b631f7660 100644 --- a/packages/web/pages/[username]/[slug]/index.tsx +++ b/packages/web/pages/[username]/[slug]/index.tsx @@ -368,7 +368,9 @@ export default function Home(): JSX.Element { [readerSettings, showHighlightsModal] ) - const [labels, dispatchLabels] = useSetPageLabels(article?.id) + const [labels, dispatchLabels] = useSetPageLabels( + articleData?.article.article?.id + ) if (articleFetchError && articleFetchError.indexOf('NOT_FOUND') > -1) { router.push('/404')