fix: satisfy production workspace build
This commit is contained in:
@@ -452,7 +452,7 @@ interface EditorPersistenceOptions {
|
||||
resolveCurrentPath: (path: string) => string
|
||||
resolvePathBeforeSave: (path: string) => Promise<string>
|
||||
canPersist: boolean
|
||||
persistenceScope: string
|
||||
persistenceScope: string | readonly string[]
|
||||
locale: AppLocale
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ function usePendingContentScopeReset({
|
||||
}: {
|
||||
cancelAutoSave: () => void
|
||||
pendingContentRef: MutableRefObject<PendingContent | null>
|
||||
persistenceScope?: string
|
||||
persistenceScope?: string | readonly string[]
|
||||
}) {
|
||||
const previousScopeRef = useRef(persistenceScope)
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export function useEditorSaveWithLinks(config: {
|
||||
resolvePath?: (path: string) => string
|
||||
resolvePathBeforeSave?: (path: string) => Promise<string>
|
||||
canPersist?: boolean
|
||||
persistenceScope?: string
|
||||
persistenceScope?: string | readonly string[]
|
||||
disabledSaveMessage?: string
|
||||
locale?: AppLocale
|
||||
}) {
|
||||
|
||||
@@ -60,7 +60,7 @@ async function loadInitialVaultChromeState(options: InitialVaultChromeOptions):
|
||||
|
||||
async function loadInitialVaultEntriesState(options: Pick<
|
||||
InitialVaultLoadStateOptions,
|
||||
'handleVaultAvailable' | 'handleVaultUnavailable' | 'isCurrentVaultPath' | 'path' | 'setEntries'
|
||||
'defaultWorkspacePath' | 'handleVaultAvailable' | 'handleVaultUnavailable' | 'isCurrentVaultPath' | 'path' | 'setEntries' | 'vaults'
|
||||
>): Promise<boolean> {
|
||||
const { handleVaultAvailable, handleVaultUnavailable, isCurrentVaultPath, path, setEntries } = options
|
||||
|
||||
|
||||
@@ -551,6 +551,7 @@ function usePersistedVaultState(onSwitchRef: MutableRefObject<() => void>): Pers
|
||||
return {
|
||||
defaultAvailable,
|
||||
defaultPath,
|
||||
defaultWorkspacePath,
|
||||
extraVaults,
|
||||
hiddenDefaults,
|
||||
lastPersistedSnapshotRef,
|
||||
|
||||
@@ -118,6 +118,27 @@ function normalizeFileKind(value: unknown): VaultEntry['fileKind'] {
|
||||
return undefined
|
||||
}
|
||||
|
||||
function normalizeWorkspaceIdentity(value: unknown): WorkspaceIdentity | undefined {
|
||||
const source = recordFrom(value)
|
||||
const id = stringFrom(source.id).trim()
|
||||
const label = stringFrom(source.label).trim()
|
||||
const alias = stringFrom(source.alias).trim()
|
||||
const path = stringFrom(source.path).trim()
|
||||
if (!id || !label || !alias || !path) return undefined
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
alias,
|
||||
path,
|
||||
shortLabel: stringFrom(source.shortLabel).trim() || label.slice(0, 2).toUpperCase(),
|
||||
color: nullableStringFrom(source.color),
|
||||
icon: nullableStringFrom(source.icon),
|
||||
mounted: booleanFrom(source.mounted, true),
|
||||
available: booleanFrom(source.available, true),
|
||||
defaultForNewNotes: booleanFrom(source.defaultForNewNotes),
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeFilterGroup(value: unknown): FilterGroup {
|
||||
const source = recordFrom(value)
|
||||
if (Array.isArray(source.all)) return { all: source.all as FilterNode[] }
|
||||
@@ -146,7 +167,7 @@ function normalizeVaultEntryRecord({ rawEntry, vaultPath, index, workspace }: En
|
||||
path,
|
||||
filename,
|
||||
title,
|
||||
workspace: workspace ?? (isRecord(source.workspace) ? source.workspace as WorkspaceIdentity : undefined),
|
||||
workspace: workspace ?? normalizeWorkspaceIdentity(source.workspace),
|
||||
isA: nullableStringFrom(source.isA),
|
||||
aliases: stringArrayFrom(source.aliases),
|
||||
belongsTo: stringArrayFrom(source.belongsTo),
|
||||
|
||||
@@ -12,7 +12,7 @@ function compareVaultContainmentPath(path: string, vaultPath: string): [string,
|
||||
}
|
||||
|
||||
export function canWritePathToVault(path: string, vaultPath: string | readonly string[]): boolean {
|
||||
if (Array.isArray(vaultPath)) {
|
||||
if (typeof vaultPath !== 'string') {
|
||||
return vaultPath.some((candidate) => canWritePathToVault(path, candidate))
|
||||
}
|
||||
const trimmedVaultPath = vaultPath.trim()
|
||||
|
||||
@@ -65,7 +65,7 @@ export function workspaceLabelForEntry(entry: Pick<VaultEntry, 'workspace'>): st
|
||||
}
|
||||
|
||||
export function workspaceDisplayPrefix(entry: Pick<VaultEntry, 'workspace'>): string | null {
|
||||
const workspace = workspaceForEntry(entry)
|
||||
const workspace = entry.workspace ?? null
|
||||
return workspace ? `${workspace.label} / ` : null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user