diff --git a/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.module.css b/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.module.css new file mode 100644 index 000000000..ffc3e1545 --- /dev/null +++ b/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.module.css @@ -0,0 +1,9 @@ +/* + * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +.highlighted { + color: #b51f08 !important; +} diff --git a/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.tsx b/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.tsx index 825c6b6bc..647e4c6e4 100644 --- a/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.tsx +++ b/src/components/editor-page/sidebar/specific-sidebar-entries/pin-note-sidebar-entry.tsx @@ -11,6 +11,7 @@ import type { SpecificSidebarEntryProps } from '../types' import { toggleHistoryEntryPinning } from '../../../../redux/history/methods' import { showErrorNotification } from '../../../../redux/ui-notifications/methods' import { useApplicationState } from '../../../../hooks/common/use-application-state' +import styles from './pin-note-sidebar-entry.module.css' /** * Sidebar entry button that toggles the pinned status of the current note in the history. @@ -40,7 +41,7 @@ export const PinNoteSidebarEntry: React.FC = ({ class icon={'thumb-tack'} hide={hide} onClick={onPinClicked} - className={`${className ?? ''} ${isPinned ? 'icon-highlighted' : ''}`}> + className={`${className ?? ''} ${isPinned ? styles['highlighted'] : ''}`}> ) diff --git a/src/redux/history/methods.ts b/src/redux/history/methods.ts index a2855a7af..7cb4d4106 100644 --- a/src/redux/history/methods.ts +++ b/src/redux/history/methods.ts @@ -106,15 +106,15 @@ export const toggleHistoryEntryPinning = async (noteId: string): Promise = if (!entryToUpdate) { return Promise.reject(`History entry for note '${noteId}' not found`) } - if (entryToUpdate.pinStatus === undefined) { - entryToUpdate.pinStatus = false + const updatedEntry = { + ...entryToUpdate, + pinStatus: !entryToUpdate.pinStatus } - entryToUpdate.pinStatus = !entryToUpdate.pinStatus if (entryToUpdate.origin === HistoryEntryOrigin.LOCAL) { - updateLocalHistoryEntry(noteId, entryToUpdate) + updateLocalHistoryEntry(noteId, updatedEntry) } else { - await updateRemoteHistoryEntryPinStatus(noteId, entryToUpdate.pinStatus) - updateHistoryEntryRedux(noteId, entryToUpdate) + await updateRemoteHistoryEntryPinStatus(noteId, updatedEntry.pinStatus) + updateHistoryEntryRedux(noteId, updatedEntry) } }