feat: on mobile goto content tab after selecting revision (#1611)
This commit is contained in:
@@ -1,18 +1,20 @@
|
|||||||
import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryController'
|
import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryController'
|
||||||
import { FeaturesClientInterface } from '@standardnotes/snjs'
|
import { FeaturesClientInterface } from '@standardnotes/snjs'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'react'
|
import { FunctionComponent, useCallback } from 'react'
|
||||||
import LegacyHistoryList from './LegacyHistoryList'
|
import LegacyHistoryList from './LegacyHistoryList'
|
||||||
import RemoteHistoryList from './RemoteHistoryList'
|
import RemoteHistoryList from './RemoteHistoryList'
|
||||||
import { RevisionType } from './RevisionType'
|
import { RevisionType } from './RevisionType'
|
||||||
import SessionHistoryList from './SessionHistoryList'
|
import SessionHistoryList from './SessionHistoryList'
|
||||||
|
import { HistoryModalMobileTab } from './utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
features: FeaturesClientInterface
|
features: FeaturesClientInterface
|
||||||
noteHistoryController: NoteHistoryController
|
noteHistoryController: NoteHistoryController
|
||||||
|
selectMobileModalTab: (tab: HistoryModalMobileTab) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const HistoryListContainer: FunctionComponent<Props> = ({ features, noteHistoryController }) => {
|
const HistoryListContainer: FunctionComponent<Props> = ({ features, noteHistoryController, selectMobileModalTab }) => {
|
||||||
const { legacyHistory, currentTab, selectTab } = noteHistoryController
|
const { legacyHistory, currentTab, selectTab } = noteHistoryController
|
||||||
|
|
||||||
const TabButton: FunctionComponent<{
|
const TabButton: FunctionComponent<{
|
||||||
@@ -34,14 +36,30 @@ const HistoryListContainer: FunctionComponent<Props> = ({ features, noteHistoryC
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onSelectRevision = useCallback(() => {
|
||||||
|
selectMobileModalTab('Content')
|
||||||
|
}, [selectMobileModalTab])
|
||||||
|
|
||||||
const CurrentTabList = () => {
|
const CurrentTabList = () => {
|
||||||
switch (currentTab) {
|
switch (currentTab) {
|
||||||
case RevisionType.Remote:
|
case RevisionType.Remote:
|
||||||
return <RemoteHistoryList features={features} noteHistoryController={noteHistoryController} />
|
return (
|
||||||
|
<RemoteHistoryList
|
||||||
|
onSelectRevision={onSelectRevision}
|
||||||
|
features={features}
|
||||||
|
noteHistoryController={noteHistoryController}
|
||||||
|
/>
|
||||||
|
)
|
||||||
case RevisionType.Session:
|
case RevisionType.Session:
|
||||||
return <SessionHistoryList noteHistoryController={noteHistoryController} />
|
return <SessionHistoryList onSelectRevision={onSelectRevision} noteHistoryController={noteHistoryController} />
|
||||||
case RevisionType.Legacy:
|
case RevisionType.Legacy:
|
||||||
return <LegacyHistoryList legacyHistory={legacyHistory} noteHistoryController={noteHistoryController} />
|
return (
|
||||||
|
<LegacyHistoryList
|
||||||
|
onSelectRevision={onSelectRevision}
|
||||||
|
legacyHistory={legacyHistory}
|
||||||
|
noteHistoryController={noteHistoryController}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import HistoryModalContentPane from './HistoryModalContentPane'
|
|||||||
import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryController'
|
import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryController'
|
||||||
import Icon from '../Icon/Icon'
|
import Icon from '../Icon/Icon'
|
||||||
import { classNames } from '@/Utils/ConcatenateClassNames'
|
import { classNames } from '@/Utils/ConcatenateClassNames'
|
||||||
|
import { HistoryModalMobileTab } from './utils'
|
||||||
|
|
||||||
const HistoryModalDialogContent = ({
|
const HistoryModalDialogContent = ({
|
||||||
application,
|
application,
|
||||||
@@ -18,7 +19,7 @@ const HistoryModalDialogContent = ({
|
|||||||
}: RevisionHistoryModalContentProps) => {
|
}: RevisionHistoryModalContentProps) => {
|
||||||
const [noteHistoryController] = useState(() => new NoteHistoryController(application, note, selectionController))
|
const [noteHistoryController] = useState(() => new NoteHistoryController(application, note, selectionController))
|
||||||
|
|
||||||
const [selectedMobileTab, setSelectedMobileTab] = useState<'List' | 'Content'>('Content')
|
const [selectedMobileTab, setSelectedMobileTab] = useState<HistoryModalMobileTab>('Content')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -56,7 +57,11 @@ const HistoryModalDialogContent = ({
|
|||||||
selectedMobileTab === 'List' ? 'flex' : 'hidden',
|
selectedMobileTab === 'List' ? 'flex' : 'hidden',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<HistoryListContainer features={application.features} noteHistoryController={noteHistoryController} />
|
<HistoryListContainer
|
||||||
|
features={application.features}
|
||||||
|
noteHistoryController={noteHistoryController}
|
||||||
|
selectMobileModalTab={setSelectedMobileTab}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryCont
|
|||||||
type Props = {
|
type Props = {
|
||||||
legacyHistory: Action[] | undefined
|
legacyHistory: Action[] | undefined
|
||||||
noteHistoryController: NoteHistoryController
|
noteHistoryController: NoteHistoryController
|
||||||
|
onSelectRevision: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const LegacyHistoryList: FunctionComponent<Props> = ({ legacyHistory, noteHistoryController }) => {
|
const LegacyHistoryList: FunctionComponent<Props> = ({ legacyHistory, noteHistoryController, onSelectRevision }) => {
|
||||||
const { selectLegacyRevision, selectedEntry } = noteHistoryController
|
const { selectLegacyRevision, selectedEntry } = noteHistoryController
|
||||||
|
|
||||||
const legacyHistoryListRef = useRef<HTMLDivElement>(null)
|
const legacyHistoryListRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -33,6 +34,7 @@ const LegacyHistoryList: FunctionComponent<Props> = ({ legacyHistory, noteHistor
|
|||||||
isSelected={selectedEntryUrl === url}
|
isSelected={selectedEntryUrl === url}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
selectLegacyRevision(entry)
|
selectLegacyRevision(entry)
|
||||||
|
onSelectRevision()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{entry.label}
|
{entry.label}
|
||||||
|
|||||||
@@ -12,9 +12,14 @@ import { PremiumFeatureIconClass, PremiumFeatureIconName } from '../Icon/Premium
|
|||||||
type RemoteHistoryListProps = {
|
type RemoteHistoryListProps = {
|
||||||
features: FeaturesClientInterface
|
features: FeaturesClientInterface
|
||||||
noteHistoryController: NoteHistoryController
|
noteHistoryController: NoteHistoryController
|
||||||
|
onSelectRevision: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = ({ features, noteHistoryController }) => {
|
const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = ({
|
||||||
|
features,
|
||||||
|
noteHistoryController,
|
||||||
|
onSelectRevision,
|
||||||
|
}) => {
|
||||||
const { remoteHistory, isFetchingRemoteHistory, selectRemoteRevision, selectedEntry } = noteHistoryController
|
const { remoteHistory, isFetchingRemoteHistory, selectRemoteRevision, selectedEntry } = noteHistoryController
|
||||||
|
|
||||||
const remoteHistoryListRef = useRef<HTMLDivElement>(null)
|
const remoteHistoryListRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -44,6 +49,7 @@ const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = ({ features
|
|||||||
isSelected={(selectedEntry as RevisionListEntry)?.uuid === entry.uuid}
|
isSelected={(selectedEntry as RevisionListEntry)?.uuid === entry.uuid}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
selectRemoteRevision(entry)
|
selectRemoteRevision(entry)
|
||||||
|
onSelectRevision()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex flex-grow items-center justify-between">
|
<div className="flex flex-grow items-center justify-between">
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryCont
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
noteHistoryController: NoteHistoryController
|
noteHistoryController: NoteHistoryController
|
||||||
|
onSelectRevision: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const SessionHistoryList: FunctionComponent<Props> = ({ noteHistoryController }) => {
|
const SessionHistoryList: FunctionComponent<Props> = ({ noteHistoryController, onSelectRevision }) => {
|
||||||
const { sessionHistory, selectedRevision, selectSessionRevision } = noteHistoryController
|
const { sessionHistory, selectedRevision, selectSessionRevision } = noteHistoryController
|
||||||
|
|
||||||
const sessionHistoryListRef = useRef<HTMLDivElement>(null)
|
const sessionHistoryListRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -40,6 +41,7 @@ const SessionHistoryList: FunctionComponent<Props> = ({ noteHistoryController })
|
|||||||
isSelected={selectedRevision?.payload.updated_at === entry.payload.updated_at}
|
isSelected={selectedRevision?.payload.updated_at === entry.payload.updated_at}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
selectSessionRevision(entry)
|
selectSessionRevision(entry)
|
||||||
|
onSelectRevision()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{entry.previewTitle()}
|
{entry.previewTitle()}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { DAYS_IN_A_WEEK, DAYS_IN_A_YEAR } from '@/Constants/Constants'
|
|||||||
import { HistoryEntry, NoteHistoryEntry, RevisionListEntry } from '@standardnotes/snjs'
|
import { HistoryEntry, NoteHistoryEntry, RevisionListEntry } from '@standardnotes/snjs'
|
||||||
import { calculateDifferenceBetweenDatesInDays } from '../../Utils/CalculateDifferenceBetweenDatesInDays'
|
import { calculateDifferenceBetweenDatesInDays } from '../../Utils/CalculateDifferenceBetweenDatesInDays'
|
||||||
|
|
||||||
|
export type HistoryModalMobileTab = 'Content' | 'List'
|
||||||
|
|
||||||
export type LegacyHistoryEntry = {
|
export type LegacyHistoryEntry = {
|
||||||
payload: HistoryEntry['payload']
|
payload: HistoryEntry['payload']
|
||||||
created_at: string
|
created_at: string
|
||||||
|
|||||||
Reference in New Issue
Block a user