Skip to content

Commit c103123

Browse files
committed
fix uploading logic & pass correct params in initial view selection dialog
1 parent e422855 commit c103123

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

frontend/src/features/collections/collection-replay-dialog.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ export class CollectionStartPageDialog extends BtrixElement {
298298
homeView === HomeView.URL &&
299299
useThumbnail === "on" &&
300300
this.selectedSnapshot &&
301-
this.collection?.homeUrlPageId !== this.selectedSnapshot.pageId;
301+
this.collection?.thumbnailSource?.urlPageId !==
302+
this.selectedSnapshot.pageId;
302303
// TODO get filename from rwp?
303304
const fileName = `page-thumbnail_${this.selectedSnapshot?.pageId}.jpeg`;
304305
let file: File | undefined;
@@ -325,12 +326,22 @@ export class CollectionStartPageDialog extends BtrixElement {
325326

326327
if (shouldUpload) {
327328
try {
328-
if (!file || !fileName) throw new Error("file or fileName missing");
329-
await this.api.upload(
330-
`/orgs/${this.orgId}/collections/${this.collectionId}/thumbnail?filename=${fileName}`,
331-
file,
332-
);
333-
await this.updateThumbnail({ defaultThumbnailName: null });
329+
if (!file || !fileName || !this.selectedSnapshot)
330+
throw new Error("file or fileName missing");
331+
const searchParams = new URLSearchParams({
332+
filename: fileName,
333+
sourceUrl: this.selectedSnapshot.url,
334+
sourceTs: this.selectedSnapshot.ts,
335+
sourcePageId: this.selectedSnapshot.pageId,
336+
});
337+
const tasks = [
338+
this.api.upload(
339+
`/orgs/${this.orgId}/collections/${this.collectionId}/thumbnail?${searchParams.toString()}`,
340+
file,
341+
),
342+
this.updateThumbnail({ defaultThumbnailName: null }),
343+
];
344+
await Promise.all(tasks);
334345

335346
this.notify.toast({
336347
message: msg("Home view and collection thumbnail updated."),

0 commit comments

Comments
 (0)