perf(core): optimize rendering of all docs (#12188)

close AF-2605

[CleanShot 2025-05-08 at 13.56.38.mp4 <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/LakojjjzZNf6ogjOVwKE/4e36e838-7c7f-4f0a-89a8-fd582c2ef573.mp4" />](https://app.graphite.dev/media/video/LakojjjzZNf6ogjOVwKE/4e36e838-7c7f-4f0a-89a8-fd582c2ef573.mp4)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Centralized state management in the document explorer using a reactive context, replacing prop drilling and local state with observable streams for preferences, selection, grouping, and view options.
  - Updated multiple components (display menus, quick actions, doc list items, group headers) to consume and update state directly via context observables.
  - Simplified component signatures by removing now-unnecessary props related to preferences and state handlers.

- **Style**
  - Adjusted user avatar display: avatars now only have right margin when user names are shown, and vertical alignment was improved.

- **New Features**
  - User avatar elements now include a data attribute to indicate if the user name is displayed.

- **Bug Fixes**
  - Improved handling of document tags to prevent errors when tags are not in the expected format.

- **Documentation**
  - Added missing group header property for updated date fields in workspace property types.

- **Chores**
  - Clarified and renamed internal types for quick actions to improve code clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
CatsJuice
2025-05-10 07:01:49 +00:00
parent 76b4da54b7
commit 66500669c8
16 changed files with 274 additions and 351 deletions

View File

@@ -22,6 +22,9 @@ export const publicUserLabelRemoved = style([
]);
export const publicUserLabelAvatar = style({
marginRight: '0.5em',
transform: 'translateY(4px)',
selectors: {
'&[data-show-name="true"]': {
marginRight: '0.5em',
},
},
});

View File

@@ -56,6 +56,7 @@ export const PublicUserLabel = ({
name={user?.name ?? ''}
size={size}
className={styles.publicUserLabelAvatar}
data-show-name={showName}
/>
{showName && user?.name}
</span>

View File

@@ -108,7 +108,13 @@ export class DocsStore extends Store {
if (pages instanceof YArray) {
return pages.map(v => ({
id: v.get('id') as string,
tags: (v.get('tags')?.toJSON() ?? []) as string[],
tags: (() => {
const tags = v.get('tags');
if (tags instanceof YArray) {
return tags.toJSON() as string[];
}
return (tags ?? []) as string[];
})(),
}));
} else {
return [];