Skip to content

Commit

Permalink
[MALI-1050] [JS Sample App] Infinite Loading is observed on downloadi…
Browse files Browse the repository at this point in the history
…ng modified Base64 data (#257)

* [MALI-1050] [JS Sample App] Infinite Loading is observed on downloading modified Base64 data

Updated the callback function  for the download file action in the sample app to throw the error to present in sample app UI.
**Link:**
[MALI-1050](https://jira.rakuten-it.com/jira/browse/MALI-1050)

* [MALI-1050] [JS Sample App] Infinite Loading is observed on downloading modified Base64 data

Resolve prettify lint errors in the last changed files.

**Link:**
[MALI-1050](https://jira.rakuten-it.com/jira/browse/MALI-1050)

* Update js-miniapp-sample/src/pages/file-download.js

Committing the suggested changes.

Co-authored-by: leojoseph.r <[email protected]>

---------

Co-authored-by: leojoseph.r <[email protected]>
  • Loading branch information
GondiTilak and rleojoseph authored Jun 23, 2023
1 parent 07e4a2a commit 250d73c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions js-miniapp-sample/src/pages/file-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,17 @@ const FileDownload = (props: FileDownloadProps) => {

function startFileDownload(url, fileName) {
setIsPermissionGranted(true);
return props.downloadFile(fileName, url, { token: 'test' });
return props
.downloadFile(fileName, url, { token: 'test' })
.then((downloadedFile) => {
console.log('FileDownloadRsponse THEN:', downloadedFile);
props.downloadedFile = downloadedFile;
})
.catch((error) => {
console.log('FileDownloadErrors CATCH:', error);
props.error = error;
props.isLoading = false;
});
}

function handleDownloadClick(url, fileName) {
Expand Down Expand Up @@ -174,7 +184,8 @@ const FileDownload = (props: FileDownloadProps) => {
<div className={classes.info}>
<p>
{!isPermissionGranted && '"FILE_DOWNLOAD" permission not granted.'}
{props.error && props.error.message}
{props.error && 'Download failed: ' + props.error.message}
{props.downloadedFile && 'File Downloaded:' + props.downloadedFile}
</p>
</div>

Expand Down
4 changes: 3 additions & 1 deletion js-miniapp-sample/src/services/filedownload/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ const requestDownloadFile = (
return Promise.resolve(name);
})
.catch((error) => {
console.log('requestDownloadFile: CATCH BLOCK: ', error);
dispatch({
type: FILE_DOWNLOAD_FAILURE,
error,
error: error,
});
throw error;
});
};
};
Expand Down

0 comments on commit 250d73c

Please sign in to comment.