2020-08-02 13:28:50 +02:00
|
|
|
import * as React from 'react';
|
2020-11-07 17:59:37 +02:00
|
|
|
import useSyncTargetUpgrade from '@joplin/lib/services/synchronizer/gui/useSyncTargetUpgrade';
|
|
|
|
import { _ } from '@joplin/lib/locale';
|
2020-09-15 15:01:07 +02:00
|
|
|
const { View, Text, ScrollView } = require('react-native');
|
2020-08-02 13:28:50 +02:00
|
|
|
|
|
|
|
const { connect } = require('react-redux');
|
2024-03-09 13:15:13 +02:00
|
|
|
import { themeStyle } from '../global-style';
|
2022-08-27 14:36:59 +02:00
|
|
|
import ScreenHeader from '../ScreenHeader';
|
2020-08-02 13:28:50 +02:00
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2020-11-12 21:13:28 +02:00
|
|
|
function UpgradeSyncTargetScreen(props: any) {
|
2020-08-02 13:28:50 +02:00
|
|
|
const upgradeResult = useSyncTargetUpgrade();
|
|
|
|
|
2020-09-15 15:01:07 +02:00
|
|
|
const theme = themeStyle(props.themeId);
|
2020-08-02 13:28:50 +02:00
|
|
|
|
|
|
|
const lineStyle = { ...theme.normalText, marginBottom: 20 };
|
|
|
|
const stackTraceStyle = { ...theme.normalText, flexWrap: 'nowrap', fontSize: theme.fontSize * 0.5, color: theme.colorFaded };
|
|
|
|
const headerStyle = { ...theme.headerStyle, marginBottom: 20 };
|
|
|
|
|
|
|
|
function renderUpgradeError() {
|
|
|
|
if (!upgradeResult.error) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={{ backgroundColor: theme.backgroundColor, flex: 1, flexDirection: 'column' }}>
|
|
|
|
<Text style={headerStyle}>Error</Text>
|
|
|
|
<Text style={lineStyle}>The sync target could not be upgraded due to an error. For support, please copy the content of this page and paste it in the forum: https://discourse.joplinapp.org/</Text>
|
|
|
|
<Text style={lineStyle}>The full error was:</Text>
|
|
|
|
<Text style={lineStyle}>{upgradeResult.error.message}</Text>
|
|
|
|
<Text style={stackTraceStyle}>{upgradeResult.error.stack}</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderInProgress() {
|
|
|
|
if (upgradeResult.error || upgradeResult.done) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<Text style={headerStyle}>Joplin upgrade in progress...</Text>
|
|
|
|
<Text style={lineStyle}>Please wait while the sync target is being upgraded. It may take a few seconds or a few minutes depending on the upgrade.</Text>
|
|
|
|
<Text style={lineStyle}>Make sure you leave your device on and the app opened while the upgrade is in progress.</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderDone() {
|
|
|
|
if (upgradeResult.error || !upgradeResult.done) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<Text style={headerStyle}>Upgrade complete</Text>
|
|
|
|
<Text style={lineStyle}>The upgrade has been applied successfully. Please press Back to exit this screen.</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ScrollView style={{ flex: 1, flexDirection: 'column', backgroundColor: theme.backgroundColor }}>
|
2024-09-24 16:12:02 +02:00
|
|
|
<ScreenHeader title={_('Sync Target Upgrade')} showShouldUpgradeSyncTargetMessage={false} showSearchButton={false} showBackButton={upgradeResult.done}/>
|
2020-08-02 13:28:50 +02:00
|
|
|
<View style={{ padding: 15, flex: 1 }}>
|
|
|
|
{renderInProgress()}
|
|
|
|
{renderDone()}
|
|
|
|
{renderUpgradeError()}
|
|
|
|
</View>
|
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2020-11-12 21:13:28 +02:00
|
|
|
export default connect((state: any) => {
|
2020-08-02 13:28:50 +02:00
|
|
|
return {
|
2020-09-15 15:01:07 +02:00
|
|
|
themeId: state.settings.theme,
|
2020-08-02 13:28:50 +02:00
|
|
|
};
|
|
|
|
})(UpgradeSyncTargetScreen);
|