mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2025-12-23 23:02:58 +00:00
Added temporary flag, auto-remove profile when tags list is empty
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user