1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Tools: Enforce and apply eslint rules prefer-const and no-var

This commit is contained in:
Laurent Cozic
2020-03-13 23:46:14 +00:00
parent 92bee549a1
commit d0d2bad7f4
189 changed files with 1387 additions and 1377 deletions

View File

@@ -107,10 +107,10 @@ class CameraView extends Component {
}
fitRectIntoBounds(rect, bounds) {
var rectRatio = rect.width / rect.height;
var boundsRatio = bounds.width / bounds.height;
const rectRatio = rect.width / rect.height;
const boundsRatio = bounds.width / bounds.height;
var newDimensions = {};
const newDimensions = {};
// Rect is more landscape than bounds - fit to width
if (rectRatio > boundsRatio) {

View File

@@ -16,7 +16,7 @@ class ModalDialog extends React.Component {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
modalWrapper: {
flex: 1,
justifyContent: 'center',

View File

@@ -56,7 +56,7 @@ class ActionButtonComponent extends React.Component {
}
render() {
let buttons = this.props.buttons ? this.props.buttons : [];
const buttons = this.props.buttons ? this.props.buttons : [];
if (this.props.addFolderNoteButtons) {
if (this.props.folders.length) {
@@ -80,11 +80,11 @@ class ActionButtonComponent extends React.Component {
}
}
let buttonComps = [];
const buttonComps = [];
for (let i = 0; i < buttons.length; i++) {
let button = buttons[i];
let buttonTitle = button.title ? button.title : '';
let key = `${buttonTitle.replace(/\s/g, '_')}_${button.icon}`;
const button = buttons[i];
const buttonTitle = button.title ? button.title : '';
const key = `${buttonTitle.replace(/\s/g, '_')}_${button.icon}`;
buttonComps.push(
<ReactNativeActionButton.Item key={key} buttonColor={button.color} title={buttonTitle} onPress={button.onPress}>
<Icon name={button.icon} style={styles.actionButtonIcon} />
@@ -96,14 +96,14 @@ class ActionButtonComponent extends React.Component {
return <ReactNativeActionButton style={{ display: 'none' }} />;
}
let mainButton = this.props.mainButton ? this.props.mainButton : {};
let mainIcon = mainButton.icon ? <Icon name={mainButton.icon} style={styles.actionButtonIcon} /> : <Icon name="md-add" style={styles.actionButtonIcon} />;
const mainButton = this.props.mainButton ? this.props.mainButton : {};
const mainIcon = mainButton.icon ? <Icon name={mainButton.icon} style={styles.actionButtonIcon} /> : <Icon name="md-add" style={styles.actionButtonIcon} />;
if (this.props.multiStates) {
if (!this.props.buttons || !this.props.buttons.length) throw new Error('Multi-state button requires at least one state');
if (this.state.buttonIndex < 0 || this.state.buttonIndex >= this.props.buttons.length) throw new Error(`Button index out of bounds: ${this.state.buttonIndex}/${this.props.buttons.length}`);
let button = this.props.buttons[this.state.buttonIndex];
let mainIcon = <Icon name={button.icon} style={styles.actionButtonIcon} />;
const button = this.props.buttons[this.state.buttonIndex];
const mainIcon = <Icon name={button.icon} style={styles.actionButtonIcon} />;
return (
<ReactNativeActionButton
icon={mainIcon}

View File

@@ -43,7 +43,7 @@ class AppNavComponent extends Component {
// Note: certain screens are kept into memory, in particular Notes and Search
// so that the scroll position is not lost when the user navigate away from them.
let route = this.props.route;
const route = this.props.route;
let Screen = null;
let notesScreenVisible = false;
let searchScreenVisible = false;
@@ -59,7 +59,7 @@ class AppNavComponent extends Component {
// Keep the search screen loaded if the user is viewing a note from that search screen
// so that if the back button is pressed, the screen is still loaded. However, unload
// it if navigating away.
let searchScreenLoaded = searchScreenVisible || (this.previousRouteName_ == 'Search' && route.routeName == 'Note');
const searchScreenLoaded = searchScreenVisible || (this.previousRouteName_ == 'Search' && route.routeName == 'Note');
this.previousRouteName_ = route.routeName;

View File

@@ -12,7 +12,7 @@ const styleObject_ = {
const styles_ = StyleSheet.create(styleObject_);
let rootStyles_ = {};
const rootStyles_ = {};
class BaseScreenComponent extends React.Component {
styles() {

View File

@@ -31,7 +31,7 @@ class Checkbox extends Component {
}
onPress() {
let newChecked = !this.state.checked;
const newChecked = !this.state.checked;
this.setState({ checked: newChecked });
if (this.props.onChange) this.props.onChange(newChecked);
}
@@ -39,11 +39,11 @@ class Checkbox extends Component {
render() {
const iconName = this.state.checked ? 'md-checkbox-outline' : 'md-square-outline';
let style = this.props.style ? Object.assign({}, this.props.style) : {};
const style = this.props.style ? Object.assign({}, this.props.style) : {};
style.justifyContent = 'center';
style.alignItems = 'center';
let checkboxIconStyle = Object.assign({}, styles.checkboxIcon);
const checkboxIconStyle = Object.assign({}, styles.checkboxIcon);
if (style.color) checkboxIconStyle.color = style.color;
if (style.paddingTop) checkboxIconStyle.marginTop = style.paddingTop;

View File

@@ -47,7 +47,7 @@ globalStyle.marginTop = globalStyle.margin;
globalStyle.marginBottom = globalStyle.margin;
globalStyle.htmlMarginLeft = `${((globalStyle.marginLeft / 10) * 0.6).toFixed(2)}em`;
let themeCache_ = {};
const themeCache_ = {};
function addExtraStyles(style) {
style.icon = {
@@ -122,7 +122,7 @@ function themeStyle(theme) {
if (themeCache_[theme]) return themeCache_[theme];
let output = Object.assign({}, globalStyle);
const output = Object.assign({}, globalStyle);
if (theme == Setting.THEME_LIGHT) return addExtraStyles(output);
else if (theme == Setting.THEME_OLED_DARK) {
output.backgroundColor = '#000000';

View File

@@ -62,7 +62,7 @@ class NoteBodyViewer extends Component {
postMessageSyntax: 'window.ReactNativeWebView.postMessage',
};
let result = await this.markupToHtml_.render(note.markup_language, bodyToRender, this.props.webViewStyle, mdOptions);
const result = await this.markupToHtml_.render(note.markup_language, bodyToRender, this.props.webViewStyle, mdOptions);
let html = result.html;
const resourceDownloadMode = Setting.value('sync.resourceDownloadMode');
@@ -188,7 +188,7 @@ class NoteBodyViewer extends Component {
// https://github.com/react-native-community/react-native-webview/issues/312#issuecomment-503754654
let webViewStyle = { backgroundColor: this.props.webViewStyle.backgroundColor };
const webViewStyle = { backgroundColor: this.props.webViewStyle.backgroundColor };
// On iOS, the onLoadEnd() event is never fired so always
// display the webview (don't do the little trick
// to avoid the white flash).

View File

@@ -27,7 +27,7 @@ class NoteItemComponent extends Component {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
listItem: {
flexDirection: 'row',
// height: 40,
@@ -110,7 +110,7 @@ class NoteItemComponent extends Component {
const theme = themeStyle(this.props.theme);
// IOS: display: none crashes the app
let checkboxStyle = !isTodo ? { display: 'none' } : { color: theme.color };
const checkboxStyle = !isTodo ? { display: 'none' } : { color: theme.color };
if (isTodo) {
checkboxStyle.paddingRight = 10;

View File

@@ -28,7 +28,7 @@ class NoteListComponent extends Component {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
noItemMessage: {
paddingLeft: theme.marginLeft,
paddingRight: theme.marginRight,
@@ -63,7 +63,7 @@ class NoteListComponent extends Component {
const maxInterval = 1000 * 60 * 60 * 24;
const notRecentTime = now - maxInterval;
let output = [];
const output = [];
for (let i = 0; i < notes.length; i++) {
const note = notes[i];
if (note.is_todo) {

View File

@@ -36,7 +36,7 @@ class ScreenHeaderComponent extends React.PureComponent {
const theme = themeStyle(themeId);
let styleObject = {
const styleObject = {
container: {
flexDirection: 'column',
backgroundColor: theme.raisedBackgroundColor,
@@ -299,11 +299,11 @@ class ScreenHeaderComponent extends React.PureComponent {
}
let key = 0;
let menuOptionComponents = [];
const menuOptionComponents = [];
if (!this.props.noteSelectionEnabled) {
for (let i = 0; i < this.props.menuOptions.length; i++) {
let o = this.props.menuOptions[i];
const o = this.props.menuOptions[i];
if (o.isDivider) {
menuOptionComponents.push(<View key={`menuOption_${key++}`} style={this.styles().divider} />);
@@ -408,7 +408,7 @@ class ScreenHeaderComponent extends React.PureComponent {
/>
);
} else {
let title = 'title' in this.props && this.props.title !== null ? this.props.title : '';
const title = 'title' in this.props && this.props.title !== null ? this.props.title : '';
return <Text style={this.styles().titleText}>{title}</Text>;
}
};

View File

@@ -122,7 +122,7 @@ class NoteTagsDialogComponent extends React.Component {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
tag: {
padding: 10,
borderBottomWidth: 1,

View File

@@ -166,7 +166,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
body: {
flex: 1,
justifyContent: 'flex-start',
@@ -332,7 +332,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
settingToComponent(key, value) {
const themeId = this.props.theme;
const theme = themeStyle(themeId);
let output = null;
const output = null;
const updateSettingValue = (key, value) => {
return shared.updateSettingValue(this, key, value);
@@ -344,9 +344,9 @@ class ConfigScreenComponent extends BaseScreenComponent {
if (md.isEnum) {
value = value.toString();
let items = [];
const items = [];
const settingOptions = md.options();
for (let k in settingOptions) {
for (const k in settingOptions) {
if (!settingOptions.hasOwnProperty(k)) continue;
items.push({ label: settingOptions[k], value: k.toString() });
}

View File

@@ -30,7 +30,7 @@ class DropboxLoginScreenComponent extends BaseScreenComponent {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
container: {
padding: theme.margin,
},

View File

@@ -63,7 +63,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
if (this.styles_[themeId]) return this.styles_[themeId];
this.styles_ = {};
let styles = {
const styles = {
titleText: {
flex: 1,
fontWeight: 'bold',
@@ -198,7 +198,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
const mkComps = [];
let nonExistingMasterKeyIds = this.props.notLoadedMasterKeys.slice();
const nonExistingMasterKeyIds = this.props.notLoadedMasterKeys.slice();
for (let i = 0; i < masterKeys.length; i++) {
const mk = masterKeys[i];

View File

@@ -30,7 +30,7 @@ class FolderScreenComponent extends BaseScreenComponent {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
textInput: {
color: theme.color,
paddingLeft: theme.marginLeft,
@@ -61,14 +61,14 @@ class FolderScreenComponent extends BaseScreenComponent {
isModified() {
if (!this.state.folder || !this.state.lastSavedFolder) return false;
let diff = BaseModel.diffObjects(this.state.folder, this.state.lastSavedFolder);
const diff = BaseModel.diffObjects(this.state.folder, this.state.lastSavedFolder);
delete diff.type_;
return !!Object.getOwnPropertyNames(diff).length;
}
folderComponent_change(propName, propValue) {
this.setState((prevState) => {
let folder = Object.assign({}, prevState.folder);
const folder = Object.assign({}, prevState.folder);
folder[propName] = propValue;
return { folder: folder };
});
@@ -101,7 +101,7 @@ class FolderScreenComponent extends BaseScreenComponent {
}
render() {
let saveButtonDisabled = !this.isModified();
const saveButtonDisabled = !this.isModified();
const theme = themeStyle(this.props.theme);
return (

View File

@@ -31,7 +31,7 @@ class LogScreenComponent extends BaseScreenComponent {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
row: {
flexDirection: 'row',
paddingLeft: 1,
@@ -81,7 +81,7 @@ class LogScreenComponent extends BaseScreenComponent {
}
render() {
let renderRow = ({ item }) => {
const renderRow = ({ item }) => {
let textStyle = this.styles().rowText;
if (item.level == Logger.LEVEL_WARN) textStyle = this.styles().rowTextWarn;
if (item.level == Logger.LEVEL_ERROR) textStyle = this.styles().rowTextError;

View File

@@ -82,7 +82,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const saveDialog = async () => {
if (this.isModified()) {
let buttonId = await dialogs.pop(this, _('This note has been modified:'), [{ text: _('Save changes'), id: 'save' }, { text: _('Discard changes'), id: 'discard' }, { text: _('Cancel'), id: 'cancel' }]);
const buttonId = await dialogs.pop(this, _('This note has been modified:'), [{ text: _('Save changes'), id: 'save' }, { text: _('Discard changes'), id: 'discard' }, { text: _('Cancel'), id: 'cancel' }]);
if (buttonId == 'cancel') return true;
if (buttonId == 'save') await this.saveNoteButton_press();
@@ -205,7 +205,7 @@ class NoteScreenComponent extends BaseScreenComponent {
if (this.styles_[cacheKey]) return this.styles_[cacheKey];
this.styles_ = {};
let styles = {
const styles = {
bodyTextInput: {
flex: 1,
paddingLeft: theme.marginLeft,
@@ -344,13 +344,13 @@ class NoteScreenComponent extends BaseScreenComponent {
}
async deleteNote_onPress() {
let note = this.state.note;
const note = this.state.note;
if (!note.id) return;
let ok = await dialogs.confirm(this, _('Delete note?'));
const ok = await dialogs.confirm(this, _('Delete note?'));
if (!ok) return;
let folderId = note.parent_id;
const folderId = note.parent_id;
await Note.delete(note.id);
@@ -402,7 +402,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async resizeImage(localFilePath, targetPath, mimeType) {
const maxSize = Resource.IMAGE_MAX_DIMENSION;
let dimensions = await this.imageDimensions(localFilePath);
const dimensions = await this.imageDimensions(localFilePath);
reg.logger().info('Original dimensions ', dimensions);
if (dimensions.width > maxSize || dimensions.height > maxSize) {
@@ -476,7 +476,7 @@ class NoteScreenComponent extends BaseScreenComponent {
if (!resource.mime) resource.mime = 'application/octet-stream';
let targetPath = Resource.fullPath(resource);
const targetPath = Resource.fullPath(resource);
try {
if (mimeType == 'image/jpeg' || mimeType == 'image/jpg' || mimeType == 'image/png') {
@@ -580,7 +580,7 @@ class NoteScreenComponent extends BaseScreenComponent {
}
async onAlarmDialogAccept(date) {
let newNote = Object.assign({}, this.state.note);
const newNote = Object.assign({}, this.state.note);
newNote.todo_due = date ? date.getTime() : 0;
await this.saveOneProperty('todo_due', date ? date.getTime() : 0);
@@ -595,7 +595,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async showOnMap_onPress() {
if (!this.state.note.id) return;
let note = await Note.load(this.state.note.id);
const note = await Note.load(this.state.note.id);
try {
const url = Note.geolocationUrl(note);
Linking.openURL(url);
@@ -608,7 +608,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async showSource_onPress() {
if (!this.state.note.id) return;
let note = await Note.load(this.state.note.id);
const note = await Note.load(this.state.note.id);
try {
Linking.openURL(note.source_url);
} catch (error) {
@@ -661,7 +661,7 @@ class NoteScreenComponent extends BaseScreenComponent {
if (this.menuOptionsCache_[cacheKey]) return this.menuOptionsCache_[cacheKey];
let output = [];
const output = [];
// The file attachement modules only work in Android >= 5 (Version 21)
// https://github.com/react-community/react-native-image-picker/issues/606
@@ -741,7 +741,7 @@ class NoteScreenComponent extends BaseScreenComponent {
titleTextInput_contentSizeChange(event) {
if (!this.enableMultilineTitle_) return;
let height = event.nativeEvent.contentSize.height;
const height = event.nativeEvent.contentSize.height;
this.setState({ titleTextInputHeight: height });
}
@@ -866,7 +866,7 @@ class NoteScreenComponent extends BaseScreenComponent {
}
const renderActionButton = () => {
let buttons = [];
const buttons = [];
buttons.push({
title: _('Edit'),
@@ -885,8 +885,8 @@ class NoteScreenComponent extends BaseScreenComponent {
const actionButtonComp = renderActionButton();
let showSaveButton = this.state.mode == 'edit' || this.isModified() || this.saveButtonHasBeenShown_;
let saveButtonDisabled = !this.isModified();
const showSaveButton = this.state.mode == 'edit' || this.isModified() || this.saveButtonHasBeenShown_;
const saveButtonDisabled = !this.isModified();
if (showSaveButton) this.saveButtonHasBeenShown_ = true;

View File

@@ -26,7 +26,7 @@ class NotesScreenComponent extends BaseScreenComponent {
this.onAppStateChange_ = async () => {
// Force an update to the notes list when app state changes
let newProps = Object.assign({}, this.props);
const newProps = Object.assign({}, this.props);
newProps.notesSource = '';
await this.refreshNotes(newProps);
};
@@ -40,7 +40,7 @@ class NotesScreenComponent extends BaseScreenComponent {
return (selected ? `${s} ` : '') + label;
};
for (let field in sortNoteOptions) {
for (const field in sortNoteOptions) {
if (!sortNoteOptions.hasOwnProperty(field)) continue;
buttons.push({
text: makeCheckboxText(Setting.value('notes.sortOrder.field') === field, 'bullet', sortNoteOptions[field]),
@@ -78,7 +78,7 @@ class NotesScreenComponent extends BaseScreenComponent {
if (this.styles_[cacheKey]) return this.styles_[cacheKey];
this.styles_ = {};
let styles = {
const styles = {
noteList: {
flex: 1,
},
@@ -106,7 +106,7 @@ class NotesScreenComponent extends BaseScreenComponent {
async refreshNotes(props = null) {
if (props === null) props = this.props;
let options = {
const options = {
order: props.notesOrder,
uncompletedTodosOnTop: props.uncompletedTodosOnTop,
showCompletedTodos: props.showCompletedTodos,
@@ -198,7 +198,7 @@ class NotesScreenComponent extends BaseScreenComponent {
const parent = this.parentItem();
const theme = themeStyle(this.props.theme);
let rootStyle = {
const rootStyle = {
flex: 1,
backgroundColor: theme.backgroundColor,
};
@@ -207,7 +207,7 @@ class NotesScreenComponent extends BaseScreenComponent {
rootStyle.flex = 0.001; // This is a bit of a hack but it seems to work fine - it makes the component invisible but without unmounting it
}
let title = parent ? parent.title : null;
const title = parent ? parent.title : null;
if (!parent) {
return (
<View style={rootStyle}>

View File

@@ -35,7 +35,7 @@ class SearchScreenComponent extends BaseScreenComponent {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
body: {
flex: 1,
},
@@ -118,10 +118,10 @@ class SearchScreenComponent extends BaseScreenComponent {
if (this.props.settings['db.ftsEnabled']) {
notes = await SearchEngineUtils.notesForQuery(query);
} else {
let p = query.split(' ');
let temp = [];
const p = query.split(' ');
const temp = [];
for (let i = 0; i < p.length; i++) {
let t = p[i].trim();
const t = p[i].trim();
if (!t) continue;
temp.push(t);
}
@@ -146,7 +146,7 @@ class SearchScreenComponent extends BaseScreenComponent {
const theme = themeStyle(this.props.theme);
let rootStyle = {
const rootStyle = {
flex: 1,
backgroundColor: theme.backgroundColor,
};

View File

@@ -33,8 +33,8 @@ class StatusScreenComponent extends BaseScreenComponent {
}
async resfreshScreen() {
let service = new ReportService();
let report = await service.status(Setting.value('sync.target'));
const service = new ReportService();
const report = await service.status(Setting.value('sync.target'));
this.setState({ report: report });
}
@@ -42,7 +42,7 @@ class StatusScreenComponent extends BaseScreenComponent {
const theme = themeStyle(this.props.theme);
const renderBody = report => {
let baseStyle = {
const baseStyle = {
paddingLeft: 6,
paddingRight: 6,
paddingTop: 2,
@@ -52,17 +52,17 @@ class StatusScreenComponent extends BaseScreenComponent {
fontSize: theme.fontSize,
};
let lines = [];
const lines = [];
for (let i = 0; i < report.length; i++) {
let section = report[i];
const section = report[i];
let style = Object.assign({}, baseStyle);
style.fontWeight = 'bold';
if (i > 0) style.paddingTop = 20;
lines.push({ key: `section_${i}`, isSection: true, text: section.title });
for (let n in section.body) {
for (const n in section.body) {
if (!section.body.hasOwnProperty(n)) continue;
style = Object.assign({}, baseStyle);
const item = section.body[n];
@@ -92,7 +92,7 @@ class StatusScreenComponent extends BaseScreenComponent {
<FlatList
data={lines}
renderItem={({ item }) => {
let style = Object.assign({}, baseStyle);
const style = Object.assign({}, baseStyle);
if (item.isSection === true) {
style.fontWeight = 'bold';
@@ -122,7 +122,7 @@ class StatusScreenComponent extends BaseScreenComponent {
);
};
let body = renderBody(this.state.report);
const body = renderBody(this.state.report);
return (
<View style={this.rootStyle(this.props.theme).root}>

View File

@@ -91,7 +91,7 @@ class TagsScreenComponent extends BaseScreenComponent {
render() {
const theme = themeStyle(this.props.theme);
let rootStyle = {
const rootStyle = {
flex: 1,
backgroundColor: theme.backgroundColor,
};

View File

@@ -93,7 +93,7 @@ shared.updateSettingValue = function(comp, key, value) {
};
shared.saveSettings = function(comp) {
for (let key in comp.state.settings) {
for (const key in comp.state.settings) {
if (!comp.state.settings.hasOwnProperty(key)) continue;
if (comp.state.changedSettingKeys.indexOf(key) < 0) continue;
console.info('Saving', key, comp.state.settings[key]);

View File

@@ -90,7 +90,7 @@ shared.saveNoteButton_press = async function(comp, folderId = null, options = nu
note.body = stateNote.body;
}
let newState = {
const newState = {
lastSavedNote: Object.assign({}, note),
note: note,
};
@@ -144,9 +144,9 @@ shared.saveOneProperty = async function(comp, name, value) {
};
shared.noteComponent_change = function(comp, propName, propValue) {
let newState = {};
const newState = {};
let note = Object.assign({}, comp.state.note);
const note = Object.assign({}, comp.state.note);
note[propName] = propValue;
newState.note = note;
@@ -189,7 +189,7 @@ shared.attachedResources = async function(noteBody) {
shared.isModified = function(comp) {
if (!comp.state.note || !comp.state.lastSavedNote) return false;
let diff = BaseModel.diffObjects(comp.state.lastSavedNote, comp.state.note);
const diff = BaseModel.diffObjects(comp.state.lastSavedNote, comp.state.note);
delete diff.type_;
return !!Object.getOwnPropertyNames(diff).length;
};
@@ -227,13 +227,13 @@ shared.initState = async function(comp) {
};
shared.toggleIsTodo_onPress = function(comp) {
let newNote = Note.toggleIsTodo(comp.state.note);
let newState = { note: newNote };
const newNote = Note.toggleIsTodo(comp.state.note);
const newState = { note: newNote };
comp.setState(newState);
};
shared.toggleCheckbox = function(ipcMessage, noteBody) {
let newBody = noteBody.split('\n');
const newBody = noteBody.split('\n');
const p = ipcMessage.split(':');
const lineIndex = Number(p[p.length - 1]);
if (lineIndex >= newBody.length) {

View File

@@ -1,11 +1,11 @@
const Folder = require('lib/models/Folder');
const BaseModel = require('lib/BaseModel');
let shared = {};
const shared = {};
function folderHasChildren_(folders, folderId) {
for (let i = 0; i < folders.length; i++) {
let folder = folders[i];
const folder = folders[i];
if (folder.parent_id === folderId) return true;
}
return false;
@@ -15,7 +15,7 @@ function folderIsVisible(folders, folderId, collapsedFolderIds) {
if (!collapsedFolderIds || !collapsedFolderIds.length) return true;
while (true) {
let folder = BaseModel.byId(folders, folderId);
const folder = BaseModel.byId(folders, folderId);
if (!folder) throw new Error(`No folder with id ${folder.id}`);
if (!folder.parent_id) return true;
if (collapsedFolderIds.indexOf(folder.parent_id) >= 0) return false;
@@ -26,7 +26,7 @@ function folderIsVisible(folders, folderId, collapsedFolderIds) {
function renderFoldersRecursive_(props, renderItem, items, parentId, depth, order) {
const folders = props.folders;
for (let i = 0; i < folders.length; i++) {
let folder = folders[i];
const folder = folders[i];
if (!Folder.idsEqual(folder.parent_id, parentId)) continue;
if (!folderIsVisible(props.folders, folder.id, props.collapsedFolderIds)) continue;
const hasChildren = folderHasChildren_(folders, folder.id);
@@ -49,11 +49,11 @@ shared.renderFolders = function(props, renderItem) {
};
shared.renderTags = function(props, renderItem) {
let tags = props.tags.slice();
const tags = props.tags.slice();
tags.sort((a, b) => {
return a.title < b.title ? -1 : +1;
});
let tagItems = [];
const tagItems = [];
const order = [];
for (let i = 0; i < tags.length; i++) {
const tag = tags[i];

View File

@@ -20,7 +20,7 @@ class SideMenuContentNoteComponent extends Component {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
menu: {
flex: 1,
backgroundColor: theme.backgroundColor,
@@ -73,7 +73,7 @@ class SideMenuContentNoteComponent extends Component {
render() {
const theme = themeStyle(this.props.theme);
let items = [];
const items = [];
const options = this.props.options ? this.props.options : [];
let dividerIndex = 0;
@@ -86,7 +86,7 @@ class SideMenuContentNoteComponent extends Component {
}
}
let style = {
const style = {
flex: 1,
borderRightWidth: 1,
borderRightColor: globalStyle.dividerColor,

View File

@@ -40,7 +40,7 @@ class SideMenuContentComponent extends Component {
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
this.styles_ = {};
let styles = {
const styles = {
menu: {
flex: 1,
backgroundColor: theme.backgroundColor,
@@ -316,7 +316,7 @@ class SideMenuContentComponent extends Component {
items.push(this.makeDivider('divider_2'));
let lines = Synchronizer.reportToLines(this.props.syncReport);
const lines = Synchronizer.reportToLines(this.props.syncReport);
const syncReportText = lines.join('\n');
let decryptionReportText = '';
@@ -329,7 +329,7 @@ class SideMenuContentComponent extends Component {
resourceFetcherText = _('Fetching resources: %d/%d', this.props.resourceFetcher.fetchingCount, this.props.resourceFetcher.toFetchCount);
}
let fullReport = [];
const fullReport = [];
if (syncReportText) fullReport.push(syncReportText);
if (resourceFetcherText) fullReport.push(resourceFetcherText);
if (decryptionReportText) fullReport.push(decryptionReportText);
@@ -367,7 +367,7 @@ class SideMenuContentComponent extends Component {
items = items.concat(folderItems);
}
let style = {
const style = {
flex: 1,
borderRightWidth: 1,
borderRightColor: globalStyle.dividerColor,