1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Mobile: Fixes #299: App freezes when connecting to OneDrive login page while internet connection is down

This commit is contained in:
Laurent Cozic 2018-03-14 23:17:02 +00:00
parent 26331f61e1
commit 9e0bf1acb2
20 changed files with 5 additions and 65 deletions

View File

@ -1,4 +1,3 @@
const { Log } = require('lib/log.js');
const { Database } = require('lib/database.js'); const { Database } = require('lib/database.js');
const { uuid } = require('lib/uuid.js'); const { uuid } = require('lib/uuid.js');
const { time } = require('lib/time-utils.js'); const { time } = require('lib/time-utils.js');
@ -423,7 +422,7 @@ class BaseModel {
output = this.filter(o); output = this.filter(o);
} catch (error) { } catch (error) {
Log.error('Cannot save model', error); this.logger().error('Cannot save model', error);
} }
this.releaseSaveMutex(o, mutexRelease); this.releaseSaveMutex(o, mutexRelease);

View File

@ -4,7 +4,6 @@ const Icon = require('react-native-vector-icons/Ionicons').default;
const ReactNativeActionButton = require('react-native-action-button').default; const ReactNativeActionButton = require('react-native-action-button').default;
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { globalStyle } = require('lib/components/global-style.js'); const { globalStyle } = require('lib/components/global-style.js');
const { Log } = require('lib/log.js');
const { _ } = require('lib/locale.js'); const { _ } = require('lib/locale.js');
const styles = StyleSheet.create({ const styles = StyleSheet.create({

View File

@ -104,7 +104,7 @@ class NoteBodyViewer extends Component {
style={webViewStyle} style={webViewStyle}
source={source} source={source}
onLoadEnd={() => this.onLoadEnd()} onLoadEnd={() => this.onLoadEnd()}
onError={(e) => reg.logger().error('WebView error', e) } onError={() => reg.logger().error('WebView error') }
onMessage={(event) => { onMessage={(event) => {
let msg = event.nativeEvent.data; let msg = event.nativeEvent.data;

View File

@ -1,7 +1,6 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { ListView, Text, TouchableOpacity , View, StyleSheet } = require('react-native'); const { ListView, Text, TouchableOpacity , View, StyleSheet } = require('react-native');
const { Log } = require('lib/log.js');
const { _ } = require('lib/locale.js'); const { _ } = require('lib/locale.js');
const { Checkbox } = require('lib/components/checkbox.js'); const { Checkbox } = require('lib/components/checkbox.js');
const { reg } = require('lib/registry.js'); const { reg } = require('lib/registry.js');

View File

@ -1,7 +1,6 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { ListView, Text, TouchableHighlight, Switch, View, StyleSheet } = require('react-native'); const { ListView, Text, TouchableHighlight, Switch, View, StyleSheet } = require('react-native');
const { Log } = require('lib/log.js');
const { _ } = require('lib/locale.js'); const { _ } = require('lib/locale.js');
const { Checkbox } = require('lib/components/checkbox.js'); const { Checkbox } = require('lib/components/checkbox.js');
const { NoteItem } = require('lib/components/note-item.js'); const { NoteItem } = require('lib/components/note-item.js');

View File

@ -2,7 +2,6 @@ const React = require('react'); const Component = React.Component;
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Platform, View, Text, Button, StyleSheet, TouchableOpacity, Image, ScrollView, Dimensions } = require('react-native'); const { Platform, View, Text, Button, StyleSheet, TouchableOpacity, Image, ScrollView, Dimensions } = require('react-native');
const Icon = require('react-native-vector-icons/Ionicons').default; const Icon = require('react-native-vector-icons/Ionicons').default;
const { Log } = require('lib/log.js');
const { BackButtonService } = require('lib/services/back-button.js'); const { BackButtonService } = require('lib/services/back-button.js');
const NavService = require('lib/services/NavService.js'); const NavService = require('lib/services/NavService.js');
const { ReportService } = require('lib/services/report.js'); const { ReportService } = require('lib/services/report.js');

View File

@ -1,7 +1,6 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { View, Button, TextInput, StyleSheet } = require('react-native'); const { View, Button, TextInput, StyleSheet } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const { ActionButton } = require('lib/components/action-button.js'); const { ActionButton } = require('lib/components/action-button.js');
const Folder = require('lib/models/Folder.js'); const Folder = require('lib/models/Folder.js');
const BaseModel = require('lib/BaseModel.js'); const BaseModel = require('lib/BaseModel.js');

View File

@ -1,7 +1,6 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { ListView, View, Text, Button, StyleSheet, Platform } = require('react-native'); const { ListView, View, Text, Button, StyleSheet, Platform } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const { reg } = require('lib/registry.js'); const { reg } = require('lib/registry.js');
const { ScreenHeader } = require('lib/components/screen-header.js'); const { ScreenHeader } = require('lib/components/screen-header.js');
const { time } = require('lib/time-utils'); const { time } = require('lib/time-utils');

View File

@ -2,7 +2,6 @@ const React = require('react'); const Component = React.Component;
const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native'); const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { uuid } = require('lib/uuid.js'); const { uuid } = require('lib/uuid.js');
const { Log } = require('lib/log.js');
const RNFS = require('react-native-fs'); const RNFS = require('react-native-fs');
const Note = require('lib/models/Note.js'); const Note = require('lib/models/Note.js');
const Setting = require('lib/models/Setting.js'); const Setting = require('lib/models/Setting.js');

View File

@ -3,7 +3,6 @@ const { View, Button, Text } = require('react-native');
const { stateUtils } = require('lib/reducer.js'); const { stateUtils } = require('lib/reducer.js');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { reg } = require('lib/registry.js'); const { reg } = require('lib/registry.js');
const { Log } = require('lib/log.js');
const { NoteList } = require('lib/components/note-list.js'); const { NoteList } = require('lib/components/note-list.js');
const Folder = require('lib/models/Folder.js'); const Folder = require('lib/models/Folder.js');
const Tag = require('lib/models/Tag.js'); const Tag = require('lib/models/Tag.js');

View File

@ -2,7 +2,6 @@ const React = require('react'); const Component = React.Component;
const { View } = require('react-native'); const { View } = require('react-native');
const { WebView, Button, Text } = require('react-native'); const { WebView, Button, Text } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const Setting = require('lib/models/Setting.js'); const Setting = require('lib/models/Setting.js');
const { ScreenHeader } = require('lib/components/screen-header.js'); const { ScreenHeader } = require('lib/components/screen-header.js');
const { reg } = require('lib/registry.js'); const { reg } = require('lib/registry.js');
@ -44,8 +43,6 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
const parsedUrl = parseUri(url); const parsedUrl = parseUri(url);
if (!this.authCode_ && parsedUrl && parsedUrl.queryKey && parsedUrl.queryKey.code) { if (!this.authCode_ && parsedUrl && parsedUrl.queryKey && parsedUrl.queryKey.code) {
Log.info('URL: ', url, parsedUrl.queryKey);
this.authCode_ = parsedUrl.queryKey.code this.authCode_ = parsedUrl.queryKey.code
try { try {
@ -60,8 +57,8 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
} }
} }
async webview_error(error) { async webview_error() {
Log.error(error); alert('Could not load page. Please check your connection and try again.');
} }
retryButton_click() { retryButton_click() {
@ -93,7 +90,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
<WebView <WebView
source={source} source={source}
onNavigationStateChange={(o) => { this.webview_load(o); }} onNavigationStateChange={(o) => { this.webview_load(o); }}
onError={(error) => { this.webview_error(error); }} onError={() => { this.webview_error(); }}
/> />
<Button title={_("Refresh")} onPress={() => { this.retryButton_click(); }}></Button> <Button title={_("Refresh")} onPress={() => { this.retryButton_click(); }}></Button>
</View> </View>

View File

@ -2,7 +2,6 @@ const React = require('react'); const Component = React.Component;
const { ListView, StyleSheet, View, Text, Button, FlatList } = require('react-native'); const { ListView, StyleSheet, View, Text, Button, FlatList } = require('react-native');
const Setting = require('lib/models/Setting.js'); const Setting = require('lib/models/Setting.js');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const { reg } = require('lib/registry.js'); const { reg } = require('lib/registry.js');
const { ScreenHeader } = require('lib/components/screen-header.js'); const { ScreenHeader } = require('lib/components/screen-header.js');
const { time } = require('lib/time-utils'); const { time } = require('lib/time-utils');

View File

@ -1,7 +1,6 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { View, Text, StyleSheet } = require('react-native'); const { View, Text, StyleSheet } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const { ScreenHeader } = require('lib/components/screen-header.js'); const { ScreenHeader } = require('lib/components/screen-header.js');
const { ActionButton } = require('lib/components/action-button.js'); const { ActionButton } = require('lib/components/action-button.js');
const { BaseScreenComponent } = require('lib/components/base-screen.js'); const { BaseScreenComponent } = require('lib/components/base-screen.js');

View File

@ -2,7 +2,6 @@ const React = require('react'); const Component = React.Component;
const { TouchableOpacity , Button, Text, Image, StyleSheet, ScrollView, View } = require('react-native'); const { TouchableOpacity , Button, Text, Image, StyleSheet, ScrollView, View } = require('react-native');
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const Icon = require('react-native-vector-icons/Ionicons').default; const Icon = require('react-native-vector-icons/Ionicons').default;
const { Log } = require('lib/log.js');
const Tag = require('lib/models/Tag.js'); const Tag = require('lib/models/Tag.js');
const Note = require('lib/models/Note.js'); const Note = require('lib/models/Note.js');
const Folder = require('lib/models/Folder.js'); const Folder = require('lib/models/Folder.js');

View File

@ -1,6 +1,5 @@
const React = require('react'); const Component = React.Component; const React = require('react'); const Component = React.Component;
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const { Log } = require('lib/log.js');
const SideMenu_ = require('react-native-side-menu').default; const SideMenu_ = require('react-native-side-menu').default;
class SideMenuComponent extends SideMenu_ {}; class SideMenuComponent extends SideMenu_ {};

View File

@ -1,40 +0,0 @@
// Custom wrapper for `console` to allow for custom logging (to file, etc.) if needed.
class Log {
static setLevel(v) {
this.level_ = v;
}
static level() {
return this.level_ === undefined ? Log.LEVEL_DEBUG : this.level_;
}
static debug(...o) {
if (Log.level() > Log.LEVEL_DEBUG) return;
console.info(...o);
}
static info(...o) {
if (Log.level() > Log.LEVEL_INFO) return;
console.info(...o);
}
static warn(...o) {
if (Log.level() > Log.LEVEL_WARN) return;
console.info(...o);
}
static error(...o) {
if (Log.level() > Log.LEVEL_ERROR) return;
console.info(...o);
}
}
Log.LEVEL_DEBUG = 0;
Log.LEVEL_INFO = 10;
Log.LEVEL_WARN = 20;
Log.LEVEL_ERROR = 30;
module.exports = { Log };

View File

@ -1,5 +1,4 @@
const BaseModel = require('lib/BaseModel.js'); const BaseModel = require('lib/BaseModel.js');
const { Log } = require('lib/log.js');
const { promiseChain } = require('lib/promise-utils.js'); const { promiseChain } = require('lib/promise-utils.js');
const { time } = require('lib/time-utils.js'); const { time } = require('lib/time-utils.js');
const Note = require('lib/models/Note.js'); const Note = require('lib/models/Note.js');

View File

@ -1,5 +1,4 @@
const BaseModel = require('lib/BaseModel.js'); const BaseModel = require('lib/BaseModel.js');
const { Log } = require('lib/log.js');
const { sprintf } = require('sprintf-js'); const { sprintf } = require('sprintf-js');
const BaseItem = require('lib/models/BaseItem.js'); const BaseItem = require('lib/models/BaseItem.js');
const Setting = require('lib/models/Setting.js'); const Setting = require('lib/models/Setting.js');

View File

@ -7,7 +7,6 @@
// So there's basically still a one way flux: React => SQLite => Redux => React // So there's basically still a one way flux: React => SQLite => Redux => React
const { AppRegistry } = require('react-native'); const { AppRegistry } = require('react-native');
const { Log } = require('lib/log.js');
const { Root } = require('./root.js'); const { Root } = require('./root.js');
function main() { function main() {

View File

@ -9,7 +9,6 @@ const AlarmServiceDriver = require('lib/services/AlarmServiceDriver');
const Alarm = require('lib/models/Alarm'); const Alarm = require('lib/models/Alarm');
const { createStore, applyMiddleware } = require('redux'); const { createStore, applyMiddleware } = require('redux');
const { shimInit } = require('lib/shim-init-react.js'); const { shimInit } = require('lib/shim-init-react.js');
const { Log } = require('lib/log.js');
const { time } = require('lib/time-utils.js'); const { time } = require('lib/time-utils.js');
const { AppNav } = require('lib/components/app-nav.js'); const { AppNav } = require('lib/components/app-nav.js');
const { Logger } = require('lib/logger.js'); const { Logger } = require('lib/logger.js');