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 (
-
+ )
+ })}
+
- Labels
- {sortedLabels.map((label) => {
- return (
- {
- const item: Shortcut = {
- id: label.id,
- type: 'label',
- label: label,
- section: 'library',
- name: label.name,
- filter: `label:\"${escapeQuotes(label.name)}\"`,
- }
- props.dispatchList({
- item,
- type: labelSelected(label) ? 'REMOVE_ITEM' : 'ADD_ITEM',
- })
+ Labels
+ {sortedLabels.map((label) => {
+ return (
+ {
+ const item: Shortcut = {
+ id: label.id,
+ type: 'label',
+ label: label,
+ section: 'library',
+ name: label.name,
+ filter: `label:\"${escapeQuotes(label.name)}\"`,
+ }
+ props.dispatchList({
+ item,
+ type: labelSelected(label) ? 'REMOVE_ITEM' : 'ADD_ITEM',
+ })
- event.preventDefault()
- }}
- >
-
-
- {labelSelected(label) ? (
-
- ) : (
-
- )}
-
-
- )
- })}
-
+ event.preventDefault()
+ }}
+ >
+
+
+ {labelSelected(label) ? (
+
+ ) : (
+
+ )}
+
+
+ )
+ })}
+
- Subscriptions
- {sortedSubscriptions.map((subscription) => {
- return (
- {
- const item: Shortcut = {
- id: subscription.id,
- section: 'subscriptions',
- name: subscription.name,
- icon: subscription.icon,
- type:
- subscription.type == SubscriptionType.NEWSLETTER
- ? 'newsletter'
- : 'feed',
- filter:
- subscription.type == SubscriptionType.NEWSLETTER
- ? `subscription:\"${escapeQuotes(subscription.name)}\"`
- : `rss:\"${subscription.url}\"`,
- }
- props.dispatchList({
- item,
- type: subscriptionSelected(subscription)
- ? 'REMOVE_ITEM'
- : 'ADD_ITEM',
- })
+ Subscriptions
+ {sortedSubscriptions.map((subscription) => {
+ return (
+ {
+ const item: Shortcut = {
+ id: subscription.id,
+ section: 'subscriptions',
+ name: subscription.name,
+ icon: subscription.icon,
+ type:
+ subscription.type == SubscriptionType.NEWSLETTER
+ ? 'newsletter'
+ : 'feed',
+ filter:
+ subscription.type == SubscriptionType.NEWSLETTER
+ ? `subscription:\"${escapeQuotes(subscription.name)}\"`
+ : `rss:\"${subscription.url}\"`,
+ }
+ props.dispatchList({
+ item,
+ type: subscriptionSelected(subscription)
+ ? 'REMOVE_ITEM'
+ : 'ADD_ITEM',
+ })
- event.preventDefault()
- }}
- >
- {subscription.name}
-
- {subscriptionSelected(subscription) ? (
-
- ) : (
-
- )}
-
-
- )
- })}
+ 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}
-
-
-
-
- )
- })}
+
+
+
)
}