mirror of
https://github.com/dream-num/univer.git
synced 2026-10-02 04:24:34 +08:00
fix(ui): support reliable base attachment previews (#7592)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user