Skip to content

TagSpaces is an offline, open source, document manager with tagging support

auto linting project

Ilian Sapundshiev3c4ec128dda8
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 17a5dd062..b89dd0dea 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -257,8 +257,10 @@ class EntryContainer extends React.Component<Props, State> {
// } else {
// if (this.fileViewer) {
- // this.fileViewer.contentWindow.onbeforeunload = () => {
- // console.log('Unloading');
+ // this.fileViewer.contentWindow.onbeforeunload = e => {
+ // console.log('Unloading ' + JSON.stringify(e));
+ // // e.preventDefault();
+ // e.returnValue = 'Do you really want to leave this page?';
// };
// }
@@ -574,7 +576,8 @@ class EntryContainer extends React.Component<Props, State> {
document.webkitExitFullscreen();
this.setState({ isFullscreen: false });
return;
- } else if (this.state.isFullscreen && document.exitFullscreen) {
+ }
+ if (this.state.isFullscreen && document.exitFullscreen) {
// TODO exit fullscreen firefox does not work
document
.exitFullscreen()
@@ -767,7 +770,7 @@ class EntryContainer extends React.Component<Props, State> {
>
<CopyContentIcon />
</IconButton>
- )*/}
+ ) */}
{!this.props.isReadOnlyMode && (
<IconButton
title={i18n.t('core:deleteEntry')}
@@ -850,7 +853,7 @@ class EntryContainer extends React.Component<Props, State> {
</div>
);
- renderFileView = fileOpenerURL => {
+ renderFileView = fileOpenerURL => (
// if (AppConfig.isElectron) {
// return (
// <webview
@@ -865,20 +868,18 @@ class EntryContainer extends React.Component<Props, State> {
// />
// );
// }
- return (
- <iframe
- ref={fileViewer => {
- this.fileViewer = fileViewer;
- }}
- className={this.props.classes.fileOpener}
- src={fileOpenerURL}
- allowFullScreen
- sandbox="allow-same-origin allow-scripts"
- title={i18n.t('core:fileViewer')}
- id="FileViewer"
- />
- );
- };
+ <iframe
+ ref={fileViewer => {
+ this.fileViewer = fileViewer;
+ }}
+ className={this.props.classes.fileOpener}
+ src={fileOpenerURL}
+ allowFullScreen
+ sandbox="allow-same-origin allow-scripts"
+ title={i18n.t('core:fileViewer')}
+ id="FileViewer"
+ />
+ );
setPropertiesEditMode = (editMode: boolean) => {
this.isPropertiesEditMode = editMode;
@@ -974,9 +975,9 @@ class EntryContainer extends React.Component<Props, State> {
this.setState({ isSaveBeforeCloseConfirmDialogOpened: false });
}
}}
- cancelDialogTID={'cancelSaveBeforeCloseDialog'}
- confirmDialogTID={'confirmSaveBeforeCloseDialog'}
- confirmDialogContentTID={'confirmDialogContent'}
+ cancelDialogTID="cancelSaveBeforeCloseDialog"
+ confirmDialogTID="confirmSaveBeforeCloseDialog"
+ confirmDialogContentTID="confirmDialogContent"
/>
<ConfirmDialog
open={this.state.isSaveBeforeReloadConfirmDialogOpened}
@@ -984,7 +985,7 @@ class EntryContainer extends React.Component<Props, State> {
this.setState({ isSaveBeforeReloadConfirmDialogOpened: false });
}}
title={i18n.t('core:confirm')}
- content={'File was modified, do you want to save the changes?'}
+ content="File was modified, do you want to save the changes?"
confirmCallback={result => {
if (result) {
this.startSavingFile();
@@ -999,9 +1000,9 @@ class EntryContainer extends React.Component<Props, State> {
}
});
}}
- cancelDialogTID={'cancelSaveBeforeCloseDialog'}
- confirmDialogTID={'confirmSaveBeforeCloseDialog'}
- confirmDialogContentTID={'confirmDialogContent'}
+ cancelDialogTID="cancelSaveBeforeCloseDialog"
+ confirmDialogTID="confirmSaveBeforeCloseDialog"
+ confirmDialogContentTID="confirmDialogContent"
/>
<ConfirmDialog
open={this.state.isDeleteEntryModalOpened}
@@ -1027,9 +1028,9 @@ class EntryContainer extends React.Component<Props, State> {
this.props.deleteFile(currentEntry.path);
}
}}
- cancelDialogTID={'cancelSaveBeforeCloseDialog'}
- confirmDialogTID={'confirmSaveBeforeCloseDialog'}
- confirmDialogContentTID={'confirmDialogContent'}
+ cancelDialogTID="cancelSaveBeforeCloseDialog"
+ confirmDialogTID="confirmSaveBeforeCloseDialog"
+ confirmDialogContentTID="confirmDialogContent"
/>
<AddRemoveTagsDialog
open={isEditTagsModalOpened}
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 4d6e5ef41..72b7061d4 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -493,9 +493,9 @@ class EntryProperties extends Component<Props, State> {
handleCloseTagMenu = () => this.setState({ tagMenuOpened: false });
handleInputChange = (event: any) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
// @ts-ignore
this.setState({ [name]: value });
diff --git a/app/components/FileSourceDnd.tsx b/app/components/FileSourceDnd.tsx
index 6776f78e9..a14b9c805 100644
--- a/app/components/FileSourceDnd.tsx
+++ b/app/components/FileSourceDnd.tsx
@@ -17,8 +17,8 @@
*/
import React from 'react';
-import { DragSource } from 'react-dnd';
-import { ConnectDragSource } from 'react-dnd';
+import { DragSource, ConnectDragSource } from 'react-dnd';
+
import DragItemTypes from './DragItemTypes';
interface Props {
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index 6bacef439..e4fd0fdf0 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -313,7 +313,8 @@ class FolderContainer extends React.Component<Props, State> {
this.props.currentDirectoryPath.length < 2
) {
return <WelcomePanelAsync />;
- } else if (this.state.currentPerspective === 'gallery') {
+ }
+ if (this.state.currentPerspective === 'gallery') {
return (
<GalleryPerspectiveAsync
directoryContent={this.props.directoryContent}
@@ -322,7 +323,8 @@ class FolderContainer extends React.Component<Props, State> {
switchPerspective={this.switchPerspective}
/>
);
- } else if (this.state.currentPerspective === 'treeviz') {
+ }
+ if (this.state.currentPerspective === 'treeviz') {
return (
<TreeVizPerspectiveAsync
directoryContent={this.props.directoryContent}
@@ -331,7 +333,8 @@ class FolderContainer extends React.Component<Props, State> {
switchPerspective={this.switchPerspective}
/>
);
- } else if (this.state.currentPerspective === 'mapique') {
+ }
+ if (this.state.currentPerspective === 'mapique') {
return (
<MapiquePerspectiveAsync
directoryContent={this.props.directoryContent}
diff --git a/app/components/PerspectiveManager.tsx b/app/components/PerspectiveManager.tsx
index 3dcd8366f..6fd8ff3b7 100644
--- a/app/components/PerspectiveManager.tsx
+++ b/app/components/PerspectiveManager.tsx
@@ -28,7 +28,7 @@ interface Props {
class PerspectiveManager extends React.Component<Props> {
render() {
- const classes = this.props.classes;
+ const { classes } = this.props;
return (
<div className={classes.panel} style={this.props.style}>
diff --git a/app/components/Search.tsx b/app/components/Search.tsx
index a9ec98860..7b7d73d33 100644
--- a/app/components/Search.tsx
+++ b/app/components/Search.tsx
@@ -129,10 +129,10 @@ class Search extends React.Component<Props, State> {
};
handleInputChange = event => {
- const target = event.target;
+ const { target } = event;
const value =
target.type && target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
@@ -149,8 +149,8 @@ class Search extends React.Component<Props, State> {
};
handleTimePeriodChange = event => {
- const target = event.target;
- const value = target.value;
+ const { target } = event;
+ const { value } = target;
let tagTimePeriodHelper = '';
const { fromDateTime, toDateTime } = extractTimePeriod(value);
@@ -173,8 +173,8 @@ class Search extends React.Component<Props, State> {
};
handlePlaceChange = event => {
- const target = event.target;
- const value = target.value;
+ const { target } = event;
+ const { value } = target;
let lat = null;
let lon = null;
let tagPlaceHelper;
@@ -391,7 +391,7 @@ class Search extends React.Component<Props, State> {
placeholderText={i18n.t('core:selectTags')}
tags={this.state.tagsAND}
handleChange={this.handleTagFieldChange}
- tagSearchType={'tagsAND'}
+ tagSearchType="tagsAND"
/>
</FormControl>
<Typography
@@ -406,7 +406,7 @@ class Search extends React.Component<Props, State> {
placeholderText={i18n.t('core:selectTags')}
tags={this.state.tagsOR}
handleChange={this.handleTagFieldChange}
- tagSearchType={'tagsOR'}
+ tagSearchType="tagsOR"
/>
</FormControl>
<Typography
@@ -421,7 +421,7 @@ class Search extends React.Component<Props, State> {
placeholderText={i18n.t('core:selectTags')}
tags={this.state.tagsNOT}
handleChange={this.handleTagFieldChange}
- tagSearchType={'tagsNOT'}
+ tagSearchType="tagsNOT"
/>
</FormControl>
<FormControl
@@ -554,22 +554,28 @@ class Search extends React.Component<Props, State> {
<MenuItem value="">{i18n.t('core:sizeAny')}</MenuItem>
<MenuItem value="sizeEmpty">{i18n.t('core:sizeEmpty')}</MenuItem>
<MenuItem value="sizeTiny">
- {i18n.t('core:sizeTiny')}&nbsp;(&lt;&nbsp;10KB)
+ {i18n.t('core:sizeTiny')}
+ &nbsp;(&lt;&nbsp;10KB)
</MenuItem>
<MenuItem value="sizeVerySmall">
- {i18n.t('core:sizeVerySmall')}&nbsp;(&lt;&nbsp;100KB)
+ {i18n.t('core:sizeVerySmall')}
+ &nbsp;(&lt;&nbsp;100KB)
</MenuItem>
<MenuItem value="sizeSmall">
- {i18n.t('core:sizeSmall')}&nbsp;(&lt;&nbsp;1MB)
+ {i18n.t('core:sizeSmall')}
+ &nbsp;(&lt;&nbsp;1MB)
</MenuItem>
<MenuItem value="sizeMedium">
- {i18n.t('core:sizeMedium')}&nbsp;(&lt;&nbsp;50MB)
+ {i18n.t('core:sizeMedium')}
+ &nbsp;(&lt;&nbsp;50MB)
</MenuItem>
<MenuItem value="sizeLarge">
- {i18n.t('core:sizeLarge')}&nbsp;(&lt;&nbsp;1GB)
+ {i18n.t('core:sizeLarge')}
+ &nbsp;(&lt;&nbsp;1GB)
</MenuItem>
<MenuItem value="sizeHuge">
- {i18n.t('core:sizeHuge')}&nbsp;(&gt;&nbsp;1GB)
+ {i18n.t('core:sizeHuge')}
+ &nbsp;(&gt;&nbsp;1GB)
</MenuItem>
</Select>
</FormControl>
diff --git a/app/components/TagContainerDnd.tsx b/app/components/TagContainerDnd.tsx
index 6f3c6a9b7..d2da00b99 100644
--- a/app/components/TagContainerDnd.tsx
+++ b/app/components/TagContainerDnd.tsx
@@ -17,8 +17,8 @@
*/
import React from 'react';
-import { DragSource } from 'react-dnd';
-import { ConnectDragPreview, ConnectDragSource } from 'react-dnd';
+import { DragSource, ConnectDragPreview, ConnectDragSource } from 'react-dnd';
+
import DragItemTypes from './DragItemTypes';
import TagContainer from './TagContainer';
import { TagGroup, Tag } from '../reducers/taglibrary';
diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsx
index 8fd8fb027..6b2347d73 100644
--- a/app/components/TagLibrary.tsx
+++ b/app/components/TagLibrary.tsx
@@ -348,8 +348,8 @@ class TagLibrary extends React.Component<Props, State> {
this.props.removeTagGroup(this.state.selectedTagGroupEntry.uuid);
}
}}
- cancelDialogTID={'cancelDeleteTagGroupDialog'}
- confirmDialogTID={'confirmDeleteTagGroupDialog'}
+ cancelDialogTID="cancelDeleteTagGroupDialog"
+ confirmDialogTID="confirmDeleteTagGroupDialog"
/>
<CreateTagGroupDialog
key={uuidv1()}
diff --git a/app/components/TagsSelect.tsx b/app/components/TagsSelect.tsx
index a748ccefd..3334390fe 100644
--- a/app/components/TagsSelect.tsx
+++ b/app/components/TagsSelect.tsx
@@ -167,7 +167,7 @@ function MultiValue(props) {
<TagContainer
key={props.data.id || props.data.title}
tag={props.data}
- tagMode={'remove'}
+ tagMode="remove"
deleteIcon={<CloseIcon {...props.removeProps} />}
/>
);
diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsx
index 8f9019c51..2ef8fc43b 100644
--- a/app/components/WelcomePanel.tsx
+++ b/app/components/WelcomePanel.tsx
@@ -20,8 +20,6 @@ import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { withStyles } from '@material-ui/core/styles';
-import WelcomeLogo from '../assets/images/welcome-logo.png';
-import WelcomeBackground from '../assets/images/background.png';
// import { getLocations, type Location } from '../reducers/locations';
import Button from '@material-ui/core/Button';
import List from '@material-ui/core/List';
@@ -37,6 +35,8 @@ import NewFeatureIcon from '@material-ui/icons/Gesture';
import SocialIcon from '@material-ui/icons/ThumbUp';
import Social2Icon from '@material-ui/icons/Mood';
import KeyShortcutsIcon from '@material-ui/icons/Keyboard';
+import WelcomeBackground from '../assets/images/background.png';
+import WelcomeLogo from '../assets/images/welcome-logo.png';
import { actions as AppActions } from '../reducers/app';
import i18n from '../services/i18n';
import {
diff --git a/app/components/dialogs/CreateDirectoryDialog.tsx b/app/components/dialogs/CreateDirectoryDialog.tsx
index e44b22232..178f58cc8 100644
--- a/app/components/dialogs/CreateDirectoryDialog.tsx
+++ b/app/components/dialogs/CreateDirectoryDialog.tsx
@@ -102,7 +102,7 @@ const CreateDirectoryDialog = (props: Props) => {
name="name"
label={i18n.t('core:createNewDirectoryTitleName')}
onChange={event => {
- const target = event.target;
+ const { target } = event;
setName(target.value);
}}
value={name}
diff --git a/app/components/dialogs/CreateFileDialog.tsx b/app/components/dialogs/CreateFileDialog.tsx
index 7608375c9..eddcd3c8d 100644
--- a/app/components/dialogs/CreateFileDialog.tsx
+++ b/app/components/dialogs/CreateFileDialog.tsx
@@ -107,14 +107,14 @@ class CreateFileDialog extends React.Component<Props, State> {
fileName;
handleTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
this.setState({ fileType: target.value });
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
{
diff --git a/app/components/dialogs/CreateLocationDialog.tsx b/app/components/dialogs/CreateLocationDialog.tsx
index 4e518034c..45ff66790 100644
--- a/app/components/dialogs/CreateLocationDialog.tsx
+++ b/app/components/dialogs/CreateLocationDialog.tsx
@@ -116,9 +116,9 @@ class CreateLocationDialog extends React.Component<Props, State> {
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
if (target.type === 'radio') {
// type is changed (skip validation)
// @ts-ignore
@@ -174,7 +174,8 @@ class CreateLocationDialog extends React.Component<Props, State> {
resolve(!disableConfirmButton)
)
);
- } else if (this.state.type === locationType.TYPE_CLOUD) {
+ }
+ if (this.state.type === locationType.TYPE_CLOUD) {
let cloudErrorTextName = false;
// let cloudErrorTextPath = false;
let cloudErrorAccessKey = false;
diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsx
index 5e42df3a4..98fa8efc5 100644
--- a/app/components/dialogs/CreateTagGroupDialog.tsx
+++ b/app/components/dialogs/CreateTagGroupDialog.tsx
@@ -48,8 +48,6 @@ interface State {
title: string;
color: string;
textcolor: string;
- children: string;
- expanded: boolean;
}
class CreateTagGroupDialog extends React.Component<Props, State> {
@@ -59,17 +57,15 @@ class CreateTagGroupDialog extends React.Component<Props, State> {
inputError: false,
disableConfirmButton: true,
title: '',
- children: '',
color: this.props.color,
textcolor: this.props.textcolor,
- expanded: true,
uuid: ''
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
diff --git a/app/components/dialogs/CreateTagsDialog.tsx b/app/components/dialogs/CreateTagsDialog.tsx
index bbba376d4..cccf27746 100644
--- a/app/components/dialogs/CreateTagsDialog.tsx
+++ b/app/components/dialogs/CreateTagsDialog.tsx
@@ -39,7 +39,6 @@ interface Props {
interface State {
inputError: boolean;
disableConfirmButton: boolean;
- open: boolean;
tagTitle: string;
}
@@ -47,14 +46,13 @@ class CreateTagsDialog extends React.Component<Props, State> {
state = {
inputError: false,
disableConfirmButton: true,
- open: false,
tagTitle: ''
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
@@ -76,7 +74,7 @@ class CreateTagsDialog extends React.Component<Props, State> {
onConfirm = () => {
if (!this.state.disableConfirmButton) {
- this.setState({ open: false, disableConfirmButton: true });
+ this.setState({ disableConfirmButton: true });
this.props.addTag(
this.state.tagTitle,
this.props.selectedTagGroupEntry.uuid
diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsx
index 77b0e0daf..ecef39609 100644
--- a/app/components/dialogs/EditEntryTagDialog.tsx
+++ b/app/components/dialogs/EditEntryTagDialog.tsx
@@ -126,7 +126,7 @@ const EditEntryTagDialog = (props: Props) => {
autoFocus
label={i18n.t('core:editTag')}
onChange={event => {
- const target = event.target;
+ const { target } = event;
setTitle(target.value);
}}
value={title}
diff --git a/app/components/dialogs/EditLocationDialog.tsx b/app/components/dialogs/EditLocationDialog.tsx
index 32f56e6fa..cf7549ba0 100644
--- a/app/components/dialogs/EditLocationDialog.tsx
+++ b/app/components/dialogs/EditLocationDialog.tsx
@@ -134,9 +134,9 @@ class EditLocationDialog extends React.Component<Props, State> {
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
if (target.type === 'radio') {
// type is changed (skip validation)
// @ts-ignore
@@ -164,8 +164,8 @@ class EditLocationDialog extends React.Component<Props, State> {
if (this.state.type === locationType.TYPE_CLOUD) {
let cloudErrorTextName = false;
// let cloudErrorTextPath = false;
- let cloudErrorAccessKey = false;
- let cloudErrorSecretAccessKey = false;
+ const cloudErrorAccessKey = false;
+ const cloudErrorSecretAccessKey = false;
let cloudErrorBucketName = false;
let cloudErrorRegion = false;
let disableConfirmButton = false;
diff --git a/app/components/dialogs/EditTagDialog.tsx b/app/components/dialogs/EditTagDialog.tsx
index e0445a22a..26bd4e422 100644
--- a/app/components/dialogs/EditTagDialog.tsx
+++ b/app/components/dialogs/EditTagDialog.tsx
@@ -76,9 +76,9 @@ class EditTagDialog extends React.Component<Props, State> {
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
@@ -198,9 +198,9 @@ class EditTagDialog extends React.Component<Props, State> {
color: '#808080'
}}
>
- <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(
- 'core:modifiedDate'
- )}: `}</span>
+ <span className="text" style={{ fontWeight: 600 }}>
+ {`${i18n.t('core:modifiedDate')}: `}
+ </span>
<time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>
</div>
)}
diff --git a/app/components/dialogs/EditTagGroupDialog.tsx b/app/components/dialogs/EditTagGroupDialog.tsx
index 855bac301..ab2bfb04e 100644
--- a/app/components/dialogs/EditTagGroupDialog.tsx
+++ b/app/components/dialogs/EditTagGroupDialog.tsx
@@ -79,9 +79,9 @@ class EditTagGroupDialog extends React.Component<Props, State> {
};
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
@@ -200,9 +200,9 @@ class EditTagGroupDialog extends React.Component<Props, State> {
color: '#808080'
}}
>
- <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(
- 'core:modifiedDate'
- )}: `}</span>
+ <span className="text" style={{ fontWeight: 600 }}>
+ {`${i18n.t('core:modifiedDate')}: `}
+ </span>
<time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>
</div>
)}
diff --git a/app/components/dialogs/ImportExportTagGroupsDialog.tsx b/app/components/dialogs/ImportExportTagGroupsDialog.tsx
index 2141f6ca4..12ab0a069 100644
--- a/app/components/dialogs/ImportExportTagGroupsDialog.tsx
+++ b/app/components/dialogs/ImportExportTagGroupsDialog.tsx
@@ -57,28 +57,22 @@ interface Props {
}
interface State {
- errorTextName: boolean;
disableConfirmButton: boolean;
- open: boolean;
tagGroupList: Array<Object>;
- checkedAll: boolean;
selectedAll: boolean;
}
class ImportExportTagGroupsDialog extends React.Component<Props, State> {
state = {
- errorTextName: false,
disableConfirmButton: true,
- open: false,
selectedAll: false,
- checkedAll: false,
tagGroupList: []
};
componentWillReceiveProps = (nextProps: Props) => {
if (nextProps.open === true) {
const tagGroupList = [];
- const tagGroups = nextProps.tagGroups;
+ const { tagGroups } = nextProps;
if (tagGroups) {
tagGroups.map(entry => {
tagGroupList.push({
@@ -90,6 +84,7 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
expanded: entry.expanded,
selected: true
});
+ return true;
});
this.setState(
{ tagGroupList, selectedAll: true },
@@ -114,10 +109,7 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
});
return true;
});
- this.setState(
- { tagGroupList, selectedAll: !this.state.selectedAll },
- this.handleValidation
- );
+ this.setState({ tagGroupList }, this.handleValidation);
};
handleChange = name => (event: any, checked: boolean) => {
@@ -182,37 +174,33 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
}
};
- renderTagGroups = (tagGroup, index) => {
- return (
- <div key={tagGroup.uuid || tagGroup.key}>
- <FormControl component="fieldset">
- <FormGroup>
- <FormControlLabel
- control={
- <Checkbox
- id={tagGroup.uuid || tagGroup.key}
- checked={tagGroup.selected}
- onClick={e =>
- this.handleTagGroup(e, tagGroup.selected, index)
- }
- onChange={e => this.handleChange(e)}
- value={tagGroup.title}
- name={tagGroup.title}
- />
- }
- label={tagGroup.title}
- />
- </FormGroup>
- </FormControl>
- <TagGroupContainer taggroup={tagGroup}>
- {tagGroup.children &&
- tagGroup.children.map((tag: Tag) => (
- <TagContainer tag={tag} tagMode="display" />
- ))}
- </TagGroupContainer>
- </div>
- );
- };
+ renderTagGroups = (tagGroup, index) => (
+ <div key={tagGroup.uuid || tagGroup.key}>
+ <FormControl component="fieldset">
+ <FormGroup>
+ <FormControlLabel
+ control={
+ <Checkbox
+ id={tagGroup.uuid || tagGroup.key}
+ checked={tagGroup.selected}
+ onClick={e => this.handleTagGroup(e, tagGroup.selected, index)}
+ onChange={e => this.handleChange(e)}
+ value={tagGroup.title}
+ name={tagGroup.title}
+ />
+ }
+ label={tagGroup.title}
+ />
+ </FormGroup>
+ </FormControl>
+ <TagGroupContainer taggroup={tagGroup}>
+ {tagGroup.children &&
+ tagGroup.children.map((tag: Tag) => (
+ <TagContainer tag={tag} tagMode="display" />
+ ))}
+ </TagGroupContainer>
+ </div>
+ );
renderTitle = () => {
if (this.props.dialogModeImport) {
@@ -221,18 +209,16 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
return <DialogTitle>{i18n.t('core:exportGroupTagsTitle')}</DialogTitle>;
};
- renderContent = () => {
- return (
- <DialogContent className={this.props.classes.root}>
- <Button color="primary" onClick={this.handleToggleSelectAll}>
- {i18n.t('core:selectAllTagGroups')}
- </Button>
- <FormControl fullWidth={true}>
- {this.state.tagGroupList.map(this.renderTagGroups)}
- </FormControl>
- </DialogContent>
- );
- };
+ renderContent = () => (
+ <DialogContent className={this.props.classes.root}>
+ <Button color="primary" onClick={this.handleToggleSelectAll}>
+ {i18n.t('core:selectAllTagGroups')}
+ </Button>
+ <FormControl fullWidth={true}>
+ {this.state.tagGroupList.map(this.renderTagGroups)}
+ </FormControl>
+ </DialogContent>
+ );
renderActions = () => (
<DialogActions>
diff --git a/app/components/dialogs/MoveCopyFilesDialog.tsx b/app/components/dialogs/MoveCopyFilesDialog.tsx
index 19472cff7..491ab25f4 100644
--- a/app/components/dialogs/MoveCopyFilesDialog.tsx
+++ b/app/components/dialogs/MoveCopyFilesDialog.tsx
@@ -143,7 +143,7 @@ const MoveCopyFilesDialog = (props: Props) => {
fullWidth={true}
data-tid="targetPathInput"
onChange={event => {
- const target = event.target;
+ const { target } = event;
setTargetPath(target.value);
}}
value={targetPath}
diff --git a/app/components/dialogs/OnboardingDialog.tsx b/app/components/dialogs/OnboardingDialog.tsx
index 72b21542a..fff26b197 100644
--- a/app/components/dialogs/OnboardingDialog.tsx
+++ b/app/components/dialogs/OnboardingDialog.tsx
@@ -66,18 +66,18 @@ const OnboardingDialog = (props: Props) => {
const [activeStep, setActiveStep] = useState(0);
const { fullScreen, open, onClose } = props;
- let maxSteps = 5;
+ const maxSteps = 5;
function handleNext() {
- setActiveStep(activeStep => activeStep + 1);
+ setActiveStep(step => step + 1);
}
function handleBack() {
- setActiveStep(activeStep => activeStep - 1);
+ setActiveStep(step => step - 1);
}
- function handleStepChange(activeStep: number) {
- setActiveStep(activeStep);
+ function handleStepChange(step: number) {
+ setActiveStep(step);
}
function toggleTaggingType() {
@@ -192,7 +192,8 @@ const OnboardingDialog = (props: Props) => {
<strong>sunset</strong> will save this tag in an
additional sidecar file called{' '}
<strong>image.jpg.json</strong> located in a sub folder
- with the name <strong>.ts</strong>
+ with the name
+ <strong>.ts</strong>
</Typography>
}
/>
diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsx
index 147f4e279..d3b07dff4 100644
--- a/app/components/dialogs/RenameFileDialog.tsx
+++ b/app/components/dialogs/RenameFileDialog.tsx
@@ -90,9 +90,9 @@ class RenameFileDialog extends React.Component<Props, State> {
fileName;
handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const target = event.target;
+ const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
+ const { name } = target;
this.setState(
// @ts-ignore
diff --git a/app/components/dialogs/settings/SettingsDialog.tsx b/app/components/dialogs/settings/SettingsDialog.tsx
index 76e74d3dc..32b4d5892 100644
--- a/app/components/dialogs/settings/SettingsDialog.tsx
+++ b/app/components/dialogs/settings/SettingsDialog.tsx
@@ -38,7 +38,7 @@ import { getSettings, actions } from '-/reducers/settings';
import { extend } from '-/utils/misc';
import AppConfig from '-/config';
-const styles: any = theme => ({
+const styles: any = () => ({
mainContent: {
overflowY: AppConfig.isFirefox ? 'auto' : 'overlay'
}
@@ -72,8 +72,6 @@ class SettingsDialog extends React.Component<Props, State> {
isConfirmDialogOpened: false
};
- settingsFileTypeRef;
-
componentWillReceiveProps = nextProps => {
const { settings } = nextProps;
const supportedFileTypes = settings.supportedFileTypes.reduce(
@@ -95,6 +93,8 @@ class SettingsDialog extends React.Component<Props, State> {
});
};
+ settingsFileTypeRef;
+
handleTabClick = (event, currentTab) => {
this.setState({ currentTab });
};
@@ -102,7 +102,7 @@ class SettingsDialog extends React.Component<Props, State> {
onAddFileType = item => {
const { items } = this.state;
this.setState({ items: [...items, item] }, () => {
- const settingsFileTypeRef = this.settingsFileTypeRef;
+ const { settingsFileTypeRef } = this;
const lastFileType = settingsFileTypeRef.querySelector('li:last-child');
lastFileType.scrollIntoView({ behavior: 'smooth' });
});
@@ -240,7 +240,7 @@ class SettingsDialog extends React.Component<Props, State> {
isConfirmDialogOpened: false
});
}}
- title={'Confirm'}
+ title="Confirm"
content={i18n.t('core:confirmFileTypeDeletion')}
confirmCallback={result => {
if (result) {
@@ -248,9 +248,9 @@ class SettingsDialog extends React.Component<Props, State> {
this.removeItem(selectedItem);
}
}}
- cancelDialogTID={'cancelDeleteFileTypeDialog'}
- confirmDialogTID={'confirmDeleteFileTypeDialog'}
- confirmDialogContentTID={'confirmDeleteFileTypeDialogContent'}
+ cancelDialogTID="cancelDeleteFileTypeDialog"
+ confirmDialogTID="confirmDeleteFileTypeDialog"
+ confirmDialogContentTID="confirmDeleteFileTypeDialogContent"
/>
<div
diff --git a/app/components/dialogs/settings/SettingsFileTypes.tsx b/app/components/dialogs/settings/SettingsFileTypes.tsx
index 0cf5b9edc..d4433b7d6 100644
--- a/app/components/dialogs/settings/SettingsFileTypes.tsx
+++ b/app/components/dialogs/settings/SettingsFileTypes.tsx
@@ -119,12 +119,11 @@ class SettingsFileTypes extends Component<Props, State> {
updateItems('id', selectedItem.id, 'color', color);
};
- sanitizeFileTypeInput = fileTypeInput => {
- return fileTypeInput.replace(/[^a-zA-Z0-9 ]/g, '');
- };
+ sanitizeFileTypeInput = fileTypeInput =>
+ fileTypeInput.replace(/[^a-zA-Z0-9 ]/g, '');
render() {
- const classes = this.props.classes;
+ const { classes } = this.props;
const {
items,
selectedItem,
@@ -255,7 +254,7 @@ class SettingsFileTypes extends Component<Props, State> {
<FormControl className={classes.fileTypeColorDialogButton}>
<TransparentBackground>
<Button
- data-tid={'settingsFileTypes_openColorPicker_'}
+ data-tid="settingsFileTypes_openColorPicker_"
className={classes.colorChooserButton}
style={{
backgroundColor: `${item.color}`,
@@ -272,7 +271,7 @@ class SettingsFileTypes extends Component<Props, State> {
</TransparentBackground>
</FormControl>
<IconButton
- data-tid={'settingsFileTypes_remove_'}
+ data-tid="settingsFileTypes_remove_"
className={classes.fileExtRemove}
title={i18n.t('removeFileType', { itemType: item.type })}
onClick={() => onRemoveItem(item)}
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index e18711179..019f39355 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -251,19 +251,17 @@ class SettingsGeneral extends React.Component<Props, State> {
checked={this.props.settings.showUnixHiddenEntries}
/>
</ListItem>
- {
- <ListItem className={classes.listItem}>
- <ListItemText primary="Mobile Mode (experimental)" />
- <Switch
- data-tid="settingsSetDesktopMode"
- disabled={!(typeof window.ExtDisplayMode === 'undefined')}
- onClick={() =>
- this.props.setDesktopMode(!this.props.settings.desktopMode)
- }
- checked={!this.props.settings.desktopMode}
- />
- </ListItem>
- }
+ <ListItem className={classes.listItem}>
+ <ListItemText primary="Mobile Mode (experimental)" />
+ <Switch
+ data-tid="settingsSetDesktopMode"
+ disabled={!(typeof window.ExtDisplayMode === 'undefined')}
+ onClick={() =>
+ this.props.setDesktopMode(!this.props.settings.desktopMode)
+ }
+ checked={!this.props.settings.desktopMode}
+ />
+ </ListItem>
{/* <ListItem className={classes.listItem}>
<ListItemText style={{ maxWidth: '300px' }} primary={i18n.t('core:tagDelimiterChoose')} />
<Select
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 6539fe083..0555cec91 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -316,9 +316,9 @@ const DirectoryMenu = (props: Props) => {
props.deleteDirectory(props.directoryPath);
}
}}
- confirmDialogContentTID={'confirmDialogContent'}
- cancelDialogTID={'cancelDeleteDirectoryDialog'}
- confirmDialogTID={'confirmDeleteDirectoryDialog'}
+ confirmDialogContentTID="confirmDialogContent"
+ cancelDialogTID="cancelDeleteDirectoryDialog"
+ confirmDialogTID="confirmDeleteDirectoryDialog"
/>
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
{props.perspectiveMode && (
diff --git a/app/components/menus/EntryTagMenu.tsx b/app/components/menus/EntryTagMenu.tsx
index 2448a120b..83b3576de 100644
--- a/app/components/menus/EntryTagMenu.tsx
+++ b/app/components/menus/EntryTagMenu.tsx
@@ -126,9 +126,9 @@ const EntryTagMenu = (props: Props) => {
confirmRemoveTag();
}
}}
- cancelDialogTID={'cancelDeleteTagDialogTagMenu'}
- confirmDialogTID={'confirmRemoveTagFromFile'}
- confirmDialogContentTID={'confirmDialogContent'}
+ cancelDialogTID="cancelDeleteTagDialogTagMenu"
+ confirmDialogTID="confirmRemoveTagFromFile"
+ confirmDialogContentTID="confirmDialogContent"
/>
</div>
);
diff --git a/app/components/menus/LocationManagerMenu.tsx b/app/components/menus/LocationManagerMenu.tsx
index 3ff3ae5e8..08f378f40 100644
--- a/app/components/menus/LocationManagerMenu.tsx
+++ b/app/components/menus/LocationManagerMenu.tsx
@@ -33,28 +33,26 @@ interface Props {
openURLExternally: (url: string) => void;
}
-const LocationManagerMenu = (props: Props) => {
- return (
- <div
- // @ts-ignore
- style={{ overflowY: 'hidden !important' }}
- >
- <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
- <MenuItem
- data-tid="locationManagerMenu"
- onClick={() => {
- props.onClose();
- props.openURLExternally(AppConfig.documentationLinks.locations);
- }}
- >
- <ListItemIcon>
- <HelpIcon />
- </ListItemIcon>
- <ListItemText primary={i18n.t('core:help')} />
- </MenuItem>
- </Menu>
- </div>
- );
-};
+const LocationManagerMenu = (props: Props) => (
+ <div
+ // @ts-ignore
+ style={{ overflowY: 'hidden !important' }}
+ >
+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
+ <MenuItem
+ data-tid="locationManagerMenu"
+ onClick={() => {
+ props.onClose();
+ props.openURLExternally(AppConfig.documentationLinks.locations);
+ }}
+ >
+ <ListItemIcon>
+ <HelpIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:help')} />
+ </MenuItem>
+ </Menu>
+ </div>
+);
export default LocationManagerMenu;
diff --git a/app/components/menus/SearchMenu.tsx b/app/components/menus/SearchMenu.tsx
index b5fe8ca2f..c3f4700a1 100644
--- a/app/components/menus/SearchMenu.tsx
+++ b/app/components/menus/SearchMenu.tsx
@@ -33,28 +33,26 @@ interface Props {
openURLExternally: (url: string) => void;
}
-const SearchMenu = (props: Props) => {
- return (
- <div
- // @ts-ignore
- style={{ overflowY: 'hidden !important' }}
- >
- <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
- <MenuItem
- data-tid="searchMenuHelp"
- onClick={() => {
- props.onClose();
- props.openURLExternally(AppConfig.documentationLinks.search);
- }}
- >
- <ListItemIcon>
- <HelpIcon />
- </ListItemIcon>
- <ListItemText primary={i18n.t('core:help')} />
- </MenuItem>
- </Menu>
- </div>
- );
-};
+const SearchMenu = (props: Props) => (
+ <div
+ // @ts-ignore
+ style={{ overflowY: 'hidden !important' }}
+ >
+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
+ <MenuItem
+ data-tid="searchMenuHelp"
+ onClick={() => {
+ props.onClose();
+ props.openURLExternally(AppConfig.documentationLinks.search);
+ }}
+ >
+ <ListItemIcon>
+ <HelpIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:help')} />
+ </MenuItem>
+ </Menu>
+ </div>
+);
export default SearchMenu;
diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsx
index e67d5841a..178cf05a9 100644
--- a/app/components/menus/TagMenu.tsx
+++ b/app/components/menus/TagMenu.tsx
@@ -138,8 +138,8 @@ const TagLibraryMenu = (props: Props) => {
confirmDeleteTag();
}
}}
- cancelDialogTID={'cancelDeleteTagDialogTagMenu'}
- confirmDialogTID={'confirmDeleteTagDialogTagMenu'}
+ cancelDialogTID="cancelDeleteTagDialogTagMenu"
+ confirmDialogTID="confirmDeleteTagDialogTagMenu"
/>
</div>
);
diff --git a/app/containers/LoginPage.tsx b/app/containers/LoginPage.tsx
index f52ab3439..97cc71243 100644
--- a/app/containers/LoginPage.tsx
+++ b/app/containers/LoginPage.tsx
@@ -26,8 +26,11 @@ import i18n from '../services/i18n';
class LoginPage extends Component {
formValid: boolean;
+
emailValid: boolean;
+
passValid: boolean;
+
handleInputChange: Function;
constructor(props) {
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index d61ade3a3..cadd469e8 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -718,7 +718,7 @@ class MainPage extends Component<Props, State> {
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={this.props.isGeneratingThumbs}
autoHideDuration={undefined}
- message={'Loading or generating thumbnails...'}
+ message="Loading or generating thumbnails..."
action={[
<IconButton
key="close"
@@ -734,7 +734,7 @@ class MainPage extends Component<Props, State> {
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={this.props.isIndexing}
autoHideDuration={undefined}
- message={'Indexing'}
+ message="Indexing"
action={[
<Button
color="secondary"
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 7fef3d556..91659a468 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -614,7 +614,7 @@ export const actions = {
getState: () => any
) => {
const state = getState();
- const currentDirectoryPath = state.app.currentDirectoryPath;
+ const { currentDirectoryPath } = state.app;
const currentLocationPath = normalizePath(getCurrentLocationPath(state));
if (currentDirectoryPath) {
@@ -892,7 +892,7 @@ export const actions = {
normalizePath(targetPath) + AppConfig.dirSeparator + fileNameAndExt;
let fileContent = content;
if (fileType === 'html') {
- const newHTMLFileContent = getState().settings.newHTMLFileContent;
+ const { newHTMLFileContent } = getState().settings;
fileContent =
newHTMLFileContent.split('<body></body>')[0] +
'<body>' +
@@ -937,7 +937,7 @@ export const actions = {
dispatch: (actions: Object) => void,
getState: () => any
) => {
- const locations: Array<Location> = getState().locations;
+ const { locations } = getState();
locations.map(location => {
if (location.uuid === locationId) {
dispatch(actions.openLocation(location));
@@ -1019,7 +1019,7 @@ export const actions = {
dispatch: (actions: Object) => void,
getState: () => any
) => {
- const locations: Array<Location> = getState().locations;
+ const { locations } = getState();
const { currentLocationId } = getState().app;
if (currentLocationId === locationId) {
locations.map(location => {
@@ -1074,8 +1074,7 @@ export const actions = {
isFile: boolean = true,
editMode: boolean = false
) => (dispatch: (actions: Object) => void, getState: () => any) => {
- const supportedFileTypes: Array<Object> = getState().settings
- .supportedFileTypes;
+ const { supportedFileTypes } = getState().settings;
const entryForOpening: OpenedEntry = findExtensionsForEntry(
supportedFileTypes,
entryPath,
@@ -1112,7 +1111,7 @@ export const actions = {
const currentEntries = getState().app.currentDirectoryEntries.filter(
entry => entry.isFile
);
- const lastSelectedEntry = getState().app.lastSelectedEntry;
+ const { lastSelectedEntry } = getState().app;
let filePath = pivotFilePath;
if (!filePath) {
if (lastSelectedEntry) {
@@ -1143,7 +1142,7 @@ export const actions = {
const currentEntries = getState().app.currentDirectoryEntries.filter(
entry => entry.isFile
);
- const lastSelectedEntry = getState().app.lastSelectedEntry;
+ const { lastSelectedEntry } = getState().app;
let filePath = pivotFilePath;
if (!filePath) {
if (lastSelectedEntry) {
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 9974918ff..e66fcd682 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -25,8 +25,8 @@ import {
extractTagsAsObjects
// getThumbFileLocationForFile
} from '../utils/paths';
-import { SearchQuery } from '../services/search';
-import Search from '../services/search';
+import Search, { SearchQuery } from '../services/search';
+
import { actions as AppActions } from './app';
import AppConfig from '../config';
import i18n from '../services/i18n';
diff --git a/app/services/electron-io.ts b/app/services/electron-io.ts
index 4d3ad0e58..0bdeb9102 100644
--- a/app/services/electron-io.ts
+++ b/app/services/electron-io.ts
@@ -34,15 +34,25 @@ import { Pro } from '../pro';
export default class ElectronIO {
electron: any;
+
win: any;
+
app: any;
+
ipcRenderer: any;
+
remote: any;
+
workerWindow: any;
+
pathUtils: any;
+
fs: any;
+
fsWatcher: any;
+
webFrame: any;
+
tsTray: any;
constructor() {
@@ -60,7 +70,7 @@ export default class ElectronIO {
}
initMainMenu = (menuConfig: Array<Object>) => {
- const Menu = this.remote.Menu;
+ const { Menu } = this.remote;
const defaultMenu = Menu.buildFromTemplate(menuConfig);
Menu.setApplicationMenu(defaultMenu);
};
@@ -72,9 +82,9 @@ export default class ElectronIO {
}
const mainWindow = this.win;
- const Menu = this.remote.Menu;
- const Tray = this.remote.Tray;
- const nativeImage = this.remote.nativeImage;
+ const { Menu } = this.remote;
+ const { Tray } = this.remote;
+ const { nativeImage } = this.remote;
// let trayIconPath;
// if (process.platform === 'darwin') {
@@ -224,8 +234,8 @@ export default class ElectronIO {
createDirectoryIndexInWorker = (
directoryPath: string,
extractText: boolean
- ): Promise<any> => {
- return new Promise((resolve, reject) => {
+ ): Promise<any> =>
+ new Promise((resolve, reject) => {
if (this.isWorkerAvailable()) {
const timestamp = new Date().getTime().toString();
this.workerWindow.webContents.send('worker', {
@@ -242,7 +252,6 @@ export default class ElectronIO {
reject('Worker window not available!');
}
});
- };
createThumbnailsInWorker = (tmbGenerationList: Array<string>): Promise<any> =>
new Promise((resolve, reject) => {
@@ -551,17 +560,20 @@ export default class ElectronIO {
'" failed'
);
return;
- } else if (this.fs.lstatSync(filePath).isDirectory()) {
+ }
+ if (this.fs.lstatSync(filePath).isDirectory()) {
reject(
'Trying to rename a directory. Renaming of "' + filePath + '" failed'
);
return;
- } else if (!this.fs.existsSync(filePath)) {
+ }
+ if (!this.fs.existsSync(filePath)) {
reject(
'Source file does not exist. Renaming of "' + filePath + '" failed'
);
return;
- } else if (this.fs.existsSync(newFilePath)) {
+ }
+ if (this.fs.existsSync(newFilePath)) {
reject(
'Target filename "' +
newFilePath +
@@ -593,7 +605,8 @@ export default class ElectronIO {
if (dirPath === newDirPath) {
reject('Trying to move in the same directory. Moving failed');
return;
- } else if (this.fs.existsSync(newDirPath)) {
+ }
+ if (this.fs.existsSync(newDirPath)) {
reject(
'Directory "' +
newDirPath +
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 496637452..48be1a506 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -18,9 +18,9 @@
import { Pro } from '../pro';
// @ts-ignore
-import platformIO from './_PLATFORMIO_';
+import NativePlatformIO from './_PLATFORMIO_';
-let nativeAPI: any = new platformIO();
+const nativeAPI: any = new NativePlatformIO();
let objectStoreAPI;
export default class PlatformIO {
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index fb03531bf..f6b0d82fd 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -351,7 +351,7 @@ export function generateFileName(
tagDelimiter: string
) {
let tagsString = '';
- const prefixTagContainer = AppConfig.prefixTagContainer;
+ const { prefixTagContainer } = AppConfig;
// Creating the string will all the tags by more that 0 tags
if (tags && tags.length > 0) {
tagsString = AppConfig.beginTagContainer;
diff --git a/app/services/webdav-io.ts b/app/services/webdav-io.ts
index 98595284b..63a93bbbd 100644
--- a/app/services/webdav-io.ts
+++ b/app/services/webdav-io.ts
@@ -27,8 +27,11 @@ import { FileSystemEntry } from './utils-io';
export default class WebDAVIO {
davClient: any;
+
_username: string;
+
_password: string;
+
_headers: any;
constructor() {
@@ -320,11 +323,8 @@ export default class WebDAVIO {
dav.resourcetype._xmlvalue[0].localName === 'collection')
);
- getEntryMeta = (
- eentry: FileSystemEntry,
- metaPath: string
- ): Promise<Object> => {
- return new Promise(resolve => {
+ getEntryMeta = (eentry: FileSystemEntry, metaPath: string): Promise<Object> =>
+ new Promise(resolve => {
if (eentry.isFile) {
this.loadTextFilePromise(metaPath)
.then(result => {
@@ -363,7 +363,6 @@ export default class WebDAVIO {
}
resolve(eentry);
});
- };
/**
* Finds out the properties of a file or directory such last modification date or file size
diff --git a/app/utils/misc.ts b/app/utils/misc.ts
index e1fd97064..4c84287fa 100644
--- a/app/utils/misc.ts
+++ b/app/utils/misc.ts
@@ -193,13 +193,17 @@ export function formatFileSize(sizeInBytes: number): string {
if (sizeInBytes >= 0 && sizeInBytes < kilobyte) {
return sizeInBytes + ' B';
- } else if (sizeInBytes >= kilobyte && sizeInBytes < megabyte) {
+ }
+ if (sizeInBytes >= kilobyte && sizeInBytes < megabyte) {
return (sizeInBytes / kilobyte).toFixed(precision) + ' KB';
- } else if (sizeInBytes >= megabyte && sizeInBytes < gigabyte) {
+ }
+ if (sizeInBytes >= megabyte && sizeInBytes < gigabyte) {
return (sizeInBytes / megabyte).toFixed(precision) + ' MB';
- } else if (sizeInBytes >= gigabyte && sizeInBytes < terabyte) {
+ }
+ if (sizeInBytes >= gigabyte && sizeInBytes < terabyte) {
return (sizeInBytes / gigabyte).toFixed(precision) + ' GB';
- } else if (sizeInBytes >= terabyte) {
+ }
+ if (sizeInBytes >= terabyte) {
return (sizeInBytes / terabyte).toFixed(precision) + ' TB';
}
return sizeInBytes + '';
@@ -559,7 +563,7 @@ export const eachProp = (obj, callback) => {
* @returns {object}
*/
export const extend = (baseObject, ...restObjects) => {
- const assign = Object.assign;
+ const { assign } = Object;
const modifiedObject = assign({}, baseObject);
restObjects.map(obj => assign(modifiedObject, obj));
@@ -667,13 +671,12 @@ export const filterObjectData = (objectData, requiredKeys) => {
* @param arrayData
* @param requiredKeys
*/
-export const filterArrayOfObjectsData = (arrayData, requiredKeys) => {
- return arrayData.reduce((accumulator, item) => {
+export const filterArrayOfObjectsData = (arrayData, requiredKeys) =>
+ arrayData.reduce((accumulator, item) => {
const filteredObject = filterObjectData(item, requiredKeys);
accumulator.push(filteredObject);
return accumulator;
}, []);
-};
/**
* @description Pluck object data to array
@@ -696,12 +699,11 @@ export const pluckObjectDataToArray = (objectData, requiredKey) => {
* @param arrayData
* @param requiredKey
*/
-export const pluckArrayOfObjectsDataToArray = (arrayData, requiredKey) => {
- return arrayData.reduce((accumulator, item) => {
+export const pluckArrayOfObjectsDataToArray = (arrayData, requiredKey) =>
+ arrayData.reduce((accumulator, item) => {
const filteredArray = pluckObjectDataToArray(item, requiredKey);
return [...accumulator, ...filteredArray];
}, []);
-};
/**
* @description Extract nexted prop
@@ -757,8 +759,8 @@ export const sortBy = (
keysText: any,
type: string = 'string',
direction: string = 'asc'
-) => {
- return items.sort((a, b) => {
+) =>
+ items.sort((a, b) => {
const aVal: any = extractNestedProp(a, keysText);
const bVal: any = extractNestedProp(b, keysText);
@@ -778,7 +780,8 @@ export const sortBy = (
return direction === 'asc' ? -1 : 1;
}
return 0;
- } else if (type === 'number' || type === 'integer' || type === 'float') {
+ }
+ if (type === 'number' || type === 'integer' || type === 'float') {
if (aVal > bVal) {
return direction === 'asc' ? 1 : -1;
}
@@ -786,7 +789,8 @@ export const sortBy = (
return direction === 'asc' ? -1 : 1;
}
return 0;
- } else if (type === 'date') {
+ }
+ if (type === 'date') {
// @ts-ignore
const res1 = new Date(aVal) - new Date(bVal);
// @ts-ignore
@@ -794,7 +798,6 @@ export const sortBy = (
return direction === 'asc' ? res1 : res2;
}
});
-};
/**
* @description Shape
@@ -823,7 +826,8 @@ export const shape = items => {
const prop = extractNestedProp(item, key);
if (isArr(prop)) {
return [...accumulator, ...prop];
- } else if (!isUndef(prop) && !isNull(prop)) {
+ }
+ if (!isUndef(prop) && !isNull(prop)) {
return [...accumulator, prop];
}
}, []);
diff --git a/app/utils/paths.ts b/app/utils/paths.ts
index e01d09ec2..8cd1315ce 100644
--- a/app/utils/paths.ts
+++ b/app/utils/paths.ts
@@ -35,10 +35,12 @@ export function extractFileExtension(filePath: string) {
const lastindexDot = filePath.lastIndexOf('.');
if (lastindexDot < 0) {
return '';
- } else if (lastindexDot < lastindexDirSeparator) {
+ }
+ if (lastindexDot < lastindexDirSeparator) {
// case: "../remote.php/webdav/somefilename"
return '';
- } else if (lastindexDot < lastIndexEndTagContainer) {
+ }
+ if (lastindexDot < lastIndexEndTagContainer) {
// case: "[20120125 89.4kg 19.5% 60.5% 39.8% 2.6kg]"
return '';
}
@@ -118,7 +120,8 @@ export function cleanTrailingDirSeparator(dirPath: string): string {
if (dirPath) {
if (dirPath.lastIndexOf('\\') === dirPath.length - 1) {
return dirPath.substring(0, dirPath.length - 1);
- } else if (dirPath.lastIndexOf('/') === dirPath.length - 1) {
+ }
+ if (dirPath.lastIndexOf('/') === dirPath.length - 1) {
return dirPath.substring(0, dirPath.length - 1);
}
return dirPath;
@@ -151,10 +154,12 @@ export function extractFileNameWithoutExt(filePath: string): string {
) {
// case: "[tag1 tag.2]"
return '';
- } else if (indexOfDot > 0) {
+ }
+ if (indexOfDot > 0) {
// case: regular
return fileName.substring(0, indexOfDot);
- } else if (indexOfDot === 0) {
+ }
+ if (indexOfDot === 0) {
// case ".txt"
return '';
}
@@ -239,7 +244,8 @@ export function extractTitle(entryPath: string, isDirectory: boolean = false) {
if (beginTagContainer === 0 && endTagContainer === title.trim().length) {
// case: "[tag1, tag2]"
return '';
- } else if (endTagContainer === title.trim().length) {
+ }
+ if (endTagContainer === title.trim().length) {
// case: "asd[tag1, tag2]"
return title.slice(0, beginTagContainer);
}