feat: configure all notes file visibility
This commit is contained in:
@@ -18,6 +18,7 @@ import { useMultiSelect, type MultiSelectState } from '../../hooks/useMultiSelec
|
||||
import { useNoteListKeyboard } from '../../hooks/useNoteListKeyboard'
|
||||
import { prefetchNoteContent } from '../../hooks/useTabManagement'
|
||||
import type { NoteListPropertiesScope } from './noteListPropertiesEvents'
|
||||
import type { AllNotesFileVisibility } from '../../utils/allNotesFileVisibility'
|
||||
|
||||
// --- useTypeEntryMap ---
|
||||
|
||||
@@ -36,6 +37,7 @@ interface FilteredEntriesParams {
|
||||
subFilter?: NoteListFilter
|
||||
inboxPeriod?: InboxPeriod
|
||||
views?: ViewFile[]
|
||||
allNotesFileVisibility?: AllNotesFileVisibility
|
||||
}
|
||||
|
||||
function buildFilteredEntries({
|
||||
@@ -50,6 +52,7 @@ function buildFilteredEntries({
|
||||
subFilter,
|
||||
inboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
}: FilteredEntriesParams & {
|
||||
isEntityView: boolean
|
||||
isChangesView: boolean
|
||||
@@ -61,7 +64,11 @@ function buildFilteredEntries({
|
||||
return entries.filter((entry) => isModifiedEntry(entry.path, modifiedPathSet, modifiedSuffixes))
|
||||
}
|
||||
if (isInboxView) return filterInboxEntries(entries, inboxPeriod ?? 'month')
|
||||
return filterEntries(entries, selection, subFilter, views)
|
||||
return filterEntries(entries, selection, {
|
||||
subFilter,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
export function useFilteredEntries({
|
||||
@@ -73,6 +80,7 @@ export function useFilteredEntries({
|
||||
subFilter,
|
||||
inboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
}: FilteredEntriesParams) {
|
||||
const isEntityView = selection.kind === 'entity'
|
||||
const isChangesView = selection.kind === 'filter' && selection.filter === 'changes'
|
||||
@@ -90,8 +98,9 @@ export function useFilteredEntries({
|
||||
subFilter,
|
||||
inboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
})
|
||||
}, [entries, inboxPeriod, isChangesView, isEntityView, isInboxView, modifiedFiles, modifiedPathSet, modifiedSuffixes, selection, subFilter, views])
|
||||
}, [allNotesFileVisibility, entries, inboxPeriod, isChangesView, isEntityView, isInboxView, modifiedFiles, modifiedPathSet, modifiedSuffixes, selection, subFilter, views])
|
||||
}
|
||||
|
||||
// --- useNoteListData ---
|
||||
@@ -104,9 +113,23 @@ interface NoteListDataParams {
|
||||
subFilter?: NoteListFilter
|
||||
inboxPeriod?: InboxPeriod
|
||||
views?: ViewFile[]
|
||||
allNotesFileVisibility?: AllNotesFileVisibility
|
||||
}
|
||||
|
||||
export function useNoteListData({ entries, selection, query, listSort, listDirection, modifiedPathSet, modifiedSuffixes, modifiedFiles, subFilter, inboxPeriod, views }: NoteListDataParams) {
|
||||
export function useNoteListData({
|
||||
entries,
|
||||
selection,
|
||||
query,
|
||||
listSort,
|
||||
listDirection,
|
||||
modifiedPathSet,
|
||||
modifiedSuffixes,
|
||||
modifiedFiles,
|
||||
subFilter,
|
||||
inboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
}: NoteListDataParams) {
|
||||
const isEntityView = selection.kind === 'entity'
|
||||
const isArchivedView = (selection.kind === 'filter' && selection.filter === 'archived') || subFilter === 'archived'
|
||||
const entityEntry = useMemo(() => {
|
||||
@@ -123,6 +146,7 @@ export function useNoteListData({ entries, selection, query, listSort, listDirec
|
||||
subFilter,
|
||||
inboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
})
|
||||
|
||||
const searched = useMemo(() => {
|
||||
@@ -530,8 +554,8 @@ function useAllNotesPropertyPickerState(
|
||||
const allNotesEntries = useMemo(
|
||||
() => isAllNotesView
|
||||
? [
|
||||
...filterEntries(entries, selection, 'open'),
|
||||
...filterEntries(entries, selection, 'archived'),
|
||||
...filterEntries(entries, selection, { subFilter: 'open' }),
|
||||
...filterEntries(entries, selection, { subFilter: 'archived' }),
|
||||
]
|
||||
: [],
|
||||
[entries, isAllNotesView, selection],
|
||||
@@ -588,7 +612,7 @@ function useViewPropertyPickerState(
|
||||
[selection, views],
|
||||
)
|
||||
const viewEntries = useMemo(
|
||||
() => selectedView ? filterEntries(entries, selection, undefined, views) : [],
|
||||
() => selectedView ? filterEntries(entries, selection, { views }) : [],
|
||||
[entries, selection, selectedView, views],
|
||||
)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
import type { AppLocale } from '../../lib/i18n'
|
||||
import type { NoteListFilter } from '../../utils/noteListHelpers'
|
||||
import { countByFilter, countAllByFilter, countAllNotesByFilter } from '../../utils/noteListHelpers'
|
||||
import type { AllNotesFileVisibility } from '../../utils/allNotesFileVisibility'
|
||||
import { NoteItem } from '../NoteItem'
|
||||
import { prefetchNoteContent } from '../../hooks/useTabManagement'
|
||||
import type { MultiSelectState } from '../../hooks/useMultiSelect'
|
||||
@@ -108,13 +109,19 @@ function useBulkActions(
|
||||
}
|
||||
}
|
||||
|
||||
function useFilterCounts(entries: VaultEntry[], selection: SidebarSelection) {
|
||||
function useFilterCounts(
|
||||
entries: VaultEntry[],
|
||||
selection: SidebarSelection,
|
||||
allNotesFileVisibility?: AllNotesFileVisibility,
|
||||
) {
|
||||
return useMemo(() => {
|
||||
if (selection.kind === 'sectionGroup') return countByFilter(entries, selection.type)
|
||||
if (selection.kind === 'folder') return countAllByFilter(entries)
|
||||
if (selection.kind === 'filter' && selection.filter === 'all') return countAllNotesByFilter(entries)
|
||||
if (selection.kind === 'filter' && selection.filter === 'all') {
|
||||
return countAllNotesByFilter(entries, allNotesFileVisibility)
|
||||
}
|
||||
return { open: 0, archived: 0 }
|
||||
}, [entries, selection])
|
||||
}, [allNotesFileVisibility, entries, selection])
|
||||
}
|
||||
|
||||
interface UseNoteListContentParams {
|
||||
@@ -136,6 +143,7 @@ interface UseNoteListContentParams {
|
||||
updateEntry?: (path: string, patch: Partial<VaultEntry>) => void
|
||||
views?: ViewFile[]
|
||||
visibleNotesRef?: React.MutableRefObject<VaultEntry[]>
|
||||
allNotesFileVisibility?: AllNotesFileVisibility
|
||||
}
|
||||
|
||||
function useNoteListContent({
|
||||
@@ -157,6 +165,7 @@ function useNoteListContent({
|
||||
updateEntry,
|
||||
views,
|
||||
visibleNotesRef,
|
||||
allNotesFileVisibility,
|
||||
}: UseNoteListContentParams) {
|
||||
const subFilter = (selection.kind === 'sectionGroup' || selection.kind === 'folder')
|
||||
? noteListFilter
|
||||
@@ -217,6 +226,7 @@ function useNoteListContent({
|
||||
subFilter,
|
||||
inboxPeriod: effectiveInboxPeriod,
|
||||
views,
|
||||
allNotesFileVisibility,
|
||||
})
|
||||
const searched = useMemo(() => filterEntriesByNoteListQuery(sortedEntries, query, {
|
||||
allEntries: entries,
|
||||
@@ -465,6 +475,7 @@ export interface NoteListProps {
|
||||
onUpdateViewDefinition?: (filename: string, patch: Partial<ViewDefinition>) => void
|
||||
views?: ViewFile[]
|
||||
visibleNotesRef?: React.MutableRefObject<VaultEntry[]>
|
||||
allNotesFileVisibility?: AllNotesFileVisibility
|
||||
locale?: AppLocale
|
||||
}
|
||||
|
||||
@@ -574,12 +585,13 @@ export function useNoteListModel({
|
||||
onUpdateViewDefinition,
|
||||
views,
|
||||
visibleNotesRef,
|
||||
allNotesFileVisibility,
|
||||
locale = 'en',
|
||||
}: NoteListProps) {
|
||||
const selectedNotePath = selectedNote?.path ?? null
|
||||
const { modifiedPathSet, modifiedSuffixes, resolvedGetNoteStatus } = useModifiedFilesState(modifiedFiles, getNoteStatus)
|
||||
const { isInboxView } = useViewFlags(selection)
|
||||
const filterCounts = useFilterCounts(entries, selection)
|
||||
const filterCounts = useFilterCounts(entries, selection, allNotesFileVisibility)
|
||||
const content = useNoteListContent({
|
||||
entries,
|
||||
selection,
|
||||
@@ -599,6 +611,7 @@ export function useNoteListModel({
|
||||
updateEntry,
|
||||
views,
|
||||
visibleNotesRef,
|
||||
allNotesFileVisibility,
|
||||
})
|
||||
const interaction = useNoteListInteractionState({
|
||||
searched: content.searched,
|
||||
|
||||
Reference in New Issue
Block a user