From 1784edefafc874dc1e0f1f916716243d4f07c8c5 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 25 Mar 2022 14:17:02 -0700 Subject: [PATCH] Remove unused imports, use a single Label fragment --- .../templates/article/ArticleContainer.tsx | 3 --- .../templates/article/HighlightsLayer.tsx | 2 -- .../lib/networking/fragments/labelFragment.ts | 1 + .../lib/networking/queries/useGetLabelsQuery.tsx | 16 +++------------- .../queries/useGetLibraryItemsQuery.tsx | 2 +- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/packages/web/components/templates/article/ArticleContainer.tsx b/packages/web/components/templates/article/ArticleContainer.tsx index 58c7ccd8f..2976227a9 100644 --- a/packages/web/components/templates/article/ArticleContainer.tsx +++ b/packages/web/components/templates/article/ArticleContainer.tsx @@ -10,11 +10,8 @@ import { MutableRefObject, useEffect, useState } from 'react' import { ReportIssuesModal } from './ReportIssuesModal' import { reportIssueMutation } from '../../../lib/networking/mutations/reportIssueMutation' import { ArticleHeaderToolbar } from './ArticleHeaderToolbar' -import { ShareArticleModal } from './ShareArticleModal' import { userPersonalizationMutation } from '../../../lib/networking/mutations/userPersonalizationMutation' -import { webBaseURL } from '../../../lib/appConfig' import { updateThemeLocally } from '../../../lib/themeUpdater' -import { EditLabelsModal } from './EditLabelsModal' import { ArticleMutations } from '../../../lib/articleActions' type ArticleContainerProps = { diff --git a/packages/web/components/templates/article/HighlightsLayer.tsx b/packages/web/components/templates/article/HighlightsLayer.tsx index f3a705580..3d19c33ff 100644 --- a/packages/web/components/templates/article/HighlightsLayer.tsx +++ b/packages/web/components/templates/article/HighlightsLayer.tsx @@ -3,8 +3,6 @@ import { makeHighlightStartEndOffset } from '../../../lib/highlights/highlightGe import type { HighlightLocation } from '../../../lib/highlights/highlightGenerator' import { useSelection } from '../../../lib/highlights/useSelection' import type { Highlight } from '../../../lib/networking/fragments/highlightFragment' -import { shareHighlightToFeedMutation } from '../../../lib/networking/mutations/shareHighlightToFeedMutation' -import { shareHighlightCommentMutation } from '../../../lib/networking/mutations/updateShareHighlightCommentMutation' import { highlightIdAttribute, highlightNoteIdAttribute, diff --git a/packages/web/lib/networking/fragments/labelFragment.ts b/packages/web/lib/networking/fragments/labelFragment.ts index a3ed216cb..837019fa7 100644 --- a/packages/web/lib/networking/fragments/labelFragment.ts +++ b/packages/web/lib/networking/fragments/labelFragment.ts @@ -6,6 +6,7 @@ export const labelFragment = gql` name color description + createdAt } ` diff --git a/packages/web/lib/networking/queries/useGetLabelsQuery.tsx b/packages/web/lib/networking/queries/useGetLabelsQuery.tsx index d132d3042..211c53178 100644 --- a/packages/web/lib/networking/queries/useGetLabelsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLabelsQuery.tsx @@ -1,5 +1,6 @@ import { gql } from 'graphql-request' import useSWR from 'swr' +import { Label, labelFragment } from '../fragments/labelFragment' import { publicGqlFetcher } from '../networkHelpers' type LabelsQueryResponse = { @@ -16,25 +17,13 @@ type LabelsData = { labels?: unknown } -export type Label = { - id: string - name: string - color: string - description?: string - createdAt: Date -} - export function useGetLabelsQuery(): LabelsQueryResponse { const query = gql` query GetLabels { labels { ... on LabelsSuccess { labels { - id - name - color - description - createdAt + ...LabelFields } } ... on LabelsError { @@ -42,6 +31,7 @@ export function useGetLabelsQuery(): LabelsQueryResponse { } } } + ${labelFragment} ` const { data, mutate, error, isValidating } = useSWR(query, publicGqlFetcher) diff --git a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx index 70a66ca71..3a761076e 100644 --- a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx @@ -6,7 +6,7 @@ import { articleFragment } from '../fragments/articleFragment' import { setLinkArchivedMutation } from '../mutations/setLinkArchivedMutation' import { deleteLinkMutation } from '../mutations/deleteLinkMutation' import { articleReadingProgressMutation } from '../mutations/articleReadingProgressMutation' -import { Label } from './useGetLabelsQuery' +import { Label } from './../fragments/labelFragment' import { showErrorToast, showSuccessToast } from '../../toastHelpers' export type LibraryItemsQueryInput = {