1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

code fixes

This commit is contained in:
Matthias Kretschmann 2019-09-10 00:15:13 +02:00
parent 73c7624873
commit 1f7845aa22
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 57 additions and 59 deletions

View File

@ -10,6 +10,8 @@ export default class AssetsUser extends PureComponent<
{ list?: boolean; recent?: number }, { list?: boolean; recent?: number },
{ results: any[]; isLoading: boolean } { results: any[]; isLoading: boolean }
> { > {
public static contextType = User
public state = { results: [], isLoading: true } public state = { results: [], isLoading: true }
public _isMounted = false public _isMounted = false
@ -58,9 +60,12 @@ export default class AssetsUser extends PureComponent<
public render() { public render() {
const { account } = this.context const { account } = this.context
const { recent, list } = this.props
const { isLoading, results } = this.state
if (!account) return null
return ( return (
account && (
<div className={styles.assetsUser}> <div className={styles.assetsUser}>
{this.props.recent && ( {this.props.recent && (
<h2 className={styles.subTitle}> <h2 className={styles.subTitle}>
@ -68,26 +73,21 @@ export default class AssetsUser extends PureComponent<
</h2> </h2>
)} )}
{this.state.isLoading ? ( {isLoading ? (
<Spinner /> <Spinner />
) : this.state.results.length ? ( ) : results.length ? (
<> <>
{this.state.results {results
.slice( .slice(0, recent ? recent : undefined)
0,
this.props.recent
? this.props.recent
: undefined
)
.filter(asset => !!asset) .filter(asset => !!asset)
.map((asset: any) => ( .map((asset: any) => (
<AssetTeaser <AssetTeaser
list={this.props.list} list={list}
key={asset.id} key={asset.id}
asset={asset} asset={asset}
/> />
))} ))}
{this.props.recent && ( {recent && (
<Link className={styles.link} to="/history"> <Link className={styles.link} to="/history">
All Data Sets All Data Sets
</Link> </Link>
@ -101,8 +101,5 @@ export default class AssetsUser extends PureComponent<
)} )}
</div> </div>
) )
)
} }
} }
AssetsUser.contextType = User

View File

@ -7,23 +7,24 @@ const cleanupContentType = (contentType: string) => {
let contentTypeCleaned let contentTypeCleaned
// TODO: add all the possible archive & compression MIME types // TODO: add all the possible archive & compression MIME types
if ( switch (contentType) {
contentType === 'application/x-lzma' || case 'application/x-lzma':
contentType === 'application/x-xz' || case 'application/x-xz':
contentType === 'application/x-tar' || case 'application/x-tar':
contentType === 'application/x-gtar' || case 'application/x-gtar':
contentType === 'application/x-bzip2' || case 'application/x-bzip2':
contentType === 'application/x-gzip' || case 'application/x-gzip':
contentType === 'application/x-7z-compressed' || case 'application/x-7z-compressed':
contentType === 'application/x-rar-compressed' || case 'application/x-rar-compressed':
contentType === 'application/x-zip-compressed' || case 'application/x-zip-compressed':
contentType === 'application/x-apple-diskimage' case 'application/x-apple-diskimage':
) {
contentTypeCleaned = contentTypeSplit contentTypeCleaned = contentTypeSplit
.replace('x-', '') .replace('x-', '')
.replace('-compressed', '') .replace('-compressed', '')
} else { break
default:
contentTypeCleaned = contentTypeSplit contentTypeCleaned = contentTypeSplit
break
} }
// Manual replacements // Manual replacements