Fix tag editing refreshing with delay

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 3 years ago
parent a38ff3928d
commit 743abc6599
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,7 @@
import { import {
AfterViewInit, AfterViewInit,
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef,
Component, Component,
EventEmitter, EventEmitter,
Input, Input,
@ -36,6 +37,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
private fileTags: { [key: number]: Tag[] } = {}; private fileTags: { [key: number]: Tag[] } = {};
constructor( constructor(
private changeDetector: ChangeDetectorRef,
private logger: LoggingService, private logger: LoggingService,
private tagService: TagService, private tagService: TagService,
) { ) {
@ -63,6 +65,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
tagInstance = (await this.tagService.createTags([tag]))[0]; tagInstance = (await this.tagService.createTags([tag]))[0];
this.allTags.push(tagInstance); this.allTags.push(tagInstance);
} }
this.changeDetector.markForCheck();
switch (this.editMode) { switch (this.editMode) {
case "Toggle": case "Toggle":
await this.toggleTag(tagInstance); await this.toggleTag(tagInstance);
@ -102,6 +105,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
if (index >= 0) { if (index >= 0) {
this.tagScroll.scrollToIndex(index); this.tagScroll.scrollToIndex(index);
} }
this.changeDetector.markForCheck();
}); });
this.tagEditEvent.emit(this); this.tagEditEvent.emit(this);
} }
@ -123,6 +127,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
} }
await this.tagService.loadTags(); await this.tagService.loadTags();
await this.tagService.loadNamespaces(); await this.tagService.loadNamespaces();
this.changeDetector.markForCheck();
}); });
this.tagEditEvent.emit(this); this.tagEditEvent.emit(this);
} }
@ -169,6 +174,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
this.tags = tags.sort( this.tags = tags.sort(
(a, b) => a.getNormalizedOutput() (a, b) => a.getNormalizedOutput()
.localeCompare(b.getNormalizedOutput())); .localeCompare(b.getNormalizedOutput()));
this.changeDetector.markForCheck();
} }
private async wrapAsyncOperation<T>(cb: () => Promise<T>): Promise<T | undefined> { private async wrapAsyncOperation<T>(cb: () => Promise<T>): Promise<T | undefined> {

Loading…
Cancel
Save