chore: prettier files
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
import { WebApplication } from '@/UIModels/Application'
|
||||
import {
|
||||
Action,
|
||||
ActionVerb,
|
||||
HistoryEntry,
|
||||
NoteHistoryEntry,
|
||||
RevisionListEntry,
|
||||
SNNote,
|
||||
} from '@standardnotes/snjs'
|
||||
import { Action, ActionVerb, HistoryEntry, NoteHistoryEntry, RevisionListEntry, SNNote } from '@standardnotes/snjs'
|
||||
import { observer } from 'mobx-react-lite'
|
||||
import { FunctionComponent } from 'preact'
|
||||
import { StateUpdater, useCallback, useState } from 'preact/hooks'
|
||||
@@ -55,26 +48,19 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
|
||||
const fetchLegacyHistory = async () => {
|
||||
const actionExtensions = application.actionsManager.getExtensions()
|
||||
actionExtensions.forEach(async (ext) => {
|
||||
const actionExtension = await application.actionsManager.loadExtensionInContextOfItem(
|
||||
ext,
|
||||
note,
|
||||
)
|
||||
const actionExtension = await application.actionsManager.loadExtensionInContextOfItem(ext, note)
|
||||
|
||||
if (!actionExtension) {
|
||||
return
|
||||
}
|
||||
|
||||
const isLegacyNoteHistoryExt = actionExtension?.actions.some(
|
||||
(action) => action.verb === ActionVerb.Nested,
|
||||
)
|
||||
const isLegacyNoteHistoryExt = actionExtension?.actions.some((action) => action.verb === ActionVerb.Nested)
|
||||
|
||||
if (!isLegacyNoteHistoryExt) {
|
||||
return
|
||||
}
|
||||
|
||||
const legacyHistoryEntries = actionExtension.actions.filter(
|
||||
(action) => action.subactions?.[0],
|
||||
)
|
||||
const legacyHistoryEntries = actionExtension.actions.filter((action) => action.subactions?.[0])
|
||||
|
||||
setLegacyHistory(legacyHistoryEntries)
|
||||
})
|
||||
@@ -114,10 +100,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
|
||||
throw new Error('Could not find revision action url')
|
||||
}
|
||||
|
||||
const response = await application.actionsManager.runAction(
|
||||
revisionListEntry.subactions[0],
|
||||
note,
|
||||
)
|
||||
const response = await application.actionsManager.runAction(revisionListEntry.subactions[0], note)
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Could not fetch revision')
|
||||
@@ -131,13 +114,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
|
||||
setIsFetchingSelectedRevision(false)
|
||||
}
|
||||
},
|
||||
[
|
||||
application.actionsManager,
|
||||
note,
|
||||
setIsFetchingSelectedRevision,
|
||||
setSelectedRemoteEntry,
|
||||
setSelectedRevision,
|
||||
],
|
||||
[application.actionsManager, note, setIsFetchingSelectedRevision, setSelectedRemoteEntry, setSelectedRevision],
|
||||
)
|
||||
|
||||
const fetchAndSetRemoteRevision = useCallback(
|
||||
@@ -150,10 +127,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
|
||||
setSelectedRemoteEntry(undefined)
|
||||
|
||||
try {
|
||||
const remoteRevision = await application.historyManager.fetchRemoteRevision(
|
||||
note,
|
||||
revisionListEntry,
|
||||
)
|
||||
const remoteRevision = await application.historyManager.fetchRemoteRevision(note, revisionListEntry)
|
||||
setSelectedRevision(remoteRevision)
|
||||
setSelectedRemoteEntry(revisionListEntry)
|
||||
} catch (err) {
|
||||
@@ -177,17 +151,11 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
'flex flex-col min-w-60 border-0 border-r-1px border-solid border-main overflow-auto h-full'
|
||||
}
|
||||
>
|
||||
<div className={'flex flex-col min-w-60 border-0 border-r-1px border-solid border-main overflow-auto h-full'}>
|
||||
<div className="flex border-0 border-b-1 border-solid border-main">
|
||||
<TabButton type={RevisionListTabType.Remote} />
|
||||
<TabButton type={RevisionListTabType.Session} />
|
||||
{legacyHistory && legacyHistory.length > 0 && (
|
||||
<TabButton type={RevisionListTabType.Legacy} />
|
||||
)}
|
||||
{legacyHistory && legacyHistory.length > 0 && <TabButton type={RevisionListTabType.Legacy} />}
|
||||
</div>
|
||||
<div className={'min-h-0 overflow-auto py-1.5 h-full'}>
|
||||
{selectedTab === RevisionListTabType.Session && (
|
||||
|
||||
@@ -6,23 +6,15 @@ type HistoryListItemProps = {
|
||||
onClick: () => void
|
||||
}
|
||||
|
||||
export const HistoryListItem: FunctionComponent<HistoryListItemProps> = ({
|
||||
children,
|
||||
isSelected,
|
||||
onClick,
|
||||
}) => {
|
||||
export const HistoryListItem: FunctionComponent<HistoryListItemProps> = ({ children, isSelected, onClick }) => {
|
||||
return (
|
||||
<button
|
||||
tabIndex={FOCUSABLE_BUT_NOT_TABBABLE}
|
||||
className={`sn-dropdown-item py-2.5 focus:bg-contrast focus:shadow-none ${
|
||||
isSelected ? 'bg-info-backdrop' : ''
|
||||
}`}
|
||||
className={`sn-dropdown-item py-2.5 focus:bg-contrast focus:shadow-none ${isSelected ? 'bg-info-backdrop' : ''}`}
|
||||
onClick={onClick}
|
||||
data-selected={isSelected}
|
||||
>
|
||||
<div
|
||||
className={`pseudo-radio-btn ${isSelected ? 'pseudo-radio-btn--checked' : ''} mr-2`}
|
||||
></div>
|
||||
<div className={`pseudo-radio-btn ${isSelected ? 'pseudo-radio-btn--checked' : ''} mr-2`}></div>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -68,9 +68,7 @@ export const LegacyHistoryList: FunctionComponent<Props> = ({
|
||||
</HistoryListItem>
|
||||
)
|
||||
})}
|
||||
{!legacyHistory?.length && (
|
||||
<div className="color-grey-0 select-none">No legacy history found</div>
|
||||
)}
|
||||
{!legacyHistory?.length && <div className="color-grey-0 select-none">No legacy history found</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,13 +43,7 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = obse
|
||||
if (firstEntry && !selectedEntryUuid.length) {
|
||||
selectFirstEntry()
|
||||
}
|
||||
}, [
|
||||
fetchAndSetRemoteRevision,
|
||||
firstEntry,
|
||||
remoteHistory,
|
||||
selectFirstEntry,
|
||||
selectedEntryUuid.length,
|
||||
])
|
||||
}, [fetchAndSetRemoteRevision, firstEntry, remoteHistory, selectFirstEntry, selectedEntryUuid.length])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -76,9 +70,7 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = obse
|
||||
>
|
||||
<div className="flex flex-grow items-center justify-between">
|
||||
<div>{previewHistoryEntryTitle(entry)}</div>
|
||||
{!application.features.hasMinimumRole(entry.required_role) && (
|
||||
<Icon type="premium-feature" />
|
||||
)}
|
||||
{!application.features.hasMinimumRole(entry.required_role) && <Icon type="premium-feature" />}
|
||||
</div>
|
||||
</HistoryListItem>
|
||||
))}
|
||||
|
||||
@@ -22,8 +22,7 @@ const getPremiumContentCopy = (planName: string | undefined) => {
|
||||
export const RevisionContentLocked: FunctionComponent<{
|
||||
appState: AppState
|
||||
}> = observer(({ appState }) => {
|
||||
const { userSubscriptionName, isUserSubscriptionExpired, isUserSubscriptionCanceled } =
|
||||
appState.subscription
|
||||
const { userSubscriptionName, isUserSubscriptionExpired, isUserSubscriptionCanceled } = appState.subscription
|
||||
|
||||
return (
|
||||
<div className="flex w-full h-full items-center justify-center">
|
||||
|
||||
@@ -46,13 +46,9 @@ const RevisionContentPlaceholder: FunctionComponent<RevisionContentPlaceholderPr
|
||||
: '-z-index-1'
|
||||
}`}
|
||||
>
|
||||
{isFetchingSelectedRevision && (
|
||||
<div className={`sk-spinner w-5 h-5 spinner-info ${ABSOLUTE_CENTER_CLASSNAME}`} />
|
||||
)}
|
||||
{isFetchingSelectedRevision && <div className={`sk-spinner w-5 h-5 spinner-info ${ABSOLUTE_CENTER_CLASSNAME}`} />}
|
||||
{!isFetchingSelectedRevision && !selectedRevision ? (
|
||||
<div className={`color-grey-0 select-none ${ABSOLUTE_CENTER_CLASSNAME}`}>
|
||||
No revision selected
|
||||
</div>
|
||||
<div className={`color-grey-0 select-none ${ABSOLUTE_CENTER_CLASSNAME}`}>No revision selected</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
@@ -87,8 +83,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
|
||||
try {
|
||||
const initialRemoteHistory = await application.historyManager.remoteHistoryForItem(note)
|
||||
|
||||
const remoteHistoryAsGroups =
|
||||
sortRevisionListIntoGroups<RevisionListEntry>(initialRemoteHistory)
|
||||
const remoteHistoryAsGroups = sortRevisionListIntoGroups<RevisionListEntry>(initialRemoteHistory)
|
||||
|
||||
setRemoteHistory(remoteHistoryAsGroups)
|
||||
} catch (err) {
|
||||
@@ -240,9 +235,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
|
||||
isFetchingSelectedRevision={isFetchingSelectedRevision}
|
||||
showContentLockedScreen={showContentLockedScreen}
|
||||
/>
|
||||
{showContentLockedScreen && !selectedRevision && (
|
||||
<RevisionContentLocked appState={appState} />
|
||||
)}
|
||||
{showContentLockedScreen && !selectedRevision && <RevisionContentLocked appState={appState} />}
|
||||
{selectedRevision && templateNoteForRevision && (
|
||||
<SelectedRevisionContent
|
||||
application={application}
|
||||
@@ -267,11 +260,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
|
||||
{selectedRevision && (
|
||||
<div class="flex items-center">
|
||||
{selectedRemoteEntry && (
|
||||
<Button
|
||||
className="py-1.35 mr-2.5"
|
||||
onClick={deleteSelectedRevision}
|
||||
variant="normal"
|
||||
>
|
||||
<Button className="py-1.35 mr-2.5" onClick={deleteSelectedRevision} variant="normal">
|
||||
{isDeletingRevision ? (
|
||||
<div className="sk-spinner my-1 w-3 h-3 spinner-info" />
|
||||
) : (
|
||||
@@ -285,12 +274,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
|
||||
onClick={restoreAsCopy}
|
||||
variant="normal"
|
||||
/>
|
||||
<Button
|
||||
className="py-1.35"
|
||||
label="Restore version"
|
||||
onClick={restore}
|
||||
variant="primary"
|
||||
/>
|
||||
<Button className="py-1.35" label="Restore version" onClick={restore} variant="primary" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -24,8 +24,7 @@ export const SelectedRevisionContent: FunctionComponent<SelectedRevisionContentP
|
||||
return undefined
|
||||
}
|
||||
|
||||
const componentViewer =
|
||||
application.componentManager.createComponentViewer(editorForCurrentNote)
|
||||
const componentViewer = application.componentManager.createComponentViewer(editorForCurrentNote)
|
||||
componentViewer.setReadonly(true)
|
||||
componentViewer.lockReadonly = true
|
||||
componentViewer.overrideContextItem = templateNoteForRevision
|
||||
|
||||
@@ -75,9 +75,7 @@ export const SessionHistoryList: FunctionComponent<Props> = ({
|
||||
</Fragment>
|
||||
) : null),
|
||||
)}
|
||||
{!sessionHistoryLength && (
|
||||
<div className="color-grey-0 select-none">No session history found</div>
|
||||
)}
|
||||
{!sessionHistoryLength && <div className="color-grey-0 select-none">No session history found</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ export const formatDateAsMonthYearString = (date: Date) =>
|
||||
|
||||
export const getGroupIndexForEntry = (entry: RevisionEntry, groups: ListGroup<RevisionEntry>[]) => {
|
||||
const todayAsDate = new Date()
|
||||
const entryDate = new Date(
|
||||
(entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.created_at,
|
||||
)
|
||||
const entryDate = new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.created_at)
|
||||
|
||||
const differenceBetweenDatesInDays = calculateDifferenceBetweenDatesInDays(todayAsDate, entryDate)
|
||||
|
||||
@@ -52,9 +50,7 @@ const GROUP_TITLE_TODAY = 'Today'
|
||||
const GROUP_TITLE_WEEK = 'This Week'
|
||||
const GROUP_TITLE_YEAR = 'More Than A Year Ago'
|
||||
|
||||
export const sortRevisionListIntoGroups = <EntryType extends RevisionEntry>(
|
||||
revisionList: EntryType[] | undefined,
|
||||
) => {
|
||||
export const sortRevisionListIntoGroups = <EntryType extends RevisionEntry>(revisionList: EntryType[] | undefined) => {
|
||||
const sortedGroups: ListGroup<EntryType>[] = [
|
||||
{
|
||||
title: GROUP_TITLE_TODAY,
|
||||
@@ -82,10 +78,7 @@ export const sortRevisionListIntoGroups = <EntryType extends RevisionEntry>(
|
||||
} else {
|
||||
addBeforeLastGroup({
|
||||
title: formatDateAsMonthYearString(
|
||||
new Date(
|
||||
(entry as RevisionListEntry).created_at ??
|
||||
(entry as NoteHistoryEntry).payload.created_at,
|
||||
),
|
||||
new Date((entry as RevisionListEntry).created_at ?? (entry as NoteHistoryEntry).payload.created_at),
|
||||
),
|
||||
entries: [entry],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user