Skip to content

Commit

Permalink
CB-4681 fix: review
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Feb 27, 2024
1 parent 6b023a7 commit 4ad39e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface IResultSetDataContentAction {
isBlobTruncated: (element: IResultSetElementKey) => boolean;
isTextTruncated: (element: IResultSetElementKey) => boolean;
isDownloadable: (element: IResultSetElementKey) => boolean;
getFileDataUrl: (element: IResultSetElementKey) => Promise<string>;
resolveFileDataUrl: (element: IResultSetElementKey) => Promise<Blob>;
retrieveBlobFromCache: (element: IResultSetElementKey) => Blob | undefined;
downloadFileData: (element: IResultSetElementKey) => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,6 @@ export class ResultSetDataContentAction extends DatabaseDataAction<any, IDatabas
return fullText;
}

async getFileDataUrl(element: IResultSetElementKey) {
const column = this.data.getColumn(element.column);
const row = this.data.getRowValue(element.row);

if (!row || !column) {
throw new Error('Failed to get value metadata information');
}

const url = await this.source.runTask(async () => {
try {
this.updateCache(element, { loading: true });
return await this.loadDataURL(this.result, column.position, row);
} finally {
this.updateCache(element, { loading: false });
}
});

return url;
}

async resolveFileDataUrl(element: IResultSetElementKey) {
const cachedUrl = this.retrieveBlobFromCache(element);

Expand Down Expand Up @@ -187,6 +167,26 @@ export class ResultSetDataContentAction extends DatabaseDataAction<any, IDatabas
this.clearCache();
}

private async getFileDataUrl(element: IResultSetElementKey) {
const column = this.data.getColumn(element.column);
const row = this.data.getRowValue(element.row);

if (!row || !column) {
throw new Error('Failed to get value metadata information');
}

const url = await this.source.runTask(async () => {
try {
this.updateCache(element, { loading: true });
return await this.loadDataURL(this.result, column.position, row);
} finally {
this.updateCache(element, { loading: false });
}
});

return url;
}

private async loadFileFullText(result: IDatabaseResultSet, columnIndex: number, row: IResultSetValue[]) {
if (!result.id) {
throw new Error("Result's id must be provided");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export const ImageValuePresentation: TabContainerPanelComponent<IDataValuePanelP
}

if (this.cacheBlob) {
// TODO: this object must be released with URL.revokeObjectURL()
// it also can be released by the browser after some time
// what leads to image not accessible
return URL.createObjectURL(this.cacheBlob);
}

Expand Down

0 comments on commit 4ad39e7

Please sign in to comment.