mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-30 05:04:14 +08:00
Cleanup PreviewWeb
a little
This commit is contained in:
parent
c15ac11f70
commit
ba4709f298
@ -323,11 +323,11 @@ export class PreviewWeb<TFramework extends AnyFramework> {
|
||||
return;
|
||||
}
|
||||
|
||||
const storyChanged = this.previousSelection?.storyId !== selection.storyId;
|
||||
const storyIdChanged = this.previousSelection?.storyId !== selection.storyId;
|
||||
const viewModeChanged = this.previousSelection?.viewMode !== selection.viewMode;
|
||||
|
||||
const implementationChanged =
|
||||
!storyChanged && this.previousStory && story !== this.previousStory;
|
||||
!storyIdChanged && this.previousStory && story !== this.previousStory;
|
||||
|
||||
if (persistedArgs) {
|
||||
this.storyStore.args.updateFromPersisted(story, persistedArgs);
|
||||
@ -336,7 +336,7 @@ export class PreviewWeb<TFramework extends AnyFramework> {
|
||||
}
|
||||
|
||||
// Don't re-render the story if nothing has changed to justify it
|
||||
if (this.previousStory && !storyChanged && !implementationChanged && !viewModeChanged) {
|
||||
if (this.previousStory && !storyIdChanged && !implementationChanged && !viewModeChanged) {
|
||||
this.channel.emit(Events.STORY_UNCHANGED, selection.storyId);
|
||||
return;
|
||||
}
|
||||
@ -344,7 +344,7 @@ export class PreviewWeb<TFramework extends AnyFramework> {
|
||||
await this.cleanupPreviousRender({ unmountDocs: viewModeChanged });
|
||||
|
||||
// If we are rendering something new (as opposed to re-rendering the same or first story), emit
|
||||
if (this.previousSelection && (storyChanged || viewModeChanged)) {
|
||||
if (this.previousSelection && (storyIdChanged || viewModeChanged)) {
|
||||
this.channel.emit(Events.STORY_CHANGED, selection.storyId);
|
||||
}
|
||||
|
||||
@ -508,17 +508,6 @@ export class PreviewWeb<TFramework extends AnyFramework> {
|
||||
|
||||
if (initial) {
|
||||
const storyContext = this.storyStore.getStoryContext(story);
|
||||
const { parameters, initialArgs, argTypes, args } = storyContext;
|
||||
if (FEATURES?.storyStoreV7) {
|
||||
this.channel.emit(Events.STORY_PREPARED, {
|
||||
id,
|
||||
parameters,
|
||||
initialArgs,
|
||||
argTypes,
|
||||
args,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await runPhase('loading', async () => {
|
||||
loadedContext = await applyLoaders({
|
||||
|
Loading…
x
Reference in New Issue
Block a user