fix(ui): support reliable base attachment previews (#7592)

This commit is contained in:
Univer
2026-08-25 02:59:43 +08:00
committed by GitHub
parent f8652364a4
commit d9d5391c85
2 changed files with 13 additions and 2 deletions
@@ -44,6 +44,17 @@ describe('DesktopGalleryService', () => {
sub.unsubscribe();
});
it('replays the open state when the global gallery UI subscribes after the first open', () => {
const service = createService();
service.open({ images: ['a.png'] });
const snapshots: IGalleryProps[] = [];
const sub = service.gallery$.subscribe((value) => snapshots.push(value));
expect(snapshots).toEqual([{ open: true, images: ['a.png'] }]);
sub.unsubscribe();
});
it('completes gallery state when the open handle is disposed', () => {
const service = createService();
let completed = false;
@@ -18,7 +18,7 @@ import type { IDisposable } from '@univerjs/core';
import type { IGalleryProps } from '@univerjs/design';
import type { IGalleryService } from './gallery.service';
import { Disposable, Inject, Injector, toDisposable } from '@univerjs/core';
import { Subject } from 'rxjs';
import { ReplaySubject } from 'rxjs';
import { connectInjector } from '../../utils/di';
import { GalleryPart } from '../../views/components/gallery-part/GalleryPart';
import { BuiltInUIPart, IUIPartsService } from '../parts/parts.service';
@@ -33,7 +33,7 @@ export class DesktopGalleryService extends Disposable implements IGalleryService
this._initUIPart();
}
gallery$ = new Subject<IGalleryProps>();
gallery$ = new ReplaySubject<IGalleryProps>(1);
override dispose(): void {
super.dispose();