1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-23 23:02:58 +00:00

Merge pull request #72 from koloml/feature/auto-remove-temporary-profiles

Remove temporary profiles when last tag was removed through dropdown
This commit is contained in:
2025-01-03 19:43:27 +04:00
committed by GitHub
3 changed files with 14 additions and 2 deletions

View File

@@ -150,7 +150,8 @@ export 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";
}

View File

@@ -42,6 +42,7 @@
targetProfile.settings.name = profileName;
targetProfile.settings.tags = [...tagsList];
targetProfile.settings.temporary = false;
await targetProfile.save();
await goto('/features/maintenance/' + targetProfile.id);