Cleanup PreviewWeb a little

This commit is contained in:
Tom Coleman 2021-10-20 21:37:14 +11:00
parent c15ac11f70
commit ba4709f298

View File

@ -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({