From eb31288e413334850a569fa0204a70b9fe6f790c Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 3 May 2022 10:26:43 -0700 Subject: [PATCH 01/31] Fix params to saveUrl on iOS --- .../Sources/Services/DataService/Mutations/SaveUrl.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveUrl.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveUrl.swift index 39e9b6b0b..84a48df2b 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveUrl.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveUrl.swift @@ -12,9 +12,9 @@ public extension DataService { } let input = InputObjects.SaveUrlInput( - clientRequestId: pageScrapePayload.url, + clientRequestId: requestId, source: "ios-url", - url: requestId + url: pageScrapePayload.url ) let selection = Selection { From 6061f2927b01f2b11cc1614a0caf395197b27703 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 8 Apr 2022 10:25:29 +0800 Subject: [PATCH 02/31] update web to call new search endpoint for pages --- .../templates/homeFeed/HomeFeedContainer.tsx | 18 ++-- .../queries/useGetLibraryItemsQuery.tsx | 93 ++++++++++++++----- 2 files changed, 77 insertions(+), 34 deletions(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 916f02d05..04f73a6ad 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -112,23 +112,23 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { // eslint-disable-next-line react-hooks/exhaustive-deps }, [setQueryInputs, router.isReady, router.query]) - const { articlesPages, size, setSize, isValidating, performActionOnItem } = + const { itemsPages, size, setSize, isValidating, performActionOnItem } = useGetLibraryItemsQuery(queryInputs) const hasMore = useMemo(() => { - if (!articlesPages) { + if (!itemsPages) { return false } - return articlesPages[articlesPages.length - 1].articles.pageInfo.hasNextPage - }, [articlesPages]) + return itemsPages[itemsPages.length - 1].search.pageInfo.hasNextPage + }, [itemsPages]) const libraryItems = useMemo(() => { const items = - articlesPages?.flatMap((ad) => { - return ad.articles.edges + itemsPages?.flatMap((ad) => { + return ad.search.edges }) || [] return items - }, [articlesPages, performActionOnItem]) + }, [itemsPages, performActionOnItem]) const handleFetchMore = useCallback(() => { if (isValidating || !hasMore) { @@ -440,8 +440,8 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { setSize(size + 1) }} hasMore={hasMore} - hasData={!!articlesPages} - totalItems={articlesPages?.[0].articles.pageInfo.totalCount || 0} + hasData={!!itemsPages} + totalItems={itemsPages?.[0].search.pageInfo.totalCount || 0} isValidating={isValidating} shareTarget={shareTarget} setShareTarget={setShareTarget} diff --git a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx index d710179d5..51bdbeeb4 100644 --- a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx @@ -2,6 +2,7 @@ import { gql } from 'graphql-request' import useSWRInfinite from 'swr/infinite' import { gqlFetcher } from '../networkHelpers' import type { ArticleFragmentData } from '../fragments/articleFragment' +import { ContentReader } from '../fragments/articleFragment' import { setLinkArchivedMutation } from '../mutations/setLinkArchivedMutation' import { deleteLinkMutation } from '../mutations/deleteLinkMutation' import { articleReadingProgressMutation } from '../mutations/articleReadingProgressMutation' @@ -16,8 +17,8 @@ export type LibraryItemsQueryInput = { } type LibraryItemsQueryResponse = { - articlesPages?: LibraryItemsData[] - articlesDataError?: unknown + itemsPages?: LibraryItemsData[] + itemsDataError?: unknown isLoading: boolean isValidating: boolean size: number @@ -36,7 +37,7 @@ type LibraryItemAction = | 'refresh' export type LibraryItemsData = { - articles: LibraryItems + search: LibraryItems } export type LibraryItems = { @@ -50,12 +51,28 @@ export type LibraryItem = { node: LibraryItemNode } -export type LibraryItemNode = ArticleFragmentData & { - description?: string - hasContent: boolean +export type LibraryItemNode = { + id: string + title: string + url: string + author?: string + image?: string + createdAt: string + publishedAt?: string + contentReader?: ContentReader originalArticleUrl: string - sharedComment?: string + readingProgressPercent: number + readingProgressAnchorIndex: number + slug: string + isArchived: boolean + description: string + ownedByViewer: boolean + uploadFileId: string labels?: Label[] + pageId: string + shortId: string + quote: string + annotation: string } export type PageInfo = { @@ -98,6 +115,7 @@ export function useGetLibraryItemsQuery({ cursor, }: LibraryItemsQueryInput): LibraryItemsQueryResponse { const query = gql` +<<<<<<< HEAD query GetArticles( $sharedOnly: Boolean $sort: SortParams @@ -114,11 +132,40 @@ export function useGetLibraryItemsQuery({ includePending: true ) { ... on ArticlesSuccess { +======= + query Search($after: String, $first: Int, $query: String) { + search(first: $first, after: $after, query: $query) { + ... on SearchSuccess { +>>>>>>> 8fc84dbc (update web to call new search endpoint for pages) edges { cursor node { - ...ArticleFields + id + title + slug + url + pageType + contentReader + createdAt + isArchived + readingProgressPercent + readingProgressAnchorIndex + author + image + description + publishedAt + ownedByViewer originalArticleUrl + uploadFileId + labels { + id + name + color + } + pageId + shortId + quote + annotation } } pageInfo { @@ -129,21 +176,19 @@ export function useGetLibraryItemsQuery({ totalCount } } - ... on ArticlesError { + ... on SearchError { errorCodes } } } +<<<<<<< HEAD ${libraryItemFragment} ${labelFragment} +======= +>>>>>>> 8fc84dbc (update web to call new search endpoint for pages) ` const variables = { - sharedOnly: false, - sort: { - order: sortDescending ? 'DESCENDING' : 'ASCENDING', - by: 'UPDATED_TIME', - }, after: cursor, first: limit, query: searchQuery, @@ -162,12 +207,10 @@ export function useGetLibraryItemsQuery({ limit, sortDescending, searchQuery, - pageIndex === 0 - ? undefined - : previousResult.articles.pageInfo.endCursor, + pageIndex === 0 ? undefined : previousResult.search.pageInfo.endCursor, ] }, - (_query, _l, _s, _sq, cursor: string) => { + (_query, _l, _s, _sq, cursor) => { return gqlFetcher(query, { ...variables, after: cursor }, true) }, { revalidateFirstPage: false } @@ -182,7 +225,7 @@ export function useGetLibraryItemsQuery({ // the response in the case of an error. if (!error && responsePages) { const errors = responsePages.filter( - (d) => d.articles.errorCodes && d.articles.errorCodes.length > 0 + (d) => d.search.errorCodes && d.search.errorCodes.length > 0 ) if (errors?.length > 0) { responseError = errors @@ -202,13 +245,13 @@ export function useGetLibraryItemsQuery({ if (!responsePages) { return } - for (const articlesData of responsePages) { - const itemIndex = articlesData.articles.edges.indexOf(item) + for (const searchResults of responsePages) { + const itemIndex = searchResults.search.edges.indexOf(item) if (itemIndex !== -1) { if (typeof mutatedItem === 'undefined') { - articlesData.articles.edges.splice(itemIndex, 1) + searchResults.search.edges.splice(itemIndex, 1) } else { - articlesData.articles.edges[itemIndex] = mutatedItem + searchResults.search.edges[itemIndex] = mutatedItem } break } @@ -313,8 +356,8 @@ export function useGetLibraryItemsQuery({ return { isValidating, - articlesPages: responsePages || undefined, - articlesDataError: responseError, + itemsPages: responsePages || undefined, + itemsDataError: responseError, isLoading: !error && !data, performActionOnItem, size, From 5eff1c05bf06e508c1d515f6270f560b66069733 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 8 Apr 2022 10:27:45 +0800 Subject: [PATCH 03/31] add savedAt and publishedAt date range in search query --- .../templates/homeFeed/LibrarySearchBar.tsx | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx index 6e4f84e3b..5d16ec5de 100644 --- a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx +++ b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx @@ -1,22 +1,30 @@ -import { ReactNode, useEffect } from 'react' -import { useState, useRef } from 'react' +import { ReactNode, useEffect, useRef, useState } from 'react' import { StyledText } from '../../elements/StyledText' import { Box, HStack, VStack } from '../../elements/LayoutPrimitives' import { SearchIcon } from '../../elements/images/SearchIcon' import { theme } from '../../tokens/stitches.config' -import { DropdownOption, Dropdown } from '../../elements/DropdownElements' +import { Dropdown, DropdownOption } from '../../elements/DropdownElements' import { FormInput } from '../../elements/FormElements' import { searchBarCommands } from '../../../lib/keyboardShortcuts/navigationShortcuts' import { useKeyboardShortcuts } from '../../../lib/keyboardShortcuts/useKeyboardShortcuts' import { Button } from '../../elements/Button' import { X } from 'phosphor-react' +import { DateTime } from 'luxon' type LibrarySearchBarProps = { searchTerm?: string applySearchQuery: (searchQuery: string) => void } -type LibraryFilter = 'in:inbox' | 'in:all' | 'in:archive' | 'type:file' +type LibraryFilter = + | 'in:inbox' + | 'in:all' + | 'in:archive' + | 'type:file' + | 'type:highlights' + | `saved:${string}` + +const recentlySavedStartDate = DateTime.now().minus({ days: 7 }).toISODate() const FOCUSED_BOXSHADOW = '0px 0px 2px 2px rgba(255, 234, 159, 0.56)' @@ -153,6 +161,16 @@ export function DropdownFilterMenu( title="Files" hideSeparator /> + props.onFilterChange('type:highlights')} + title="Highlights" + hideSeparator + /> + props.onFilterChange(`saved:${recentlySavedStartDate}`)} + title="Recently Saved" + hideSeparator + /> ) } From b36e8a78d71bdf0dc3f84a1590d59e04cb724efb Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 5 Apr 2022 11:17:20 +0800 Subject: [PATCH 04/31] remove luxon dependency in web --- .../web/components/templates/homeFeed/LibrarySearchBar.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx index 5d16ec5de..f22c34fd7 100644 --- a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx +++ b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx @@ -24,7 +24,10 @@ type LibraryFilter = | 'type:highlights' | `saved:${string}` -const recentlySavedStartDate = DateTime.now().minus({ days: 7 }).toISODate() +// get last week's date +const recentlySavedStartDate = new Date( + new Date().getTime() - 7 * 24 * 60 * 60 * 1000 +).toLocaleDateString('en-US') const FOCUSED_BOXSHADOW = '0px 0px 2px 2px rgba(255, 234, 159, 0.56)' From f68507c0697151bda5aa41187ae8dc1f8986eefd Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 8 Apr 2022 10:28:41 +0800 Subject: [PATCH 05/31] add sort by updated and recently read --- .../web/components/templates/homeFeed/LibrarySearchBar.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx index f22c34fd7..f06618e86 100644 --- a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx +++ b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx @@ -23,6 +23,7 @@ type LibraryFilter = | 'type:file' | 'type:highlights' | `saved:${string}` + | `sort:updated` // get last week's date const recentlySavedStartDate = new Date( @@ -174,6 +175,11 @@ export function DropdownFilterMenu( title="Recently Saved" hideSeparator /> + props.onFilterChange(`sort:updated`)} + title="Recently Read" + hideSeparator + /> ) } From bbb812f196eebfe1c434eb71c4208dc95eea6997 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 3 May 2022 11:08:02 -0700 Subject: [PATCH 06/31] Rebase --- .../queries/useGetLibraryItemsQuery.tsx | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx index 51bdbeeb4..cd57f9ada 100644 --- a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx @@ -115,28 +115,9 @@ export function useGetLibraryItemsQuery({ cursor, }: LibraryItemsQueryInput): LibraryItemsQueryResponse { const query = gql` -<<<<<<< HEAD - query GetArticles( - $sharedOnly: Boolean - $sort: SortParams - $after: String - $first: Int - $query: String - ) { - articles( - sharedOnly: $sharedOnly - sort: $sort - first: $first - after: $after - query: $query - includePending: true - ) { - ... on ArticlesSuccess { -======= query Search($after: String, $first: Int, $query: String) { search(first: $first, after: $after, query: $query) { ... on SearchSuccess { ->>>>>>> 8fc84dbc (update web to call new search endpoint for pages) edges { cursor node { @@ -181,11 +162,6 @@ export function useGetLibraryItemsQuery({ } } } -<<<<<<< HEAD - ${libraryItemFragment} - ${labelFragment} -======= ->>>>>>> 8fc84dbc (update web to call new search endpoint for pages) ` const variables = { From 7d3ad10aa072b85ae5f30cf285eff5d5a49e767c Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 3 May 2022 11:47:30 -0700 Subject: [PATCH 07/31] treat unknown link content status as succeeded (since older items don't return a status) --- .../Queries/ArticleContentQuery.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift index 217010def..f2beed079 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift @@ -54,8 +54,8 @@ extension DataService { } switch fetchedContent.contentStatus { - case .failed, .unknown: - throw BasicError.message(messageText: "content fetch failed") + case .failed: + throw BasicError.message(messageText: "content processing failed") case .processing: do { let retryDelayInNanoSeconds = UInt64(requestCount * 2 * 1_000_000_000) @@ -65,12 +65,16 @@ extension DataService { } catch { throw BasicError.message(messageText: "content fetch failed") } - case .succeeded: + case .succeeded, .unknown: return fetchedContent } } - public func articleContent(username: String, itemID: String, useCache: Bool) async throws -> ArticleContent { + public func articleContent( + username: String, + itemID: String, + useCache: Bool + ) async throws -> ArticleContent { struct ArticleProps { let htmlContent: String let highlights: [InternalHighlight] @@ -122,7 +126,11 @@ extension DataService { switch payload.data { case let .success(result: result): - if let status = result.contentStatus, status == .succeeded { + // Default to suceeded since older links will return a nil status + // (but the content is almost always there) + let status = result.contentStatus ?? .succeeded + + if status == .succeeded { self?.persistArticleContent( htmlContent: result.htmlContent, itemID: itemID, From 5ea67a0bea87525b3e20e9e6ca408ce1670a771c Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 3 May 2022 12:09:32 -0700 Subject: [PATCH 08/31] Pull in new highlight cards --- packages/api/src/elastic/pages.ts | 2 + .../web/components/elements/StyledText.tsx | 4 + .../LibraryCards/HighlightItemCard.tsx | 89 +++++++++++++++++++ .../patterns/LibraryCards/LinkedItemCard.tsx | 5 ++ .../templates/homeFeed/HomeFeedContainer.tsx | 2 +- .../networking/fragments/articleFragment.ts | 10 +++ .../queries/useGetLibraryItemsQuery.tsx | 13 ++- .../web/stories/HighlightItemCard.stories.tsx | 71 +++++++++++++++ 8 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 packages/web/components/patterns/LibraryCards/HighlightItemCard.tsx create mode 100644 packages/web/stories/HighlightItemCard.stories.tsx diff --git a/packages/api/src/elastic/pages.ts b/packages/api/src/elastic/pages.ts index f0a19434a..67a4a5e42 100644 --- a/packages/api/src/elastic/pages.ts +++ b/packages/api/src/elastic/pages.ts @@ -447,6 +447,8 @@ export const searchPages = async ( body, }) + console.log('resopnse', response) + if (response.body.hits.total.value === 0) { return [[], 0] } diff --git a/packages/web/components/elements/StyledText.tsx b/packages/web/components/elements/StyledText.tsx index f5113ffb3..55ef94b5e 100644 --- a/packages/web/components/elements/StyledText.tsx +++ b/packages/web/components/elements/StyledText.tsx @@ -177,3 +177,7 @@ export const StyledImg = styled('img', { export const StyledAnchor = styled('a', { textDecoration: 'none' }) + +export const StyledMark = styled('mark', { + +}) \ No newline at end of file diff --git a/packages/web/components/patterns/LibraryCards/HighlightItemCard.tsx b/packages/web/components/patterns/LibraryCards/HighlightItemCard.tsx new file mode 100644 index 000000000..f3f685ab7 --- /dev/null +++ b/packages/web/components/patterns/LibraryCards/HighlightItemCard.tsx @@ -0,0 +1,89 @@ +import { styled } from '@stitches/react' +import { VStack, HStack } from '../../elements/LayoutPrimitives' +import { StyledMark, StyledText } from '../../elements/StyledText' +import { LinkedItemCardAction, LinkedItemCardProps } from './CardTypes' + +export interface HighlightItemCardProps + extends Pick { + handleAction: (action: LinkedItemCardAction) => void +} + +export const PreviewImage = styled('img', { + objectFit: 'cover', + cursor: 'pointer', +}) + +export function HighlightItemCard(props: HighlightItemCardProps): JSX.Element { + return ( + { + props.handleAction('showDetail') + }} + > + + + {props.item.quote} + + + + {props.item.image && ( + { + ;(e.target as HTMLElement).style.display = 'none' + }} + /> + )} + + {props.item.title + .substring(0, 50) + .concat(props.item.title.length > 50 ? '...' : '')} + + + + ) +} diff --git a/packages/web/components/patterns/LibraryCards/LinkedItemCard.tsx b/packages/web/components/patterns/LibraryCards/LinkedItemCard.tsx index 12a4a4be7..0b201184d 100644 --- a/packages/web/components/patterns/LibraryCards/LinkedItemCard.tsx +++ b/packages/web/components/patterns/LibraryCards/LinkedItemCard.tsx @@ -1,6 +1,8 @@ import { GridLinkedItemCard } from './GridLinkedItemCard' import { ListLinkedItemCard } from './ListLinkedItemCard' import type { LinkedItemCardProps } from './CardTypes' +import { HighlightItemCard } from './HighlightItemCard' +import { PageType } from '../../../lib/networking/fragments/articleFragment' const siteName = (originalArticleUrl: string, itemUrl: string): string => { try { @@ -15,6 +17,9 @@ const siteName = (originalArticleUrl: string, itemUrl: string): string => { export function LinkedItemCard(props: LinkedItemCardProps): JSX.Element { const originText = siteName(props.item.originalArticleUrl, props.item.url) + if (props.item.pageType === PageType.HIGHLIGHTS) { + return + } if (props.layout == 'LIST_LAYOUT') { return } else { diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 04f73a6ad..faad41b5e 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -53,7 +53,7 @@ const timeZoneHourDiff = -new Date().getTimezoneOffset() / 60 const SAVED_SEARCHES: Record = { Inbox: `in:inbox`, 'Read Later': `in:inbox -label:Newsletter`, - Highlighted: `in:inbox has:highlights`, + Highlights: `type:highlights`, Today: `in:inbox saved:${ new Date(new Date().getTime() - 24 * 3600000).toISOString().split('T')[0] }Z${timeZoneHourDiff.toLocaleString('en-US', { diff --git a/packages/web/lib/networking/fragments/articleFragment.ts b/packages/web/lib/networking/fragments/articleFragment.ts index 59794687b..a8cc4636a 100644 --- a/packages/web/lib/networking/fragments/articleFragment.ts +++ b/packages/web/lib/networking/fragments/articleFragment.ts @@ -30,6 +30,16 @@ export enum State { FAILED = 'FAILED', } +export enum PageType { + ARTICLE = 'ARTICLE', + BOOK = 'BOOK', + FILE = 'FILE', + PROFILE = 'PROFILE', + WEBSITE = 'WEBSITE', + HIGHLIGHTS = 'HIGHLIGHTS', + UNKNOWN = 'UNKNOWN', +} + export type ArticleFragmentData = { id: string title: string diff --git a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx index cd57f9ada..fefa32b22 100644 --- a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx @@ -1,7 +1,7 @@ import { gql } from 'graphql-request' import useSWRInfinite from 'swr/infinite' import { gqlFetcher } from '../networkHelpers' -import type { ArticleFragmentData } from '../fragments/articleFragment' +import type { ArticleFragmentData, PageType, State } from '../fragments/articleFragment' import { ContentReader } from '../fragments/articleFragment' import { setLinkArchivedMutation } from '../mutations/setLinkArchivedMutation' import { deleteLinkMutation } from '../mutations/deleteLinkMutation' @@ -73,6 +73,8 @@ export type LibraryItemNode = { shortId: string quote: string annotation: string + state: State + pageType: PageType } export type PageInfo = { @@ -195,6 +197,8 @@ export function useGetLibraryItemsQuery({ let responseError = error let responsePages = data as LibraryItemsData[] | undefined + console.log('data', data) + // We need to check the response errors here and return the error // it will be nested in the data pages, if there is one error, // we invalidate the data and return the error. We also zero out @@ -330,7 +334,8 @@ export function useGetLibraryItemsQuery({ } } - return { + + const res = { isValidating, itemsPages: responsePages || undefined, itemsDataError: responseError, @@ -339,4 +344,8 @@ export function useGetLibraryItemsQuery({ size, setSize, } + + console.log('itemsPages', responsePages, 'error:', responseError) + + return res } diff --git a/packages/web/stories/HighlightItemCard.stories.tsx b/packages/web/stories/HighlightItemCard.stories.tsx new file mode 100644 index 000000000..260338eb4 --- /dev/null +++ b/packages/web/stories/HighlightItemCard.stories.tsx @@ -0,0 +1,71 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react' +import { HighlightItemCard, HighlightItemCardProps } from '../components/patterns/LibraryCards/HighlightItemCard' +import { updateThemeLocally } from '../lib/themeUpdater' +import { ThemeId } from '../components/tokens/stitches.config' +import { PageType, State } from '../lib/networking/fragments/articleFragment' + +export default { + title: 'Components/HighlightItemCard', + component: HighlightItemCard, + argTypes: { + item: { + description: 'The highlight.', + }, + handleAction: { + description: 'Action that fires on click.' + } + } +} as ComponentMeta + +const highlight: HighlightItemCardProps = { + handleAction: () => console.log('Handling Action'), + item:{ + id: "nnnnn", + shortId: "shortId", + quote: "children not only participate in herding work, but are also encouraged to act independently in most other areas of life. They have a say in deciding when to eat, when to sleep, and what to wear, even at temperatures of -30C (-22F).", + annotation: "Okay… this is wild! I love this independence. Wondering how I can reponsibly instill this type of indepence in my own kids…", + createdAt: '', + description: '', + isArchived: false, + originalArticleUrl: 'https://example.com', + ownedByViewer: true, + pageId: '1', + readingProgressAnchorIndex: 12, + readingProgressPercent: 50, + slug: 'slug', + title: "This is a title", + uploadFileId: '1', + url: 'https://example.com', + author: 'Author', + image: 'https://logos-world.net/wp-content/uploads/2021/11/Unity-New-Logo.png', + state: State.SUCCEEDED, + pageType: PageType.HIGHLIGHTS, + }, +} + +const Template = (props: HighlightItemCardProps) => + +export const LightHighlightItemCard: ComponentStory< + typeof HighlightItemCard +> = (args: any) => { + updateThemeLocally(ThemeId.Light) + return ( +