1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-24 07:12:57 +00:00

Added temporary flag, auto-remove profile when tags list is empty

This commit is contained in:
2024-12-23 21:45:09 +04:00
parent a8a27654fc
commit ac85938355
2 changed files with 13 additions and 2 deletions

View File

@@ -108,7 +108,8 @@ class TagDropdownWrapper extends BaseComponent {
async #onAddToNewClicked() {
const profile = new MaintenanceProfile(crypto.randomUUID(), {
name: 'Temporary Profile (' + (new Date().toISOString()) + ')',
tags: [this.#tagName]
tags: [this.#tagName],
temporary: true,
});
await profile.save();

View File

@@ -4,6 +4,7 @@ import EntitiesController from "$lib/extension/EntitiesController.ts";
export interface MaintenanceProfileSettings {
name: string;
tags: string[];
temporary: boolean;
}
/**
@@ -17,9 +18,18 @@ export default class MaintenanceProfile extends StorageEntity<MaintenanceProfile
constructor(id: string, settings: Partial<MaintenanceProfileSettings>) {
super(id, {
name: settings.name || '',
tags: settings.tags || []
tags: settings.tags || [],
temporary: settings.temporary ?? false
});
}
async save(): Promise<void> {
if (this.settings.temporary && !this.settings.tags?.length) {
return this.delete();
}
return super.save();
}
public static readonly _entityName = "profiles";
}