refactor: readonly note content

This commit is contained in:
Aman Harwara
2023-06-26 16:12:17 +05:30
parent 28a52cb998
commit 59fbf6f4c3
7 changed files with 43 additions and 53 deletions

View File

@@ -1,26 +1,19 @@
import RevisionContentLocked from './RevisionContentLocked'
import SelectedRevisionContent from './SelectedRevisionContent'
import { observer } from 'mobx-react-lite'
import { WebApplication } from '@/Application/WebApplication'
import { NotesController } from '@/Controllers/NotesController/NotesController'
import { SubscriptionController } from '@/Controllers/Subscription/SubscriptionController'
import { NoteHistoryController, RevisionContentState } from '@/Controllers/NoteHistory/NoteHistoryController'
import Spinner from '@/Components/Spinner/Spinner'
import { ReadonlyNoteContent } from '../NoteView/ReadonlyNoteContent'
import { SNNote } from '@standardnotes/snjs'
type Props = {
application: WebApplication
noteHistoryController: NoteHistoryController
notesController: NotesController
note: SNNote
subscriptionController: SubscriptionController
}
const HistoryModalContentPane = ({
application,
noteHistoryController,
notesController,
subscriptionController,
}: Props) => {
const { contentState } = noteHistoryController
const HistoryModalContentPane = ({ noteHistoryController, subscriptionController, note }: Props) => {
const { selectedRevision, contentState } = noteHistoryController
switch (contentState) {
case RevisionContentState.Idle:
@@ -32,13 +25,10 @@ const HistoryModalContentPane = ({
case RevisionContentState.Loading:
return <Spinner className="absolute top-1/2 left-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2" />
case RevisionContentState.Loaded:
return (
<SelectedRevisionContent
application={application}
notesController={notesController}
noteHistoryController={noteHistoryController}
/>
)
if (!selectedRevision) {
return null
}
return <ReadonlyNoteContent note={note} content={selectedRevision.payload.content} showLinkedItems={false} />
case RevisionContentState.NotEntitled:
return <RevisionContentLocked subscriptionController={subscriptionController} />
default:

View File

@@ -15,7 +15,6 @@ import MobileModalHeader from '../Modal/MobileModalHeader'
const HistoryModalDialogContent = ({
application,
dismissModal,
notesController,
subscriptionController,
note,
selectionController,
@@ -89,9 +88,8 @@ const HistoryModalDialogContent = ({
)}
>
<HistoryModalContentPane
application={application}
noteHistoryController={noteHistoryController}
notesController={notesController}
note={note}
subscriptionController={subscriptionController}
/>
</div>

View File

@@ -9,7 +9,6 @@ import { useModalAnimation } from '../Modal/useModalAnimation'
const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps> = ({
application,
historyModalController,
notesController,
selectionController,
subscriptionController,
}) => {
@@ -49,7 +48,6 @@ const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps> = ({
application={application}
dismissModal={historyModalController.dismissModal}
note={historyModalController.note}
notesController={notesController}
selectionController={selectionController}
subscriptionController={subscriptionController}
/>

View File

@@ -1,13 +1,11 @@
import { WebApplication } from '@/Application/WebApplication'
import { HistoryModalController } from '@/Controllers/NoteHistory/HistoryModalController'
import { NotesController } from '@/Controllers/NotesController/NotesController'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import { SubscriptionController } from '@/Controllers/Subscription/SubscriptionController'
import { SNNote } from '@standardnotes/snjs'
type CommonProps = {
application: WebApplication
notesController: NotesController
selectionController: SelectedItemsController
subscriptionController: SubscriptionController
}