Skip to content

Commit

Permalink
fix: issue when creating new note in new tag doesnt re-render immedia…
Browse files Browse the repository at this point in the history
…tely
  • Loading branch information
moughxyz committed Jan 12, 2022
1 parent 8f4f188 commit a2b2d3f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Expand Up @@ -333,9 +333,14 @@ export class NotesViewState {
if (this.isFiltering) {
title = this.noteFilterText;
}

await this.appState.openNewNote(title);
this.reloadNotes();
this.appState.noteTags.reloadTags();
this.application.performFunctionWithAngularDigestCycleAfterAsyncChange(
() => {
this.reloadNotes();
this.appState.noteTags.reloadTags();
}
);
};

createPlaceholderNote = () => {
Expand Down
11 changes: 11 additions & 0 deletions app/assets/javascripts/ui_models/application.ts
Expand Up @@ -43,6 +43,7 @@ export class WebApplication extends SNApplication {
platform: Platform,
identifier: string,
private $compile: angular.ICompileService,
private $timeout: angular.ITimeoutService,
scope: angular.IScope,
defaultSyncServerHost: string,
public bridge: Bridge,
Expand Down Expand Up @@ -104,6 +105,16 @@ export class WebApplication extends SNApplication {
this.webServices = services;
}

/**
* If a UI change is made in an async function, Angular might not re-render the change.
* Use this function to force re-render the UI after an async function has made UI changes.
*/
public performFunctionWithAngularDigestCycleAfterAsyncChange(
func: () => void
) {
this.$timeout(func);
}

public getAppState(): AppState {
return this.webServices.appState;
}
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/ui_models/application_group.ts
Expand Up @@ -61,6 +61,7 @@ export class ApplicationGroup extends SNApplicationGroup {
platform,
descriptor.identifier,
this.$compile,
this.$timeout,
scope,
this.defaultSyncServerHost,
this.bridge,
Expand Down

0 comments on commit a2b2d3f

Please sign in to comment.