1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-24 15:04:27 +07:00

chore: improve types and checks

This commit is contained in:
Juan Picado @jotadeveloper 2019-07-28 17:51:46 +02:00
parent 12974ea54f
commit 62431038bb
No known key found for this signature in database
GPG Key ID: 15AA875EF3768142
2 changed files with 3 additions and 3 deletions

View File

@ -17,7 +17,7 @@ export interface Action {
handler?: Function; handler?: Function;
} }
async function downloadHandler(link: string): Promise<void> { export async function downloadHandler(link: string): Promise<void> {
const fileStream: Blob = await api.request(link, 'GET', { const fileStream: Blob = await api.request(link, 'GET', {
headers: { headers: {
['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', ['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
@ -73,7 +73,7 @@ class ActionBar extends Component {
tarball, tarball,
}; };
const renderList = Object.keys(actionsMap).reduce((component, value, key) => { const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => {
const link = actionsMap[value]; const link = actionsMap[value];
if (link && isURL(link)) { if (link && isURL(link)) {
const actionItem: Action = ACTIONS[value]; const actionItem: Action = ACTIONS[value];

View File

@ -21,7 +21,7 @@ function handleResponseType(response: Response): Promise<[boolean, Blob | string
} }
// unfortunatelly on download files there is no header available // unfortunatelly on download files there is no header available
if (response.url.match(/tgz/).length > 0) { if (response.url && response.url.match(/.tgz/) !== null) {
return Promise.all([response.ok, response.blob()]); return Promise.all([response.ok, response.blob()]);
} }
} }