Skip to content

Commit

Permalink
Disable creating new deletion mappings when mass-removing tags in 580+
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Jul 7, 2024
1 parent ff09671 commit 031abce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/app/hydrus-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ export class HydrusApiService {
service_names_to_tags?: ServiceNamesOrKeysToTags,
service_keys_to_tags?: ServiceNamesOrKeysToTags,
service_names_to_actions_to_tags?: ServiceNamesOrKeysToActionsToTags,
service_keys_to_actions_to_tags?: ServiceNamesOrKeysToActionsToTags
service_keys_to_actions_to_tags?: ServiceNamesOrKeysToActionsToTags,
override_previously_deleted_mappings?: boolean, // added in hydrus v580
create_new_deleted_mappings?: boolean // added in hydrus v580
} & HydrusRequestFiles) {
return this.apiPost<void>('add_tags/add_tags', data);
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/hydrus-tags.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ export class HydrusTagsService {
)
}

deleteTagsFromLocalServiceFileIDs(file_ids: number[], tags: string[], serviceKey: string) {
deleteTagsFromLocalServiceFileIDs(file_ids: number[], tags: string[], serviceKey: string, create_new_deleted_mappings = false) {
return this.api.addTags(
{
file_ids,
service_keys_to_actions_to_tags: {
[serviceKey]: {
"1": tags
}
}
},
create_new_deleted_mappings
}
)
}
Expand Down
7 changes: 5 additions & 2 deletions src/app/image-list-loader/image-list-loader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getLocalTagServices } from '../hydrus-services';
import { TagInputDialogComponent } from '../tag-input-dialog/tag-input-dialog.component';
import { HydrusTagsService } from '../hydrus-tags.service';
import { union } from 'set-utilities';
import { HydrusVersionService } from '../hydrus-version.service';

@Component({
selector: 'app-image-list-loader',
Expand Down Expand Up @@ -48,7 +49,8 @@ export class ImageListLoaderComponent implements OnInit, OnChanges {
private snackbar: MatSnackBar,
private dialog: MatDialog,
private errorService: ErrorService,
private tagsService: HydrusTagsService
private tagsService: HydrusTagsService,
private versionService: HydrusVersionService
) {

}
Expand Down Expand Up @@ -242,7 +244,8 @@ export class ImageListLoaderComponent implements OnInit, OnChanges {
})
const dialogResult = await firstValueFrom(tagsDialog.afterClosed());
if (dialogResult) {
if (!await ConfirmDialogComponent.confirmPromise(this.dialog, {
// the ability to disable creating new deleted mappings for tags that weren't on the file to begin with was added in hydrus v580
if (!await firstValueFrom(this.versionService.isAtLeastVersion(580)) && !await ConfirmDialogComponent.confirmPromise(this.dialog, {
title: 'Delete tags from selected files?',
description: `This will attempt to delete the selected tags from ${this.numSelected()} files. A deletion record will be created for the tags on all selected files, including those that do not currently have the tags.`,
})) return;
Expand Down

0 comments on commit 031abce

Please sign in to comment.