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

Linter update (#1777)

* Update eslint config

* Applied linter to lib

* Applied eslint config to CliClient/app

* Removed prettier due to https://github.com/prettier/prettier/pull/4765

* First pass on test units

* Applied linter config to test units

* Applied eslint config to clipper

* Applied to plugin dir

* Applied to root of ElectronClient

* Applied on RN root

* Applied on CLI root

* Applied on Clipper root

* Applied config to tools

* test hook

* test hook

* test hook

* Added pre-commit hook

* Applied rule no-trailing-spaces

* Make sure root packages are installed when installing sub-dir

* Added doc
This commit is contained in:
Laurent Cozic
2019-07-30 09:35:42 +02:00
committed by GitHub
parent b8fbaa2029
commit 71efff6827
208 changed files with 7715 additions and 5019 deletions

View File

@@ -1,19 +1,18 @@
const React = require('react'); const Component = React.Component;
const { View, Button, StyleSheet, TouchableOpacity } = require('react-native');
const { globalStyle, themeStyle } = require('lib/components/global-style.js');
const React = require('react');
const Component = React.Component;
const { View, TouchableOpacity } = require('react-native');
import { RNCamera } from 'react-native-camera';
const Icon = require('react-native-vector-icons/Ionicons').default;
const { _ } = require('lib/locale.js');
class CameraView extends Component {
constructor() {
super();
this.state = {
snapping: false,
};
this.back_onPress = this.back_onPress.bind(this);
this.photo_onPress = this.photo_onPress.bind(this);
}
@@ -30,7 +29,7 @@ class CameraView extends Component {
const result = await this.camera.takePictureAsync({
quality: 0.8,
exif: true,
fixOrientation: true
fixOrientation: true,
});
if (this.props.onPhoto) this.props.onPhoto(result);
@@ -39,14 +38,15 @@ class CameraView extends Component {
}
render() {
const theme = themeStyle(this.props.theme);
const photoIcon = this.state.snapping ? 'md-checkmark' : 'md-camera';
return (
<View style={this.props.style}>
<RNCamera
style={{flex:1}}
ref={ref => { this.camera = ref; }}
style={{ flex: 1 }}
ref={ref => {
this.camera = ref;
}}
type={RNCamera.Constants.Type.back}
captureAudio={false}
androidCameraPermissionOptions={{
@@ -56,24 +56,30 @@ class CameraView extends Component {
buttonNegative: _('Cancel'),
}}
>
<View style={{flex:1, justifyContent:'space-between', flexDirection:'column'}}>
<View style={{flex:1, justifyContent:'flex-start'}}>
<View style={{ flex: 1, justifyContent: 'space-between', flexDirection: 'column' }}>
<View style={{ flex: 1, justifyContent: 'flex-start' }}>
<TouchableOpacity onPress={this.back_onPress}>
<View style={{ marginLeft:5, marginTop:5, borderRadius:90, width:50,height:50, display:'flex', backgroundColor:'#ffffff55', justifyContent:'center', alignItems:'center'}}>
<Icon name={'md-arrow-back'} style={{
fontSize: 40,
color: 'black',
}} />
<View style={{ marginLeft: 5, marginTop: 5, borderRadius: 90, width: 50, height: 50, display: 'flex', backgroundColor: '#ffffff55', justifyContent: 'center', alignItems: 'center' }}>
<Icon
name={'md-arrow-back'}
style={{
fontSize: 40,
color: 'black',
}}
/>
</View>
</TouchableOpacity>
</View>
<View style={{flex:1, justifyContent:'center', alignItems:'flex-end', flexDirection:'row'}}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-end', flexDirection: 'row' }}>
<TouchableOpacity onPress={this.photo_onPress}>
<View style={{marginBottom:20, borderRadius:90, width:90,height:90,backgroundColor:'#ffffffaa', display:'flex', justifyContent:'center', alignItems:'center'}}>
<Icon name={photoIcon} style={{
fontSize: 60,
color: 'black',
}} />
<View style={{ marginBottom: 20, borderRadius: 90, width: 90, height: 90, backgroundColor: '#ffffffaa', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Icon
name={photoIcon}
style={{
fontSize: 60,
color: 'black',
}}
/>
</View>
</TouchableOpacity>
</View>
@@ -82,7 +88,6 @@ class CameraView extends Component {
</View>
);
}
}
module.exports = CameraView;
module.exports = CameraView;

View File

@@ -3,7 +3,6 @@ const Component = React.Component;
const { Platform, View } = require('react-native');
const { WebView } = require('react-native-webview');
const { themeStyle } = require('lib/components/global-style.js');
const Resource = require('lib/models/Resource.js');
const Setting = require('lib/models/Setting.js');
const { reg } = require('lib/registry.js');
const { shim } = require('lib/shim');

View File

@@ -4,8 +4,6 @@ const { connect } = require('react-redux');
const { ListView, Text, StyleSheet } = require('react-native');
const { _ } = require('lib/locale.js');
const { NoteItem } = require('lib/components/note-item.js');
const Note = require('lib/models/Note.js');
const Setting = require('lib/models/Setting.js');
const { time } = require('lib/time-utils.js');
const { themeStyle } = require('lib/components/global-style.js');

View File

@@ -12,7 +12,6 @@ const Note = require('lib/models/Note.js');
const Folder = require('lib/models/Folder.js');
const { themeStyle } = require('lib/components/global-style.js');
const { Dropdown } = require('lib/components/Dropdown.js');
const RNFS = require('react-native-fs');
const { dialogs } = require('lib/dialogs.js');
const DialogBox = require('react-native-dialogbox').default;

View File

@@ -1,11 +1,8 @@
const React = require('react');
const { StyleSheet, View, Text, FlatList, TouchableOpacity, TextInput } = require('react-native');
const Setting = require('lib/models/Setting.js');
const { connect } = require('react-redux');
const BaseItem = require('lib/models/BaseItem.js');
const Tag = require('lib/models/Tag.js');
const Folder = require('lib/models/Folder.js');
const { _ } = require('lib/locale.js');
const { themeStyle } = require('lib/components/global-style.js');
const Icon = require('react-native-vector-icons/Ionicons').default;

View File

@@ -1,8 +1,8 @@
const React = require('react'); const Component = React.Component;
const React = require('react');
const { Platform, TouchableOpacity, Linking, View, Switch, StyleSheet, Text, Button, ScrollView, TextInput, Alert } = require('react-native');
const { connect } = require('react-redux');
const { ScreenHeader } = require('lib/components/screen-header.js');
const { _, setLocale } = require('lib/locale.js');
const { _ } = require('lib/locale.js');
const { BaseScreenComponent } = require('lib/components/base-screen.js');
const { Dropdown } = require('lib/components/Dropdown.js');
const { themeStyle } = require('lib/components/global-style.js');
@@ -21,7 +21,6 @@ import { PermissionsAndroid } from 'react-native';
import Slider from '@react-native-community/slider';
class ConfigScreenComponent extends BaseScreenComponent {
static navigationOptions(options) {
return { header: null };
}
@@ -38,22 +37,15 @@ class ConfigScreenComponent extends BaseScreenComponent {
this.checkSyncConfig_ = async () => {
await shared.checkSyncConfig(this, this.state.settings);
}
};
this.e2eeConfig_ = () => {
NavService.go('EncryptionConfig');
}
};
this.saveButton_press = async () => {
if (
this.state.changedSettingKeys.includes('sync.target')
&& this.state.settings['sync.target'] === SyncTargetRegistry.nameToId('filesystem')
&& !await this.checkFilesystemPermission()
) {
Alert.alert(
_('Warning'),
_('In order to use file system synchronisation your permission to write to external storage is required.')
);
if (this.state.changedSettingKeys.includes('sync.target') && this.state.settings['sync.target'] === SyncTargetRegistry.nameToId('filesystem') && !(await this.checkFilesystemPermission())) {
Alert.alert(_('Warning'), _('In order to use file system synchronisation your permission to write to external storage is required.'));
// Save settings anyway, even if permission has not been granted
}
return shared.saveSettings(this);
@@ -61,45 +53,39 @@ class ConfigScreenComponent extends BaseScreenComponent {
this.syncStatusButtonPress_ = () => {
NavService.go('Status');
}
};
this.exportDebugButtonPress_ = async () => {
this.setState({ creatingReport: true });
const service = new ReportService();
const logItems = await reg.logger().lastEntries(null);
const logItemRows = [
['Date','Level','Message']
];
const logItemRows = [['Date', 'Level', 'Message']];
for (let i = 0; i < logItems.length; i++) {
const item = logItems[i];
logItemRows.push([
time.formatMsToLocal(item.timestamp, 'MM-DDTHH:mm:ss'),
item.level,
item.message
]);
logItemRows.push([time.formatMsToLocal(item.timestamp, 'MM-DDTHH:mm:ss'), item.level, item.message]);
}
const logItemCsv = service.csvCreate(logItemRows);
const itemListCsv = await service.basicItemList({ format: 'csv' });
const filePath = RNFS.ExternalDirectoryPath + '/syncReport-' + (new Date()).getTime() + '.txt';
const filePath = RNFS.ExternalDirectoryPath + '/syncReport-' + new Date().getTime() + '.txt';
const finalText = [logItemCsv, itemListCsv].join("\n================================================================================\n");
const finalText = [logItemCsv, itemListCsv].join('\n================================================================================\n');
await RNFS.writeFile(filePath, finalText);
alert('Debug report exported to ' + filePath);
this.setState({ creatingReport: false });
}
};
this.fixSearchEngineIndexButtonPress_ = async () => {
this.setState({ fixingSearchIndex: true });
await SearchEngine.instance().rebuildIndex();
this.setState({ fixingSearchIndex: false });
}
};
this.logButtonPress_ = () => {
NavService.go('Log');
}
};
}
async checkFilesystemPermission() {
@@ -107,20 +93,16 @@ class ConfigScreenComponent extends BaseScreenComponent {
// Not implemented yet
return true;
}
const hasPermission = await PermissionsAndroid.check(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
const hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
if (hasPermission) {
return true;
}
const requestResult = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
{
title: _('Information'),
message: _('In order to use file system synchronisation your permission to write to external storage is required.'),
buttonPositive: _('OK'),
},
);
return (requestResult === PermissionsAndroid.RESULTS.GRANTED);
const requestResult = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
title: _('Information'),
message: _('In order to use file system synchronisation your permission to write to external storage is required.'),
buttonPositive: _('OK'),
});
return requestResult === PermissionsAndroid.RESULTS.GRANTED;
}
UNSAFE_componentWillMount() {
@@ -185,7 +167,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
color: theme.color,
flex: 1,
},
}
};
styles.settingContainerNoBottomBorder = Object.assign({}, styles.settingContainer, {
borderBottomWidth: 0,
@@ -208,7 +190,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
styles.linkText.flex = 0;
styles.linkText.fontWeight = 'normal';
styles.headerWrapperStyle = Object.assign({}, styles.settingContainer, theme.headerWrapperStyle)
styles.headerWrapperStyle = Object.assign({}, styles.settingContainer, theme.headerWrapperStyle);
styles.switchSettingControl = Object.assign({}, styles.settingControl);
delete styles.switchSettingControl.color;
@@ -234,7 +216,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
let descriptionComp = null;
if (options.description) {
descriptionComp = (
<View style={{flex:1, marginTop: 10}}>
<View style={{ flex: 1, marginTop: 10 }}>
<Text style={this.styles().descriptionText}>{options.description}</Text>
</View>
);
@@ -242,19 +224,18 @@ class ConfigScreenComponent extends BaseScreenComponent {
return (
<View key={key} style={this.styles().settingContainer}>
<View style={{flex:1, flexDirection: 'column'}}>
<View style={{flex:1}}>
<Button title={title} onPress={clickHandler} disabled={!!options.disabled}/>
<View style={{ flex: 1, flexDirection: 'column' }}>
<View style={{ flex: 1 }}>
<Button title={title} onPress={clickHandler} disabled={!!options.disabled} />
</View>
{ options.statusComp }
{ descriptionComp }
{options.statusComp}
{descriptionComp}
</View>
</View>
);
}
sectionToComponent(key, section, settings) {
const theme = themeStyle(this.props.theme);
const settingComps = [];
for (let i = 0; i < section.metadatas.length; i++) {
@@ -266,10 +247,15 @@ class ConfigScreenComponent extends BaseScreenComponent {
if (syncTargetMd.supportsConfigCheck) {
const messages = shared.checkSyncConfigMessages(this);
const statusComp = !messages.length ? null : (
<View style={{flex:1, marginTop: 10}}>
<View style={{ flex: 1, marginTop: 10 }}>
<Text style={this.styles().descriptionText}>{messages[0]}</Text>
{messages.length >= 1 ? (<View style={{marginTop:10}}><Text style={this.styles().descriptionText}>{messages[1]}</Text></View>) : null}
</View>);
{messages.length >= 1 ? (
<View style={{ marginTop: 10 }}>
<Text style={this.styles().descriptionText}>{messages[1]}</Text>
</View>
) : null}
</View>
);
settingComps.push(this.renderButton('check_sync_config_button', _('Check synchronisation configuration'), this.checkSyncConfig_, { statusComp: statusComp }));
}
@@ -283,14 +269,10 @@ class ConfigScreenComponent extends BaseScreenComponent {
settingComps.push(this.renderButton('e2ee_config_button', _('Encryption Config'), this.e2eeConfig_));
}
const headerWrapperStyle = this.styles().headerWrapperStyle;
return (
<View key={key}>
{this.renderHeader(section.name, Setting.sectionNameToLabel(section.name))}
<View>
{settingComps}
</View>
<View>{settingComps}</View>
</View>
);
}
@@ -302,7 +284,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
const updateSettingValue = (key, value) => {
return shared.updateSettingValue(this, key, value);
}
};
const md = Setting.settingMetadata(key);
const settingDescription = md.description ? md.description() : '';
@@ -317,13 +299,15 @@ class ConfigScreenComponent extends BaseScreenComponent {
items.push({ label: settingOptions[k], value: k.toString() });
}
const descriptionComp = !settingDescription ? null : <Text style={this.styles().settingDescriptionText}>{settingDescription}</Text>
const descriptionComp = !settingDescription ? null : <Text style={this.styles().settingDescriptionText}>{settingDescription}</Text>;
const containerStyle = !settingDescription ? this.styles().settingContainer : this.styles().settingContainerNoBottomBorder;
return (
<View key={key} style={{flexDirection:'column', borderBottomWidth: 1, borderBottomColor: theme.dividerColor}}>
<View key={key} style={{ flexDirection: 'column', borderBottomWidth: 1, borderBottomColor: theme.dividerColor }}>
<View style={containerStyle}>
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
<Text key="label" style={this.styles().settingText}>
{md.label()}
</Text>
<Dropdown
key="control"
style={this.styles().settingControl}
@@ -340,7 +324,9 @@ class ConfigScreenComponent extends BaseScreenComponent {
color: theme.color,
fontSize: theme.fontSize,
}}
onValueChange={(itemValue, itemIndex) => { updateSettingValue(key, itemValue); }}
onValueChange={(itemValue, itemIndex) => {
updateSettingValue(key, itemValue);
}}
/>
</View>
{descriptionComp}
@@ -349,26 +335,32 @@ class ConfigScreenComponent extends BaseScreenComponent {
} else if (md.type == Setting.TYPE_BOOL) {
return (
<View key={key} style={this.styles().switchSettingContainer}>
<Text key="label" style={this.styles().switchSettingText}>{md.label()}</Text>
<Switch key="control" style={this.styles().switchSettingControl} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
<Text key="label" style={this.styles().switchSettingText}>
{md.label()}
</Text>
<Switch key="control" style={this.styles().switchSettingControl} value={value} onValueChange={value => updateSettingValue(key, value)} />
</View>
);
} else if (md.type == Setting.TYPE_INT) {
const unitLabel = md.unitLabel ? md.unitLabel(value) : value;
return (
<View key={key} style={this.styles().settingContainer}>
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
<View style={{display:'flex', flexDirection: 'row', alignItems: 'center', flex:1}}>
<Text key="label" style={this.styles().settingText}>
{md.label()}
</Text>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', flex: 1 }}>
<Text style={this.styles().sliderUnits}>{unitLabel}</Text>
<Slider key="control" minimumTrackTintColor={theme.color} maximumTrackTintColor={theme.color} style={{flex:1}} step={md.step} minimumValue={md.minimum} maximumValue={md.maximum} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
<Slider key="control" minimumTrackTintColor={theme.color} maximumTrackTintColor={theme.color} style={{ flex: 1 }} step={md.step} minimumValue={md.minimum} maximumValue={md.maximum} value={value} onValueChange={value => updateSettingValue(key, value)} />
</View>
</View>
);
} else if (md.type == Setting.TYPE_STRING) {
return (
<View key={key} style={this.styles().settingContainer}>
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
<TextInput autoCorrect={false} autoCompleteType="off" selectionColor={theme.textSelectionColor} autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={(value) => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
<Text key="label" style={this.styles().settingText}>
{md.label()}
</Text>
<TextInput autoCorrect={false} autoCompleteType="off" selectionColor={theme.textSelectionColor} autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={value => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
</View>
);
} else {
@@ -399,10 +391,18 @@ class ConfigScreenComponent extends BaseScreenComponent {
settingComps.push(
<View key="permission_info" style={this.styles().settingContainer}>
<View key="permission_info_wrapper">
<Text key="perm1a" style={this.styles().settingText}>{_('To work correctly, the app needs the following permissions. Please enable them in your phone settings, in Apps > Joplin > Permissions')}</Text>
<Text key="perm2" style={this.styles().permissionText}>{_('- Storage: to allow attaching files to notes and to enable filesystem synchronisation.')}</Text>
<Text key="perm3" style={this.styles().permissionText}>{_('- Camera: to allow taking a picture and attaching it to a note.')}</Text>
<Text key="perm4" style={this.styles().permissionText}>{_('- Location: to allow attaching geo-location information to a note.')}</Text>
<Text key="perm1a" style={this.styles().settingText}>
{_('To work correctly, the app needs the following permissions. Please enable them in your phone settings, in Apps > Joplin > Permissions')}
</Text>
<Text key="perm2" style={this.styles().permissionText}>
{_('- Storage: to allow attaching files to notes and to enable filesystem synchronisation.')}
</Text>
<Text key="perm3" style={this.styles().permissionText}>
{_('- Camera: to allow taking a picture and attaching it to a note.')}
</Text>
<Text key="perm4" style={this.styles().permissionText}>
{_('- Location: to allow attaching geo-location information to a note.')}
</Text>
</View>
</View>
);
@@ -410,31 +410,49 @@ class ConfigScreenComponent extends BaseScreenComponent {
settingComps.push(
<View key="donate_link" style={this.styles().settingContainer}>
<TouchableOpacity onPress={() => { Linking.openURL('https://joplinapp.org/donate/') }}>
<Text key="label" style={this.styles().linkText}>{_('Make a donation')}</Text>
<TouchableOpacity
onPress={() => {
Linking.openURL('https://joplinapp.org/donate/');
}}
>
<Text key="label" style={this.styles().linkText}>
{_('Make a donation')}
</Text>
</TouchableOpacity>
</View>
);
settingComps.push(
<View key="website_link" style={this.styles().settingContainer}>
<TouchableOpacity onPress={() => { Linking.openURL('https://joplinapp.org/') }}>
<Text key="label" style={this.styles().linkText}>{_('Joplin website')}</Text>
<TouchableOpacity
onPress={() => {
Linking.openURL('https://joplinapp.org/');
}}
>
<Text key="label" style={this.styles().linkText}>
{_('Joplin website')}
</Text>
</TouchableOpacity>
</View>
);
settingComps.push(
<View key="privacy_link" style={this.styles().settingContainer}>
<TouchableOpacity onPress={() => { Linking.openURL('https://joplinapp.org/privacy/') }}>
<Text key="label" style={this.styles().linkText}>Privacy Policy</Text>
<TouchableOpacity
onPress={() => {
Linking.openURL('https://joplinapp.org/privacy/');
}}
>
<Text key="label" style={this.styles().linkText}>
Privacy Policy
</Text>
</TouchableOpacity>
</View>
);
settingComps.push(
<View key="version_info_app" style={this.styles().settingContainer}>
<Text style={this.styles().settingText}>{"Joplin " + VersionInfo.appVersion}</Text>
<Text style={this.styles().settingText}>{'Joplin ' + VersionInfo.appVersion}</Text>
</View>
);
@@ -452,30 +470,18 @@ class ConfigScreenComponent extends BaseScreenComponent {
return (
<View style={this.rootStyle(this.props.theme).root}>
<ScreenHeader
title={_('Configuration')}
showSaveButton={true}
showSearchButton={false}
showSideMenuButton={false}
saveButtonDisabled={!this.state.changedSettingKeys.length}
onSaveButtonPress={this.saveButton_press}
/>
<ScrollView >
{ settingComps }
</ScrollView>
<ScreenHeader title={_('Configuration')} showSaveButton={true} showSearchButton={false} showSideMenuButton={false} saveButtonDisabled={!this.state.changedSettingKeys.length} onSaveButtonPress={this.saveButton_press} />
<ScrollView>{settingComps}</ScrollView>
</View>
);
}
}
const ConfigScreen = connect(
(state) => {
return {
settings: state.settings,
theme: state.settings.theme,
};
}
)(ConfigScreenComponent)
const ConfigScreen = connect(state => {
return {
settings: state.settings,
theme: state.settings.theme,
};
})(ConfigScreenComponent);
module.exports = { ConfigScreen };

View File

@@ -8,7 +8,6 @@ const { _ } = require('lib/locale.js');
const { BaseScreenComponent } = require('lib/components/base-screen.js');
const { themeStyle } = require('lib/components/global-style.js');
const { time } = require('lib/time-utils.js');
const Setting = require('lib/models/Setting.js');
const shared = require('lib/components/shared/encryption-config-shared.js');
const { dialogs } = require('lib/dialogs.js');
const DialogBox = require('react-native-dialogbox').default;
@@ -106,7 +105,6 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
const password = this.state.passwords[mk.id] ? this.state.passwords[mk.id] : '';
const passwordOk = this.state.passwordChecks[mk.id] === true ? '✔' : '❌';
const active = this.props.activeMasterKeyId === mk.id ? '✔' : '';
const inputStyle = { flex: 1, marginRight: 10, color: theme.color };
inputStyle.borderBottomWidth = 1;

View File

@@ -1,10 +1,9 @@
const React = require('react'); const Component = React.Component;
const { Platform, Clipboard, Keyboard, BackHandler, View, Button, TextInput, Text, StyleSheet, Linking, Image, Share } = require('react-native');
const React = require('react');
const { Platform, Clipboard, Keyboard, View, TextInput, StyleSheet, Linking, Image, Share } = require('react-native');
const { connect } = require('react-redux');
const { uuid } = require('lib/uuid.js');
const RNFS = require('react-native-fs');
const Note = require('lib/models/Note.js');
const ObjectUtils = require('lib/ObjectUtils.js');
const BaseItem = require('lib/models/BaseItem.js');
const Setting = require('lib/models/Setting.js');
const Resource = require('lib/models/Resource.js');
@@ -14,8 +13,7 @@ const { BackButtonService } = require('lib/services/back-button.js');
const NavService = require('lib/services/NavService.js');
const BaseModel = require('lib/BaseModel.js');
const { ActionButton } = require('lib/components/action-button.js');
const Icon = require('react-native-vector-icons/Ionicons').default;
const { fileExtension, basename, safeFileExtension } = require('lib/path-utils.js');
const { fileExtension, safeFileExtension } = require('lib/path-utils.js');
const mimeUtils = require('lib/mime-utils.js').mime;
const { ScreenHeader } = require('lib/components/screen-header.js');
const NoteTagsDialog = require('lib/components/screens/NoteTagsDialog');
@@ -26,16 +24,14 @@ const { reg } = require('lib/registry.js');
const { shim } = require('lib/shim.js');
const ResourceFetcher = require('lib/services/ResourceFetcher');
const { BaseScreenComponent } = require('lib/components/base-screen.js');
const { globalStyle, themeStyle } = require('lib/components/global-style.js');
const { themeStyle } = require('lib/components/global-style.js');
const { dialogs } = require('lib/dialogs.js');
const DialogBox = require('react-native-dialogbox').default;
const { NoteBodyViewer } = require('lib/components/note-body-viewer.js');
const RNFetchBlob = require('rn-fetch-blob').default;
const { DocumentPicker, DocumentPickerUtil } = require('react-native-document-picker');
const ImageResizer = require('react-native-image-resizer').default;
const shared = require('lib/components/shared/note-screen-shared.js');
const ImagePicker = require('react-native-image-picker');
const AlarmService = require('lib/services/AlarmService.js');
const { SelectDateTimeDialog } = require('lib/components/select-date-time-dialog.js');
const ShareExtension = require('react-native-share-extension').default;
const CameraView = require('lib/components/CameraView');
@@ -44,7 +40,6 @@ const SearchEngine = require('lib/services/SearchEngine');
import FileViewer from 'react-native-file-viewer';
class NoteScreenComponent extends BaseScreenComponent {
static navigationOptions(options) {
return { header: null };
}
@@ -59,7 +54,7 @@ class NoteScreenComponent extends BaseScreenComponent {
isLoading: true,
titleTextInputHeight: 20,
alarmDialogShown: false,
heightBumpView:0,
heightBumpView: 0,
noteTagDialogShown: false,
fromShare: false,
showCamera: false,
@@ -70,7 +65,7 @@ class NoteScreenComponent extends BaseScreenComponent {
// appear one day and did not go away - reverting to an old RN version did not help, undoing all
// the commits till a working version did not help. The bug also does not happen in the simulator which makes it hard to fix.
// Eventually, a way that "worked" is to add a 1px margin on top of the text input just after the webview has loaded, then removing this
// margin. This forces RN to update the text input and to display it. Maybe that hack can be removed once RN is upgraded.
// margin. This forces RN to update the text input and to display it. Maybe that hack can be removed once RN is upgraded.
// See https://github.com/laurent22/joplin/issues/1057
HACK_webviewLoadingState: 0,
};
@@ -86,22 +81,18 @@ 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' },
]);
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' }]);
if (buttonId == 'cancel') return true;
if (buttonId == 'save') await this.saveNoteButton_press();
}
return false;
}
};
this.navHandler = async () => {
return await saveDialog();
}
};
this.backHandler = async () => {
const r = await saveDialog();
@@ -112,7 +103,7 @@ class NoteScreenComponent extends BaseScreenComponent {
}
if (this.state.mode == 'edit') {
Keyboard.dismiss()
Keyboard.dismiss();
this.setState({
note: Object.assign({}, this.state.lastSavedNote),
@@ -127,9 +118,9 @@ class NoteScreenComponent extends BaseScreenComponent {
this.noteTagDialog_closeRequested = () => {
this.setState({ noteTagDialogShown: false });
}
};
this.onJoplinLinkClick_ = async (msg) => {
this.onJoplinLinkClick_ = async msg => {
try {
if (msg.indexOf('joplin://') === 0) {
const itemId = msg.substr('joplin://'.length);
@@ -168,9 +159,9 @@ class NoteScreenComponent extends BaseScreenComponent {
} catch (error) {
dialogs.error(this, error.message);
}
}
};
this.refreshResource = async (resource) => {
this.refreshResource = async resource => {
if (!this.state.note || !this.state.note.body) return;
const resourceIds = await Note.linkedResourceIds(this.state.note.body);
if (resourceIds.indexOf(resource.id) >= 0 && this.refs.noteBodyViewer) {
@@ -180,7 +171,7 @@ class NoteScreenComponent extends BaseScreenComponent {
this.refs.noteBodyViewer.rebuildMd();
});
}
}
};
this.takePhoto_onPress = this.takePhoto_onPress.bind(this);
this.cameraView_onPhoto = this.cameraView_onPhoto.bind(this);
@@ -365,7 +356,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async pickDocument() {
return new Promise((resolve, reject) => {
DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error,res) => {
DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error, res) => {
if (error) {
// Also returns an error if the user doesn't pick a file
// so just resolve with null.
@@ -381,15 +372,21 @@ class NoteScreenComponent extends BaseScreenComponent {
async imageDimensions(uri) {
return new Promise((resolve, reject) => {
Image.getSize(uri, (width, height) => {
resolve({ width: width, height: height });
}, (error) => { reject(error) });
Image.getSize(
uri,
(width, height) => {
resolve({ width: width, height: height });
},
error => {
reject(error);
}
);
});
}
showImagePicker(options) {
return new Promise((resolve, reject) => {
ImagePicker.launchImageLibrary(options, (response) => {
ImagePicker.launchImageLibrary(options, response => {
resolve(response);
});
});
@@ -424,7 +421,7 @@ class NoteScreenComponent extends BaseScreenComponent {
}
}
async attachFile(pickerResponse, fileType) {
async attachFile(pickerResponse, fileType) {
if (!pickerResponse) {
reg.logger().warn('Got no response from picker');
return;
@@ -444,7 +441,7 @@ class NoteScreenComponent extends BaseScreenComponent {
android: pickerResponse.uri,
ios: decodeURI(pickerResponse.uri),
});
let mimeType = pickerResponse.type;
if (!mimeType) {
@@ -508,7 +505,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const resourceTag = Resource.markdownTag(resource);
const newNote = Object.assign({}, this.state.note);
newNote.body += "\n" + resourceTag;
newNote.body += '\n' + resourceTag;
this.setState({ note: newNote });
this.refreshResource(resource);
@@ -523,15 +520,18 @@ class NoteScreenComponent extends BaseScreenComponent {
takePhoto_onPress() {
this.setState({ showCamera: true });
}
}
cameraView_onPhoto(data) {
this.attachFile({
uri: data.uri,
didCancel: false,
error: null,
type: 'image/jpg',
}, 'image');
this.attachFile(
{
uri: data.uri,
didCancel: false,
error: null,
type: 'image/jpg',
},
'image'
);
this.setState({ showCamera: false });
}
@@ -626,8 +626,19 @@ class NoteScreenComponent extends BaseScreenComponent {
output.push({ title: _('Updated: %s', updatedDateString) });
output.push({ isDivider: true });
output.push({ title: _('View on map'), onPress: () => { this.showOnMap_onPress(); } });
if (!!note.source_url) output.push({ title: _('Go to source URL'), onPress: () => { this.showSource_onPress(); } });
output.push({
title: _('View on map'),
onPress: () => {
this.showOnMap_onPress();
},
});
if (note.source_url)
output.push({
title: _('Go to source URL'),
onPress: () => {
this.showSource_onPress();
},
});
return output;
}
@@ -649,29 +660,65 @@ class NoteScreenComponent extends BaseScreenComponent {
let canAttachPicture = true;
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
if (canAttachPicture) {
output.push({ title: _('Attach...'), onPress: async () => {
const buttonId = await dialogs.pop(this, _('Choose an option'), [
{ text: _('Take photo'), id: 'takePhoto' },
{ text: _('Attach photo'), id: 'attachPhoto' },
{ text: _('Attach any file'), id: 'attachFile' },
]);
output.push({
title: _('Attach...'),
onPress: async () => {
const buttonId = await dialogs.pop(this, _('Choose an option'), [{ text: _('Take photo'), id: 'takePhoto' }, { text: _('Attach photo'), id: 'attachPhoto' }, { text: _('Attach any file'), id: 'attachFile' }]);
if (buttonId === 'takePhoto') this.takePhoto_onPress();
if (buttonId === 'attachPhoto') this.attachPhoto_onPress();
if (buttonId === 'attachFile') this.attachFile_onPress();
}});
if (buttonId === 'takePhoto') this.takePhoto_onPress();
if (buttonId === 'attachPhoto') this.attachPhoto_onPress();
if (buttonId === 'attachFile') this.attachFile_onPress();
},
});
}
if (isTodo) {
output.push({ title: _('Set alarm'), onPress: () => { this.setState({ alarmDialogShown: true }) }});;
output.push({
title: _('Set alarm'),
onPress: () => {
this.setState({ alarmDialogShown: true });
},
});
}
output.push({ title: _('Share'), onPress: () => { this.share_onPress(); } });
if (isSaved) output.push({ title: _('Tags'), onPress: () => { this.tags_onPress(); } });
output.push({ title: isTodo ? _('Convert to note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } });
if (isSaved) output.push({ title: _('Copy Markdown link'), onPress: () => { this.copyMarkdownLink_onPress(); } });
output.push({ title: _('Properties'), onPress: () => { this.properties_onPress(); } });
output.push({ title: _('Delete'), onPress: () => { this.deleteNote_onPress(); } });
output.push({
title: _('Share'),
onPress: () => {
this.share_onPress();
},
});
if (isSaved)
output.push({
title: _('Tags'),
onPress: () => {
this.tags_onPress();
},
});
output.push({
title: isTodo ? _('Convert to note') : _('Convert to todo'),
onPress: () => {
this.toggleIsTodo_onPress();
},
});
if (isSaved)
output.push({
title: _('Copy Markdown link'),
onPress: () => {
this.copyMarkdownLink_onPress();
},
});
output.push({
title: _('Properties'),
onPress: () => {
this.properties_onPress();
},
});
output.push({
title: _('Delete'),
onPress: () => {
this.deleteNote_onPress();
},
});
this.menuOptionsCache_ = {};
this.menuOptionsCache_[cacheKey] = output;
@@ -693,7 +740,7 @@ class NoteScreenComponent extends BaseScreenComponent {
focusUpdate() {
this.scheduleFocusUpdateIID_ = null;
if (!this.state.note) return;
let fieldToFocus = !!this.state.note.is_todo ? 'title' : 'body';
let fieldToFocus = this.state.note.is_todo ? 'title' : 'body';
if (this.state.mode === 'view') fieldToFocus = '';
if (fieldToFocus === 'title') this.refs.titleTextField.focus();
@@ -737,7 +784,7 @@ class NoteScreenComponent extends BaseScreenComponent {
if (this.state.isLoading) {
return (
<View style={this.styles().screen}>
<ScreenHeader/>
<ScreenHeader />
</View>
);
}
@@ -745,16 +792,14 @@ class NoteScreenComponent extends BaseScreenComponent {
const theme = themeStyle(this.props.theme);
const note = this.state.note;
const isTodo = !!Number(note.is_todo);
const folder = this.state.folder;
const isNew = !note.id;
if (this.state.showCamera) {
return <CameraView theme={this.props.theme} style={{flex:1}} onPhoto={this.cameraView_onPhoto} onCancel={this.cameraView_onCancel}/>
return <CameraView theme={this.props.theme} style={{ flex: 1 }} onPhoto={this.cameraView_onPhoto} onCancel={this.cameraView_onCancel} />;
}
let bodyComponent = null;
if (this.state.mode == 'view') {
const onCheckboxChange = (newBody) => {
const onCheckboxChange = newBody => {
this.saveOneProperty('body', newBody);
};
@@ -767,45 +812,37 @@ class NoteScreenComponent extends BaseScreenComponent {
// Note: as of 2018-12-29 it's important not to display the viewer if the note body is empty,
// to avoid the HACK_webviewLoadingState related bug.
bodyComponent = !note || !note.body.trim() ? null : <NoteBodyViewer
onJoplinLinkClick={this.onJoplinLinkClick_}
ref="noteBodyViewer"
style={this.styles().noteBodyViewer}
webViewStyle={theme}
note={note}
noteResources={this.state.noteResources}
highlightedKeywords={keywords}
theme={this.props.theme}
onCheckboxChange={(newBody) => { onCheckboxChange(newBody) }}
onMarkForDownload={this.onMarkForDownload}
onLoadEnd={() => {
setTimeout(() => {
this.setState({ HACK_webviewLoadingState: 1 });
setTimeout(() => {
this.setState({ HACK_webviewLoadingState: 0 });
}, 50);
}, 5);
}}
/>
bodyComponent =
!note || !note.body.trim() ? null : (
<NoteBodyViewer
onJoplinLinkClick={this.onJoplinLinkClick_}
ref="noteBodyViewer"
style={this.styles().noteBodyViewer}
webViewStyle={theme}
note={note}
noteResources={this.state.noteResources}
highlightedKeywords={keywords}
theme={this.props.theme}
onCheckboxChange={newBody => {
onCheckboxChange(newBody);
}}
onMarkForDownload={this.onMarkForDownload}
onLoadEnd={() => {
setTimeout(() => {
this.setState({ HACK_webviewLoadingState: 1 });
setTimeout(() => {
this.setState({ HACK_webviewLoadingState: 0 });
}, 50);
}, 5);
}}
/>
);
} else {
// autoFocus={fieldToFocus === 'body'}
// Note: blurOnSubmit is necessary to get multiline to work.
// See https://github.com/facebook/react-native/issues/12717#issuecomment-327001997
bodyComponent = (
<TextInput
autoCapitalize="sentences"
style={this.styles().bodyTextInput}
ref="noteBodyTextField"
multiline={true}
value={note.body}
onChangeText={(text) => this.body_changeText(text)}
blurOnSubmit={false}
selectionColor={theme.textSelectionColor}
placeholder={_('Add body')}
placeholderTextColor={theme.colorFaded}
/>
);
bodyComponent = <TextInput autoCapitalize="sentences" style={this.styles().bodyTextInput} ref="noteBodyTextField" multiline={true} value={note.body} onChangeText={text => this.body_changeText(text)} blurOnSubmit={false} selectionColor={theme.textSelectionColor} placeholder={_('Add body')} placeholderTextColor={theme.colorFaded} />;
}
const renderActionButton = () => {
@@ -823,8 +860,8 @@ class NoteScreenComponent extends BaseScreenComponent {
if (this.state.mode == 'edit') return null;
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />
}
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />;
};
const actionButtonComp = renderActionButton();
@@ -839,69 +876,45 @@ class NoteScreenComponent extends BaseScreenComponent {
const titleComp = (
<View style={titleContainerStyle}>
{ isTodo && <Checkbox style={this.styles().checkbox} checked={!!Number(note.todo_completed)} onChange={this.todoCheckbox_change} /> }
<TextInput
onContentSizeChange={this.titleTextInput_contentSizeChange}
multiline={this.enableMultilineTitle_}
ref="titleTextField"
underlineColorAndroid="#ffffff00"
autoCapitalize="sentences"
style={this.styles().titleTextInput}
value={note.title}
onChangeText={this.title_changeText}
selectionColor={theme.textSelectionColor}
placeholder={_('Add title')}
placeholderTextColor={theme.colorFaded}
/>
{isTodo && <Checkbox style={this.styles().checkbox} checked={!!Number(note.todo_completed)} onChange={this.todoCheckbox_change} />}
<TextInput onContentSizeChange={this.titleTextInput_contentSizeChange} multiline={this.enableMultilineTitle_} ref="titleTextField" underlineColorAndroid="#ffffff00" autoCapitalize="sentences" style={this.styles().titleTextInput} value={note.title} onChangeText={this.title_changeText} selectionColor={theme.textSelectionColor} placeholder={_('Add title')} placeholderTextColor={theme.colorFaded} />
</View>
);
const noteTagDialog = !this.state.noteTagDialogShown ? null : <NoteTagsDialog onCloseRequested={this.noteTagDialog_closeRequested}/>;
const noteTagDialog = !this.state.noteTagDialogShown ? null : <NoteTagsDialog onCloseRequested={this.noteTagDialog_closeRequested} />;
return (
<View style={this.rootStyle(this.props.theme).root}>
<ScreenHeader
folderPickerOptions={this.folderPickerOptions()}
menuOptions={this.menuOptions()}
showSaveButton={showSaveButton}
saveButtonDisabled={saveButtonDisabled}
onSaveButtonPress={this.saveNoteButton_press}
showSideMenuButton={false}
showSearchButton={false}
/>
{ titleComp }
{ bodyComponent }
{ actionButtonComp }
<ScreenHeader folderPickerOptions={this.folderPickerOptions()} menuOptions={this.menuOptions()} showSaveButton={showSaveButton} saveButtonDisabled={saveButtonDisabled} onSaveButtonPress={this.saveNoteButton_press} showSideMenuButton={false} showSearchButton={false} />
{titleComp}
{bodyComponent}
{actionButtonComp}
<SelectDateTimeDialog
shown={this.state.alarmDialogShown}
date={dueDate}
onAccept={this.onAlarmDialogAccept}
onReject={this.onAlarmDialogReject}
/>
<SelectDateTimeDialog shown={this.state.alarmDialogShown} date={dueDate} onAccept={this.onAlarmDialogAccept} onReject={this.onAlarmDialogReject} />
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
{ noteTagDialog }
<DialogBox
ref={dialogbox => {
this.dialogbox = dialogbox;
}}
/>
{noteTagDialog}
</View>
);
}
}
const NoteScreen = connect(
(state) => {
return {
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
folderId: state.selectedFolderId,
itemType: state.selectedItemType,
folders: state.folders,
searchQuery: state.searchQuery,
theme: state.settings.theme,
ftsEnabled: state.settings['db.ftsEnabled'],
sharedData: state.sharedData,
showSideMenu: state.showSideMenu,
};
}
)(NoteScreenComponent)
const NoteScreen = connect(state => {
return {
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
folderId: state.selectedFolderId,
itemType: state.selectedItemType,
folders: state.folders,
searchQuery: state.searchQuery,
theme: state.settings.theme,
ftsEnabled: state.settings['db.ftsEnabled'],
sharedData: state.sharedData,
showSideMenu: state.showSideMenu,
};
})(NoteScreenComponent);
module.exports = { NoteScreen };

View File

@@ -73,7 +73,6 @@ class NotesScreenComponent extends BaseScreenComponent {
styles() {
if (!this.styles_) this.styles_ = {};
const themeId = this.props.theme;
const theme = themeStyle(themeId);
const cacheKey = themeId;
if (this.styles_[cacheKey]) return this.styles_[cacheKey];
@@ -178,7 +177,7 @@ class NotesScreenComponent extends BaseScreenComponent {
output = { id: this.props.selectedSmartFilterId, title: _('All notes') };
} else {
return null;
throw new Error('Invalid parent type: ' + props.notesParentType);
// throw new Error('Invalid parent type: ' + props.notesParentType);
}
return output;
}

View File

@@ -4,7 +4,6 @@ const { View } = require('react-native');
const { Button } = require('react-native');
const { WebView } = require('react-native-webview');
const { connect } = require('react-redux');
const Setting = require('lib/models/Setting.js');
const { ScreenHeader } = require('lib/components/screen-header.js');
const { reg } = require('lib/registry.js');
const { _ } = require('lib/locale.js');

View File

@@ -4,8 +4,6 @@ const { StyleSheet, View, Text, Button, FlatList } = require('react-native');
const Setting = require('lib/models/Setting.js');
const { connect } = require('react-redux');
const { ScreenHeader } = require('lib/components/screen-header.js');
const BaseItem = require('lib/models/BaseItem.js');
const Folder = require('lib/models/Folder.js');
const { ReportService } = require('lib/services/report.js');
const { _ } = require('lib/locale.js');
const { BaseScreenComponent } = require('lib/components/base-screen.js');
@@ -44,7 +42,6 @@ class StatusScreenComponent extends BaseScreenComponent {
const theme = themeStyle(this.props.theme);
const renderBody = report => {
let output = [];
let baseStyle = {
paddingLeft: 6,
paddingRight: 6,

View File

@@ -1,72 +0,0 @@
const React = require('react');
const { View } = require('react-native');
const { connect } = require('react-redux');
const { ScreenHeader } = require('lib/components/screen-header.js');
const Icon = require('react-native-vector-icons/Ionicons').default;
const Note = require('lib/models/Note.js');
const { BaseScreenComponent } = require('lib/components/base-screen.js');
let styles = {
body: {
flex: 1,
},
};
class TagScreenComponent extends BaseScreenComponent {
static navigationOptions(options) {
return { header: null };
}
componentDidMount() {
this.refreshNotes();
}
UNSAFE_componentWillReceiveProps(newProps) {
if (newProps.selectedTagId !== this.props.selectedTagId) {
this.refreshNotes(newProps);
}
}
async refreshNotes(props = null) {
if (props === null) props = this.props;
const source = JSON.stringify({ selectedTagId: props.selectedTagId });
if (source == props.tagNotesSource) return;
const notes = await Tag.notes(props.selectedTagId);
this.props.dispatch({
type: 'NOTE_UPDATE_ALL',
notes: notes,
notesSource: source,
});
}
render() {
let title = tag ? tag.title : '';
const {} = this.props.navigation;
return (
<View style={this.styles().screen}>
<ScreenHeader title={title} menuOptions={this.menuOptions()} />
<NoteList style={{ flex: 1 }} />
<DialogBox
ref={dialogbox => {
this.dialogbox = dialogbox;
}}
/>
</View>
);
}
}
const TagScreen = connect(state => {
return {
tag: tag,
notes: state.notes,
notesSource: state.notesSource,
};
})(TagScreenComponent);
module.exports = { TagScreen };

View File

@@ -2,14 +2,10 @@ const React = require('react');
const { View, Text, FlatList, StyleSheet, TouchableOpacity } = require('react-native');
const { connect } = require('react-redux');
const Folder = require('lib/models/Folder.js');
const Tag = require('lib/models/Tag.js');
const Note = require('lib/models/Note.js');
const Setting = require('lib/models/Setting.js');
const { themeStyle } = require('lib/components/global-style.js');
const { ScreenHeader } = require('lib/components/screen-header.js');
const { _ } = require('lib/locale.js');
const DialogBox = require('react-native-dialogbox').default;
const { BaseScreenComponent } = require('lib/components/base-screen.js');
class TagsScreenComponent extends BaseScreenComponent {

View File

@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { Keyboard, View, Button, Text, StyleSheet, Linking, Image } from 'react-native';
import React from 'react';
import { View } from 'react-native';
import PopupDialog, { DialogTitle, DialogButton } from 'react-native-popup-dialog';
import DatePicker from 'react-native-datepicker'
import DatePicker from 'react-native-datepicker';
import moment from 'moment';
import { _ } from 'lib/locale.js';
@@ -41,7 +41,7 @@ class SelectDateTimeDialog extends React.PureComponent {
}
dateTimeFormat() {
return "MM/DD/YYYY HH:mm";
return 'MM/DD/YYYY HH:mm';
}
stringToDate(s) {
@@ -61,12 +61,12 @@ class SelectDateTimeDialog extends React.PureComponent {
}
render() {
const clearAlarmText = _("Clear alarm"); // For unknown reasons, this particular string doesn't get translated if it's directly in the text property below
const clearAlarmText = _('Clear alarm'); // For unknown reasons, this particular string doesn't get translated if it's directly in the text property below
const popupActions = [
<DialogButton text={_("Save alarm")} align="center" onPress={() => this.onAccept()} key="saveButton" />,
<DialogButton text={_('Save alarm')} align="center" onPress={() => this.onAccept()} key="saveButton" />,
<DialogButton text={clearAlarmText} align="center" onPress={() => this.onClear()} key="clearButton" />,
<DialogButton text={_("Cancel")} align="center" onPress={() => this.onReject()} key="cancelButton" />,
<DialogButton text={_('Cancel')} align="center" onPress={() => this.onReject()} key="cancelButton" />,
];
return (
@@ -77,7 +77,7 @@ class SelectDateTimeDialog extends React.PureComponent {
dismissOnTouchOutside={false}
width={0.9}
height={350}
>
>
<View style={{flex:1, margin: 20, alignItems:'center'}}>
<DatePicker
date={this.state.date}
@@ -104,4 +104,4 @@ class SelectDateTimeDialog extends React.PureComponent {
}
export { SelectDateTimeDialog };
export { SelectDateTimeDialog };

View File

@@ -188,6 +188,7 @@ shared.attachedResources = async function(noteBody) {
localState: localState,
};
// eslint-disable-next-line require-atomic-updates
resourceCache_[id] = o;
output[id] = o;
}
@@ -229,6 +230,7 @@ shared.initState = async function(comp) {
this.noteComponent_change(comp, 'body', comp.props.sharedData.value);
}
// eslint-disable-next-line require-atomic-updates
comp.lastLoadedNoteId_ = note ? note.id : null;
};

View File

@@ -1,4 +1,3 @@
const ArrayUtils = require('lib/ArrayUtils');
const Folder = require('lib/models/Folder');
const BaseModel = require('lib/BaseModel');
@@ -22,8 +21,6 @@ function folderIsVisible(folders, folderId, collapsedFolderIds) {
if (collapsedFolderIds.indexOf(folder.parent_id) >= 0) return false;
folderId = folder.parent_id;
}
return true;
}
function renderFoldersRecursive_(props, renderItem, items, parentId, depth, order) {
@@ -85,7 +82,6 @@ shared.renderTags = function(props, renderItem) {
// }
shared.synchronize_press = async function(comp) {
const Setting = require('lib/models/Setting.js');
const { reg } = require('lib/registry.js');
const action = comp.props.syncStarted ? 'cancel' : 'start';

View File

@@ -3,13 +3,7 @@ const Component = React.Component;
const { TouchableOpacity, Text, StyleSheet, ScrollView, View } = require('react-native');
const { connect } = require('react-redux');
const Icon = require('react-native-vector-icons/Ionicons').default;
const Tag = require('lib/models/Tag.js');
const Note = require('lib/models/Note.js');
const Folder = require('lib/models/Folder.js');
const Setting = require('lib/models/Setting.js');
const NavService = require('lib/services/NavService.js');
const { globalStyle, themeStyle } = require('lib/components/global-style.js');
const shared = require('lib/components/shared/side-menu-shared.js');
class SideMenuContentNoteComponent extends Component {
constructor() {
@@ -56,8 +50,6 @@ class SideMenuContentNoteComponent extends Component {
}
renderSideBarButton(key, title, iconName, onPressHandler) {
const theme = themeStyle(this.props.theme);
const content = (
<View key={key} style={onPressHandler ? this.styles().sideButton : this.styles().sideButtonDisabled}>
{!iconName ? null : <Icon name={iconName} style={this.styles().sidebarIcon} />}

View File

@@ -3,10 +3,7 @@ const Component = React.Component;
const { Easing, Animated, TouchableOpacity, Text, StyleSheet, ScrollView, View, Alert } = require('react-native');
const { connect } = require('react-redux');
const Icon = require('react-native-vector-icons/Ionicons').default;
const Tag = require('lib/models/Tag.js');
const Note = require('lib/models/Note.js');
const Folder = require('lib/models/Folder.js');
const Setting = require('lib/models/Setting.js');
const { Synchronizer } = require('lib/synchronizer.js');
const NavService = require('lib/services/NavService.js');
const { _ } = require('lib/locale.js');
@@ -122,8 +119,6 @@ class SideMenuContentComponent extends Component {
async folder_longPress(folder) {
if (folder === 'all') return;
const buttons = [];
Alert.alert(
'',
_('Notebook: %s', folder.title),
@@ -278,8 +273,6 @@ class SideMenuContentComponent extends Component {
}
renderSideBarButton(key, title, iconName, onPressHandler = null, selected = false) {
const theme = themeStyle(this.props.theme);
let icon = <Icon name={iconName} style={this.styles().sidebarIcon} />;
if (key === 'synchronize_button') {

View File

@@ -1,5 +1,3 @@
const React = require('react');
const { connect } = require('react-redux');
const SideMenu_ = require('react-native-side-menu').default;