feat(editor): add blobState$ to BlobEngine (#11756)

Closes: [BS-3137](https://linear.app/affine-design/issue/BS-3137/在-bs-添加-blobstate-接口)

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

## Summary by CodeRabbit

- **New Features**
  - Introduced real-time status tracking for file upload and download operations, allowing users to monitor progress and errors more effectively.
- **Improvements**
  - Enhanced icon display for attachments, providing a refreshed visual experience.
  - Improved update frequency and accuracy for file synchronization status indicators.
- **Bug Fixes**
  - Refined internal logic for filtering status updates, ensuring more precise feedback during file operations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fundon
2025-04-28 02:28:48 +00:00
committed by Fangdun Tsai
parent d7b1819149
commit e9003dec9e
9 changed files with 35 additions and 11 deletions

View File

@@ -104,6 +104,10 @@ export class BlobEngine {
return key;
}
blobState$(key: string) {
return this.main.blobState$?.(key) ?? null;
}
start() {
if (this._abort) {
return;

View File

@@ -1,3 +1,12 @@
import type { Observable } from 'rxjs';
export interface BlobState {
uploading: boolean;
downloading: boolean;
errorMessage?: string | null;
overSize: boolean;
}
export interface BlobSource {
name: string;
readonly: boolean;
@@ -5,4 +14,6 @@ export interface BlobSource {
set: (key: string, value: Blob) => Promise<string>;
delete: (key: string) => Promise<void>;
list: () => Promise<string[]>;
// This state is only available when uploading to the cloud or downloading from the cloud.
blobState$?: (key: string) => Observable<BlobState> | null;
}