Fix new tags not being displayed in tag suggestions

Signed-off-by: Trivernis <trivernis@protonmail.com>
pull/4/head
Trivernis 3 years ago
parent a3e33be9b6
commit e2116dae04

@ -1,8 +1,8 @@
import { import {
Component, Component, EventEmitter,
Input, Input,
OnChanges, OnChanges,
OnInit, OnInit, Output,
SimpleChanges, SimpleChanges,
ViewChild ViewChild
} from "@angular/core"; } from "@angular/core";
@ -20,6 +20,7 @@ import {delay} from "rxjs/operators";
export class TagEditComponent implements OnInit, OnChanges { export class TagEditComponent implements OnInit, OnChanges {
@Input() files: File[] = []; @Input() files: File[] = [];
@Output() tagEditEvent = new EventEmitter<TagEditComponent>();
public tags: Tag[] = []; public tags: Tag[] = [];
public allTags: Tag[] = []; public allTags: Tag[] = [];
@ -84,10 +85,14 @@ export class TagEditComponent implements OnInit, OnChanges {
this.fileTags[file.id] = await this.tagService.changeFileTags( this.fileTags[file.id] = await this.tagService.changeFileTags(
file.id, file.id,
addedTags, removedTags); addedTags, removedTags);
if (addedTags.length > 0) {
await this.tagService.loadTags();
}
} }
this.mapFileTagsToTagList(); this.mapFileTagsToTagList();
const index = this.tags.indexOf(tag); const index = this.tags.indexOf(tag);
index >= 0 && this.tagScroll.scrollToIndex(index); index >= 0 && this.tagScroll.scrollToIndex(index);
this.tagEditEvent.emit(this);
} }
async addTag(tag: Tag) { async addTag(tag: Tag) {
@ -101,6 +106,8 @@ export class TagEditComponent implements OnInit, OnChanges {
this.mapFileTagsToTagList(); this.mapFileTagsToTagList();
const index = this.tags.indexOf(tag); const index = this.tags.indexOf(tag);
index >= 0 && this.tagScroll.scrollToIndex(index); index >= 0 && this.tagScroll.scrollToIndex(index);
this.tagEditEvent.emit(this);
await this.tagService.loadTags();
} }
public async removeTag(tag: Tag) { public async removeTag(tag: Tag) {
@ -114,6 +121,7 @@ export class TagEditComponent implements OnInit, OnChanges {
} }
this.mapFileTagsToTagList(); this.mapFileTagsToTagList();
this.loading = false; this.loading = false;
this.tagEditEvent.emit(this);
} }
private async loadFileTags() { private async loadFileTags() {

Loading…
Cancel
Save