mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat(core): support better battery save mode (#13383)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced a Document Summary module, enabling live and cached document summaries with cloud revalidation. * Added a feature flag for enabling battery save mode. * Added explicit pause and resume controls for sync operations, accessible via UI events and programmatically. * **Improvements** * Enhanced sync and indexing logic to support pausing, resuming, and battery save mode, with improved job prioritization. * Updated navigation and preview components to use the new document summary service and improved priority handling. * Improved logging and state reporting for sync and indexing processes. * Refined backlink handling with reactive loading states and cloud revalidation. * Replaced backlink and link management to use a new dedicated document links service. * Enhanced workspace engine to conditionally enable battery save mode based on feature flags and workspace flavor. * **Bug Fixes** * Removed unnecessary debug console logs from various components for cleaner output. * **Refactor** * Replaced battery save mode methods with explicit pause/resume methods throughout the app and services. * Modularized and streamlined document summary and sync-related code for better maintainability. * Restructured backlink components to improve visibility handling and data fetching. * Simplified and improved document backlink data fetching with retry and loading state management. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { DocsSearchService } from '@affine/core/modules/docs-search';
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { DocSummaryService } from '@affine/core/modules/doc-summary';
|
||||
import { LiveData, useLiveData, useService } from '@toeverything/infra';
|
||||
import { type ReactNode, useEffect, useMemo } from 'react';
|
||||
import { type ReactNode, useMemo } from 'react';
|
||||
|
||||
interface PagePreviewProps {
|
||||
pageId: string;
|
||||
@@ -14,8 +13,7 @@ const PagePreviewInner = ({
|
||||
emptyFallback,
|
||||
fallback,
|
||||
}: PagePreviewProps) => {
|
||||
const docSummary = useService(DocsSearchService);
|
||||
const workspaceService = useService(WorkspaceService);
|
||||
const docSummary = useService(DocSummaryService);
|
||||
const summary = useLiveData(
|
||||
useMemo(
|
||||
() => LiveData.from(docSummary.watchDocSummary(pageId), null),
|
||||
@@ -23,16 +21,6 @@ const PagePreviewInner = ({
|
||||
)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const undo = docSummary.indexer.addPriority(pageId, 100);
|
||||
return undo;
|
||||
}, [docSummary, pageId]);
|
||||
|
||||
useEffect(() => {
|
||||
const undo = workspaceService.workspace.engine.doc.addPriority(pageId, 10);
|
||||
return undo;
|
||||
}, [workspaceService, pageId]);
|
||||
|
||||
const res =
|
||||
summary === null ? fallback : summary === '' ? emptyFallback : summary;
|
||||
return res;
|
||||
|
||||
@@ -312,8 +312,6 @@ export const WorkspaceCard = forwardRef<
|
||||
onClickOpenSettings?.(workspaceMetadata);
|
||||
}, [onClickOpenSettings, workspaceMetadata]);
|
||||
|
||||
console.log(information);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
|
||||
Reference in New Issue
Block a user