Skip to content

Commit

Permalink
chore(lint): run yarn lint:js --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trollepierre committed Mar 24, 2022
1 parent 8023d00 commit d0729f3
Show file tree
Hide file tree
Showing 85 changed files with 674 additions and 842 deletions.
5 changes: 1 addition & 4 deletions src/components/pushClient/Banner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,4 @@ class BannerClient extends Component {
}
}

export default flow(
translate(),
withClient
)(BannerClient)
export default flow(translate(), withClient)(BannerClient)
4 changes: 2 additions & 2 deletions src/components/pushClient/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const track = element => {

export const isLinux = () =>
window.navigator &&
(window.navigator.appVersion.indexOf('Win') === -1 &&
window.navigator.appVersion.indexOf('Mac') === -1)
window.navigator.appVersion.indexOf('Win') === -1 &&
window.navigator.appVersion.indexOf('Mac') === -1
export const isAndroid = () =>
window.navigator.userAgent &&
window.navigator.userAgent.indexOf('Android') >= 0
Expand Down
34 changes: 18 additions & 16 deletions src/drive/lib/getFileMimetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ const mappingMimetypeSubtype = {
powerpoint: 'slide'
}

export const getFileMimetype = collection => (mime = '', name = '') => {
const mimetype =
mime === 'application/octet-stream'
? getMimetypeFromFilename(name.toLowerCase())
: mime
const [type, subtype] = mimetype.split('/')
if (collection[type]) {
return type
export const getFileMimetype =
collection =>
(mime = '', name = '') => {
const mimetype =
mime === 'application/octet-stream'
? getMimetypeFromFilename(name.toLowerCase())
: mime
const [type, subtype] = mimetype.split('/')
if (collection[type]) {
return type
}
if (type === 'application') {
const existingType = subtype.match(
Object.keys(mappingMimetypeSubtype).join('|')
)
return existingType ? mappingMimetypeSubtype[existingType[0]] : undefined
}
return undefined
}
if (type === 'application') {
const existingType = subtype.match(
Object.keys(mappingMimetypeSubtype).join('|')
)
return existingType ? mappingMimetypeSubtype[existingType[0]] : undefined
}
return undefined
}
6 changes: 3 additions & 3 deletions src/drive/mobile/lib/withPersistentState.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export const withPersistentState = (WrappedComponent, persistenceKey) => {
this.persistedStatePromise.cancel()
}
}
WithPersistentState.displayName = `WithPersistentState(${WrappedComponent.displayName ||
WrappedComponent.name ||
'Component'})`
WithPersistentState.displayName = `WithPersistentState(${
WrappedComponent.displayName || WrappedComponent.name || 'Component'
})`
return WithPersistentState
}
export default withPersistentState
5 changes: 1 addition & 4 deletions src/drive/mobile/modules/authorization/DriveMobileRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,4 @@ const mapDispatchToProps = dispatch => ({
unlink: client => dispatch(unlink(client))
})

export default connect(
null,
mapDispatchToProps
)(withClient(DriveMobileRouter))
export default connect(null, mapDispatchToProps)(withClient(DriveMobileRouter))
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,4 @@ const mapDispatchToProps = dispatch => ({
unlink: (client, clientSettings) => dispatch(unlink(client, clientSettings))
})

export default connect(
mapStateToProps,
mapDispatchToProps
)(UserActionRequired)
export default connect(mapStateToProps, mapDispatchToProps)(UserActionRequired)
6 changes: 2 additions & 4 deletions src/drive/mobile/modules/mediaBackup/FirstUploadModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ const OnlyOnceFirstUploadModal = withPersistentState(
)

const mapStateToProps = state => {
const {
uploading = false,
currentUpload = { messageData: { total: 0 } }
} = state.mobile.mediaBackup
const { uploading = false, currentUpload = { messageData: { total: 0 } } } =
state.mobile.mediaBackup
const { messageData } = currentUpload
return {
uploading:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ const mapStateToProps = state => ({
})

export const UploadStatus = props => {
const {
isEnabled,
isPreparing,
isUploading,
isAborted,
isQuotaReached
} = props
const { isEnabled, isPreparing, isUploading, isAborted, isQuotaReached } =
props
const { t, current, total, progress, serverUrl } = props
const storageUpgradeUrl = serverUrl
? serverUrl.replace(/(\w+)\./, '$1-settings.') + '/#/storage'
Expand Down
86 changes: 41 additions & 45 deletions src/drive/mobile/modules/mediaBackup/duck/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,51 @@ const mediaUploadSucceed = ({ id }) => ({
type: MEDIA_UPLOAD_SUCCESS,
id
})
export const uploadPhoto = (
dirName,
dirID,
photo,
client
) => async dispatch => {
try {
const path = dirName + '/' + photo.fileName
await client.collection('io.cozy.files').statByPath(path)
export const uploadPhoto =
(dirName, dirID, photo, client) => async dispatch => {
try {
const path = dirName + '/' + photo.fileName
await client.collection('io.cozy.files').statByPath(path)

dispatch(mediaUploadSucceed(photo))
return
} catch (_) {
// logger.log('_')
} // if an exception is throw, the file doesn't exist yet and we can safely upload it
dispatch(mediaUploadSucceed(photo))
return
} catch (_) {
// logger.log('_')
} // if an exception is throw, the file doesn't exist yet and we can safely upload it

const MILLISECOND = 1
const SECOND = 1000 * MILLISECOND
const MINUTE = 60 * SECOND
const maxBackupTime = 5 * MINUTE
const timeout = setTimeout(() => {
logger.info(JSON.stringify(photo))
logException(`Backup duration exceeded ${maxBackupTime} milliseconds`)
}, maxBackupTime)
try {
const onProgressUpdate = progress => {
dispatch({ type: CURRENT_UPLOAD_PROGRESS, progress })
}
const MILLISECOND = 1
const SECOND = 1000 * MILLISECOND
const MINUTE = 60 * SECOND
const maxBackupTime = 5 * MINUTE
const timeout = setTimeout(() => {
logger.info(JSON.stringify(photo))
logException(`Backup duration exceeded ${maxBackupTime} milliseconds`)
}, maxBackupTime)
try {
const onProgressUpdate = progress => {
dispatch({ type: CURRENT_UPLOAD_PROGRESS, progress })
}

const onThumbnailGenerated = () => {}
const onThumbnailGenerated = () => {}

await uploadLibraryItem(
dirID,
photo,
throttle(onProgressUpdate, 500),
onThumbnailGenerated
)
clearTimeout(timeout)
dispatch(mediaUploadSucceed(photo))
} catch (err) {
if (err.code && parseInt(err.code) === ERROR_CODE_TOO_LARGE) {
await uploadLibraryItem(
dirID,
photo,
throttle(onProgressUpdate, 500),
onThumbnailGenerated
)
clearTimeout(timeout)
dispatch({ type: MEDIA_UPLOAD_QUOTA })
} else {
logger.warn('startMediaBackup upload item error')
logger.warn(JSON.stringify(err))
logger.info(JSON.stringify(photo))
const reason = err.message ? err.message : JSON.stringify(err)
logException('Backup error: ' + reason, null, ['backup error'])
dispatch(mediaUploadSucceed(photo))
} catch (err) {
if (err.code && parseInt(err.code) === ERROR_CODE_TOO_LARGE) {
clearTimeout(timeout)
dispatch({ type: MEDIA_UPLOAD_QUOTA })
} else {
logger.warn('startMediaBackup upload item error')
logger.warn(JSON.stringify(err))
logger.info(JSON.stringify(photo))
const reason = err.message ? err.message : JSON.stringify(err)
logException('Backup error: ' + reason, null, ['backup error'])
}
}
}
}
Loading

0 comments on commit d0729f3

Please sign in to comment.