From f10e1f667be9934d5e7f457594a056397a47ab5f Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 29 Jun 2023 14:37:13 -0700 Subject: [PATCH 1/3] Close notebook on escape --- .../Sources/App/Views/LibraryTabView.swift | 8 +++++++ .../BookOpen.imageset/BookOpen.png | Bin 0 -> 482 bytes .../BookOpen.imageset/Contents.json | 21 ++++++++++++++++++ .../BookmarksSimple.png | Bin 0 -> 707 bytes .../BookmarksSimple.imageset/Contents.json | 21 ++++++++++++++++++ .../HighlighterCircle.imageset/Contents.json | 21 ++++++++++++++++++ .../HighlighterCircle.png | Bin 0 -> 1270 bytes .../_homeTab.imageset/Contents.json | 12 ---------- .../_homeTab.imageset/home-tab.svg | 3 --- .../_homeTabSelected.imageset/Contents.json | 12 ---------- .../home-tab-selected.svg | 4 ---- .../_moon-stars.imageset/Contents.json | 15 ------------- .../_moon-stars.imageset/moon-stars.svg | 10 --------- .../_moon.imageset/Contents.json | 15 ------------- .../Images.xcassets/_moon.imageset/moon.svg | 6 ----- .../_mountains.imageset/Contents.json | 15 ------------- .../_mountains.imageset/mountains.svg | 9 -------- .../templates/article/HighlightNoteModal.tsx | 5 +++++ 18 files changed, 76 insertions(+), 101 deletions(-) create mode 100644 apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/BookOpen.png create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookOpen.imageset/Contents.json create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/BookmarksSimple.png create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/BookmarksSimple.imageset/Contents.json create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/Contents.json create mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/HighlighterCircle.imageset/HighlighterCircle.png delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/Contents.json delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTab.imageset/home-tab.svg delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/Contents.json delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_homeTabSelected.imageset/home-tab-selected.svg delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/Contents.json delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon-stars.imageset/moon-stars.svg delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/Contents.json delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_moon.imageset/moon.svg delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/Contents.json delete mode 100644 apple/OmnivoreKit/Sources/Views/Images/Images.xcassets/_mountains.imageset/mountains.svg 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 0000000000000000000000000000000000000000..e512b518aed8c2aa92d7242b3279ca2ebc006516 GIT binary patch literal 482 zcmV<80UiE{P)t5 z!!Q(v|3us#GeS0?Y*03!6Tk+*8;X!fUl5OU0>T8a0b&Bm1{oo*R4C@yDPWT#XmV_| z)%he_j^kKge2JU`2!bF80y9yo=28t&V~GEvP+=F3$fNSlw#)Vnl-MzSS9YZVzh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md)v++sG{G<4lxjA7qjZ|s-;;rhi>Eh<1Fpv3c_&QbaU!kxsj9{l>34(j1>FN!%E`hxFNMhU(_CRw zC~c^z7pU!S5%f}m2nerpmX|{0l1@t-YWs)o5TQ2;%Pp>8X8pXmg%OdZohX5jCVm>x z9f0$9NOll?_kAiX?FvZ;J&idRm|=day0=Z7T`Hm<2dL<>pO&@CN^=i>W6zV?Uq5$}#QCxWozj(&ES8yYx5}bg4an?P*224t zQQMss1(>jZ-9bd`E$hz!*w3m`?Z@X)1Ee}aX)FR0cTYjbz&w+J2$&I|xByoDx+PlU zraDWV`*83sPj0qvOOI_tHeOA)08TTx|BUUnh4A^`7b&T71D!L+`RA*vjd7h`^u2;@ g_&#%%HP#669py_N)@G5RfB*mh07*qoM6N<$f`+I{#sB~S literal 0 HcmV?d00001 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() + }} >
{ From 2009ce1b7221b6792196a995e550cda478677049 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 29 Jun 2023 15:03:38 -0700 Subject: [PATCH 2/3] Fix state of articleId preventing labels from saving on reader view --- packages/web/lib/hooks/useSetPageLabels.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/web/lib/hooks/useSetPageLabels.tsx b/packages/web/lib/hooks/useSetPageLabels.tsx index 339fe7a06..41c748720 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,7 +30,8 @@ export const useSetPageLabels = ( const labelsReducer = ( state: { labels: Label[] - throttledSave: (labels: Label[]) => void + articleId: string | undefined + throttledSave: (labels: Label[], articleId: string) => void }, action: { type: string @@ -51,8 +52,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', @@ -69,11 +70,15 @@ export const useSetPageLabels = ( } const debouncedSave = useCallback( - throttle((labels: Label[]) => saveLabels(labels), 2000), + throttle( + (labels: Label[], articleId: string) => saveLabels(labels, articleId), + 2000 + ), [] ) const [labels, dispatchLabels] = useReducer(labelsReducer, { labels: [], + articleId: articleId, throttledSave: debouncedSave, }) From c1448d510d4746f3a2ebccf18e6f5306e4406121 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 29 Jun 2023 15:32:11 -0700 Subject: [PATCH 3/3] Make sure articleId is updated when setting labels --- .../templates/article/SetLabelsControl.tsx | 34 +++++++++++++++++-- packages/web/lib/hooks/useSetPageLabels.tsx | 16 +++++++++ .../web/pages/[username]/[slug]/index.tsx | 4 ++- 3 files changed, 51 insertions(+), 3 deletions(-) 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 41c748720..1205c3e4f 100644 --- a/packages/web/lib/hooks/useSetPageLabels.tsx +++ b/packages/web/lib/hooks/useSetPageLabels.tsx @@ -36,6 +36,7 @@ export const useSetPageLabels = ( action: { type: string labels: Label[] + articleId?: string } ) => { switch (action.type) { @@ -64,6 +65,12 @@ export const useSetPageLabels = ( labels: action.labels, } } + case 'UPDATE_ARTICLE_ID': { + return { + ...state, + articleId: action.articleId, + } + } default: return state } @@ -76,6 +83,15 @@ export const useSetPageLabels = ( ), [] ) + + useEffect(() => { + dispatchLabels({ + type: 'UPDATE_ARTICLE_ID', + labels: [], + articleId: articleId, + }) + }, [articleId]) + const [labels, dispatchLabels] = useReducer(labelsReducer, { labels: [], articleId: articleId, 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')