Fix the library select and mark read/unread shortcuts
This commit is contained in:
@ -4,13 +4,16 @@ import { ReactNode, useEffect, useState, useCallback } from 'react'
|
||||
import { useGetViewerQuery } from '../../lib/networking/queries/useGetViewerQuery'
|
||||
import { navigationCommands } from '../../lib/keyboardShortcuts/navigationShortcuts'
|
||||
import { useKeyboardShortcuts } from '../../lib/keyboardShortcuts/useKeyboardShortcuts'
|
||||
import { useRouter } from 'next/router'
|
||||
import { NextRouter, useRouter } from 'next/router'
|
||||
import { ConfirmationModal } from '../patterns/ConfirmationModal'
|
||||
import { KeyboardShortcutListModal } from './KeyboardShortcutListModal'
|
||||
import { setupAnalytics } from '../../lib/analytics'
|
||||
import { primaryCommands } from '../../lib/keyboardShortcuts/navigationShortcuts'
|
||||
import { logout } from '../../lib/logout'
|
||||
import { useApplyLocalTheme } from '../../lib/hooks/useApplyLocalTheme'
|
||||
import { updateTheme } from '../../lib/themeUpdater'
|
||||
import { Priority, useRegisterActions } from 'kbar'
|
||||
import { ThemeId } from '../tokens/stitches.config'
|
||||
|
||||
type PrimaryLayoutProps = {
|
||||
children: ReactNode
|
||||
@ -42,6 +45,38 @@ export function PrimaryLayout(props: PrimaryLayoutProps): JSX.Element {
|
||||
})
|
||||
)
|
||||
|
||||
useRegisterActions(
|
||||
[
|
||||
{
|
||||
id: 'home',
|
||||
section: 'Navigation',
|
||||
name: 'Go to Home (Library) ',
|
||||
shortcut: ['g h'],
|
||||
keywords: 'go home',
|
||||
perform: () => router?.push('/home'),
|
||||
},
|
||||
{
|
||||
id: 'lightTheme',
|
||||
section: 'Preferences',
|
||||
name: 'Change theme (light) ',
|
||||
shortcut: ['v', 'l'],
|
||||
keywords: 'light theme',
|
||||
priority: Priority.LOW,
|
||||
perform: () => updateTheme(ThemeId.Light),
|
||||
},
|
||||
{
|
||||
id: 'darkTheme',
|
||||
section: 'Preferences',
|
||||
name: 'Change theme (dark) ',
|
||||
shortcut: ['v', 'd'],
|
||||
keywords: 'dark theme',
|
||||
priority: Priority.LOW,
|
||||
perform: () => updateTheme(ThemeId.Dark),
|
||||
},
|
||||
],
|
||||
[router]
|
||||
)
|
||||
|
||||
// Attempt to identify the user if they are logged in.
|
||||
useEffect(() => {
|
||||
setupAnalytics(viewerData?.me)
|
||||
|
||||
@ -635,7 +635,7 @@ export function HomeFeedContainer(): JSX.Element {
|
||||
createAction({
|
||||
section: 'Library',
|
||||
name: 'Mark item as read',
|
||||
shortcut: ['m', 'r'],
|
||||
shortcut: ['-'],
|
||||
perform: () => {
|
||||
handleCardAction('mark-read', activeItem)
|
||||
},
|
||||
@ -643,7 +643,7 @@ export function HomeFeedContainer(): JSX.Element {
|
||||
createAction({
|
||||
section: 'Library',
|
||||
name: 'Mark item as unread',
|
||||
shortcut: ['m', 'u'],
|
||||
shortcut: ['_'],
|
||||
perform: () => handleCardAction('mark-unread', activeItem),
|
||||
}),
|
||||
]
|
||||
|
||||
@ -35,9 +35,9 @@ export function searchBarCommands(
|
||||
callback: () => setTimeout(() => actionHandler('focusSearchBar'), 0),
|
||||
},
|
||||
{
|
||||
shortcutKeys: ['x'],
|
||||
shortcutKeys: ['c', 's'],
|
||||
actionDescription: 'Clear search bar',
|
||||
shortcutKeyDescription: 'x',
|
||||
shortcutKeyDescription: 'c then s',
|
||||
callback: () => actionHandler('clearSearch'),
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user