diff --git a/packages/web/pages/settings/shortcuts.tsx b/packages/web/pages/settings/shortcuts.tsx index 0d8169eba..2d849d9d9 100644 --- a/packages/web/pages/settings/shortcuts.tsx +++ b/packages/web/pages/settings/shortcuts.tsx @@ -4,6 +4,7 @@ import { useEffect, useMemo, useReducer, + useRef, useState, } from 'react' import { applyStoredTheme } from '../../lib/themeUpdater' @@ -35,7 +36,12 @@ import { SavedSearch } from '../../lib/networking/fragments/savedSearchFragment' import { escapeQuotes } from '../../utils/helper' import { useGetLabels } from '../../lib/networking/labels/useLabels' import { useGetSavedSearches } from '../../lib/networking/savedsearches/useSavedSearches' -import { Shortcut } from '../../lib/networking/shortcuts/useShortcuts' +import { + Shortcut, + useResetShortcuts, +} from '../../lib/networking/shortcuts/useShortcuts' +import { ShortcutsTree } from '../../components/templates/ShortcutsTree' +import { TreeApi } from 'react-arborist' type ListAction = 'RESET' | 'ADD_ITEM' | 'REMOVE_ITEM' @@ -147,8 +153,11 @@ export default function Shortcuts(): JSX.Element { Shortcuts - - Use shortcuts to access your most important reads quickly + + Use shortcuts to access your most important reads quickly. You can + create folders for your shortcuts, remove shortcuts, and select + items from your labels, subscriptions, and saved searches to be + added to your shortcuts. { return ( - Saved Searches - {sortedsavedSearches?.map((search) => { - return ( - - ) - })} - + event.preventDefault() + }} + > + {' '} + {search.name} + + {searchSelected(search) ? ( + + ) : ( + + )} + + + ) + })} + - Labels - {sortedLabels.map((label) => { - return ( - - ) - })} - + event.preventDefault() + }} + > + + + {labelSelected(label) ? ( + + ) : ( + + )} + + + ) + })} + - Subscriptions - {sortedSubscriptions.map((subscription) => { - return ( - - ) - })} + event.preventDefault() + }} + > + {subscription.name} + + {subscriptionSelected(subscription) ? ( + + ) : ( + + )} + + + ) + })} + ) } @@ -462,36 +485,49 @@ const AvailableItemButton = (props: AvailableItemButtonProps): JSX.Element => { } const SelectedItems = (props: ListProps): JSX.Element => { + const treeRef = useRef | undefined>(undefined) + const resetShortcuts = useResetShortcuts() + + const createNewFolder = useCallback(async () => { + if (treeRef.current) { + const result = await treeRef.current.create({ + type: 'internal', + index: 0, + }) + } + }, [treeRef]) + return ( Your shortcuts - {props.shortcuts.map((shortcut) => { - return ( - - - {shortcut.name} - - - - - ) - })} + + + ) }