Skip to content

Commit

Permalink
fix: Keep existing preview state while loading a new file. (#238)
Browse files Browse the repository at this point in the history
Keeps the UI for the existing file while waiting for the next file to load.

Also hides the existing editing UI and show the loading UI instead when there is a loading file.
  • Loading branch information
Zoramite committed Aug 13, 2021
1 parent ce97eef commit 9191de5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/ts/editor/state.ts
Expand Up @@ -599,9 +599,6 @@ export class EditorState extends ListenersMixin(Base) {
}
});

// Unset the existing file since it is 'unloaded'.
this.file = undefined;

// Mark the file path that is being loaded.
this.loadingFilePath = file.path;

Expand Down
2 changes: 1 addition & 1 deletion src/ts/editor/ui/parts/content.ts
Expand Up @@ -138,7 +138,7 @@ export class ContentPart extends BasePart implements UiPartComponent {

subParts.push(this.partToolbar.template());

if (this.config.editor.state.inProgress(StatePromiseKeys.GetFile)) {
if (this.config.editor.state.loadingFilePath) {
subParts.push(html`<div class="le__part__content__loading">
${templateLoading(
{},
Expand Down
2 changes: 1 addition & 1 deletion src/ts/editor/ui/parts/content/toolbar.ts
Expand Up @@ -103,7 +103,7 @@ export class ContentToolbarPart extends BasePart implements UiPartComponent {
}

templateIconRefresh(): TemplateResult {
if (!this.config.state.file) {
if (!this.config.state.file || this.config.state.loadingFilePath) {
return html``;
}

Expand Down
5 changes: 4 additions & 1 deletion src/ts/editor/ui/parts/preview.ts
Expand Up @@ -156,7 +156,10 @@ export class PreviewPart extends BasePart implements UiPartComponent {
templatePreviewNotAvailable(): TemplateResult {
// When waiting for the file to load do not show anything
// since the file load is already showing.
if (this.config.editor.state.inProgress(StatePromiseKeys.GetFile)) {
if (
!this.config.state.loadingFilePath &&
this.config.editor.state.inProgress(StatePromiseKeys.GetFile)
) {
return html``;
}

Expand Down

0 comments on commit 9191de5

Please sign in to comment.