mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-04 00:48:51 -04:00
Add application state hook (#1308)
* Add application state hook Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add docs Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4720f2d36b
commit
829cc2fe48
47 changed files with 149 additions and 195 deletions
|
@ -10,15 +10,14 @@ import { SidebarButton } from './sidebar-button'
|
|||
import { SpecificSidebarEntryProps } from './types'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { EditorPagePathParams } from '../editor-page'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../../redux'
|
||||
import { toggleHistoryEntryPinning } from '../../../redux/history/methods'
|
||||
import { showErrorNotification } from '../../../redux/ui-notifications/methods'
|
||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||
|
||||
export const PinNoteSidebarEntry: React.FC<SpecificSidebarEntryProps> = ({ className, hide }) => {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<EditorPagePathParams>()
|
||||
const history = useSelector((state: ApplicationState) => state.history)
|
||||
const history = useApplicationState((state) => state.history)
|
||||
|
||||
const isPinned = useMemo(() => {
|
||||
const entry = history.find((entry) => entry.identifier === id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue