Skip to content

Commit e662daa

Browse files
committed
Show confirmation dialog when loading loras from image history
1 parent 7b1e7b6 commit e662daa

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

src/app/home/options/options.component.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,21 @@
413413
</div>
414414
</div>
415415

416+
<!-- Load LoRAs Prompt -->
417+
<p-dialog [(visible)]="showLoraLoadPrompt" [modal]="true" [dismissableMask]="true" [closable]="true"
418+
[style]="{width: 'min(90vw, 420px)'}" (onHide)="declineLoadHistoryLoras()">
419+
<ng-template pTemplate="header">
420+
<h5>Load LoRAs?</h5>
421+
</ng-template>
422+
<ng-template pTemplate="content">
423+
<p>This image used LoRAs. Load them into your current selection?</p>
424+
</ng-template>
425+
<ng-template pTemplate="footer">
426+
<button class="btn btn-secondary" type="button" (click)="declineLoadHistoryLoras()">No</button>
427+
<button class="btn btn-primary ms-2" type="button" (click)="confirmLoadHistoryLoras()">Yes</button>
428+
</ng-template>
429+
</p-dialog>
430+
416431
<!-- Loras Content Panel -->
417432
<div class="collapse w-100" id="lorasCollapse">
418433
<div class="card card-body" id="lorasDropdown">

src/app/home/options/options.component.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ export class OptionsComponent implements OnInit {
192192
// to show full sized lora image
193193
displayModal: boolean = false;
194194
selectedImageUrl: string | null = null;
195+
showLoraLoadPrompt: boolean = false;
196+
pendingLoraLoadImage: MobiansImage | null = null;
195197

196198
// DB variables
197199
private db: IDBDatabase | null = null;
@@ -1749,11 +1751,31 @@ export class OptionsComponent implements OnInit {
17491751
this.sharedService.setPrompt(image.prompt!);
17501752
}
17511753

1752-
if (image.loras !== undefined) {
1753-
this.selectedLoras = this.resolveHistoryLoras(image.loras);
1754-
this.generationRequest.loras = this.selectedLoras;
1755-
this.updateCreditCost();
1754+
const hasHistoryLoras = Array.isArray(image.loras) && image.loras.length > 0;
1755+
if (hasHistoryLoras) {
1756+
this.pendingLoraLoadImage = image;
1757+
this.showLoraLoadPrompt = true;
1758+
}
1759+
}
1760+
1761+
confirmLoadHistoryLoras() {
1762+
const image = this.pendingLoraLoadImage;
1763+
this.clearLoraLoadPrompt();
1764+
if (!image) {
1765+
return;
17561766
}
1767+
this.selectedLoras = this.resolveHistoryLoras(image.loras);
1768+
this.generationRequest.loras = this.selectedLoras;
1769+
this.updateCreditCost();
1770+
}
1771+
1772+
declineLoadHistoryLoras() {
1773+
this.clearLoraLoadPrompt();
1774+
}
1775+
1776+
private clearLoraLoadPrompt() {
1777+
this.showLoraLoadPrompt = false;
1778+
this.pendingLoraLoadImage = null;
17571779
}
17581780

17591781
async downloadImage(image: MobiansImage, event?: Event) {

0 commit comments

Comments
 (0)