Skip to content

Commit

Permalink
Chore remove file migration dialogs (#399)
Browse files Browse the repository at this point in the history
* chore: removed file migration dialogs [branch ch17681]

* chore: remove unused

* chore: updated icebear branch

* chore: revert to icebear dev
  • Loading branch information
Karim94 authored and seavan committed Dec 11, 2018
1 parent 10a4e50 commit 5fc3ed5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 109 deletions.
35 changes: 1 addition & 34 deletions app/components/routes/router-main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { observable, reaction, action, when, extendObservable } from 'mobx';
import RNKeepAwake from 'react-native-keep-awake';
import { observable, reaction, action, extendObservable } from 'mobx';
import Router from './router';
import uiState from '../layout/ui-state';
import WelcomeZeroState from '../layout/welcome-zero-state';
Expand All @@ -26,11 +25,7 @@ import {
} from '../states';
// import { enablePushNotifications } from '../../lib/push';
import routes from './routes';
import snackbarState from '../snackbars/snackbar-state';
import { tx } from '../utils/translator';
import popupState from '../layout/popup-state';
import { fileStore } from '../../lib/icebear';
import { popupUpgradeNotification, popupUpgradeProgress } from '../shared/popups';
import preferenceStore from '../settings/preference-store';
import whiteLabelComponents from '../../components/whitelabel/white-label-components';
import { timeoutWithAction } from '../utils/timeouts';
Expand Down Expand Up @@ -87,14 +82,6 @@ class RouterMain extends Router {
this.add('accountUpgradeMonthly', [<AccountUpgradeMonthly />], accountUpgradeState);
this.add('accountUpgradeAnnual', [<AccountUpgradeAnnual />], accountUpgradeState);

reaction(
() => fileStore.migration.pending,
migration => {
if (migration) this.filesystemUpgrade();
},
{ fireImmediately: true }
);

reaction(
() => this.current || this.currentIndex,
() => {
Expand Down Expand Up @@ -141,26 +128,6 @@ class RouterMain extends Router {
if (whiteLabelComponents.extendRoutes) whiteLabelComponents.extendRoutes(this);
}

@action
async filesystemUpgrade() {
if (fileStore.migration.pending) {
if (!(fileStore.migration.started || fileStore.migration.performedByAnotherClient)) {
await popupUpgradeNotification();
fileStore.migration.confirmMigration();
}
popupUpgradeProgress();
when(
() => !fileStore.migration.pending,
() => {
popupState.discardPopup();
snackbarState.pushTemporary(tx('title_fileUpdateComplete'));
RNKeepAwake.deactivate();
}
);
RNKeepAwake.activate();
}
}

add(key, components, routeState) {
const route = super.add(key, null);
extendObservable(route, { components }, { components: observable.ref });
Expand Down
76 changes: 1 addition & 75 deletions app/components/shared/popups.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from 'react';
import RNFS from 'react-native-fs';
import FileOpener from 'react-native-file-opener';
import { WebView, Image, View, Platform } from 'react-native';
import { observable } from 'mobx';
import Text from '../controls/custom-text';
Expand All @@ -10,28 +8,14 @@ import popupState from '../layout/popup-state';
import locales from '../../lib/locales';
import CheckBox from './checkbox';
import { vars } from '../../styles/styles';
import { fileStore, User, config, telemetry } from '../../lib/icebear';
import { User, config, telemetry } from '../../lib/icebear';
import testLabel from '../helpers/test-label';
import FilePreview from '../files/file-preview';
import PopupMigration from '../controls/popup-migration';
import TwoFactorAuthPrompt from '../settings/two-factor-auth-prompt';
import tm from '../../telemetry';

const { S } = telemetry;

const titleStyle = {
color: vars.lighterBlackText,
fontSize: vars.font.size20
};
const textStyle = {
color: vars.lighterBlackText,
fontSize: vars.font.size14
};
const textDownloadStyle = {
textDecorationLine: 'underline',
color: vars.linkColor
};

function textControl(str, style) {
const text = {
color: '#000000AA',
Expand Down Expand Up @@ -610,62 +594,6 @@ function popupMoveToSharedFolder() {
});
}

function popupUpgradeNotification() {
return new Promise(resolve => {
const viewFileMigrationList = async () => {
const directory =
Platform.OS === 'ios' ? RNFS.CachesDirectoryPath : RNFS.ExternalDirectoryPath;
const path = `${directory}/${User.current.username}-Peerio-shared-files-list.txt`;
const content = await fileStore.migration.getLegacySharedFilesText();
RNFS.writeFile(path, content, 'utf8')
.then(() => FileOpener.open(path, 'text/*', path))
.catch(err => console.log(err.message));
};
const download = text => {
return (
<Text
style={textDownloadStyle}
onPress={viewFileMigrationList}
pressRetentionOffset={vars.retentionOffset}>
{text}
</Text>
);
};
const resolveButtonText = fileStore.hasLegacySharedFiles ? 'update' : 'ok';
popupState.showPopup({
type: 'systemUpgrade',
title: textControl(tx('title_upgradeFileSystem'), titleStyle),
contents: (
<View>
{textControl(tx('title_upgradeFileSystemDescription1'), textStyle)}
{textControl(tx('title_upgradeFileSystemDescription2'), textStyle)}
{fileStore.migration.hasLegacySharedFiles
? textControl(
tx('title_upgradeFileSystemDescription3', { download }),
textStyle
)
: null}
</View>
),
buttons: [
{
id: resolveButtonText,
text: tu(`button_${resolveButtonText}`),
action: () => resolve(true)
}
]
});
});
}

function popupUpgradeProgress() {
return popupState.showPopup({
type: 'systemUpgrade',
title: textControl(tx('title_fileUpdateProgress'), titleStyle),
contents: <PopupMigration />
});
}

locales.loadAssetFile('terms.txt').then(s => {
tos = s;
});
Expand Down Expand Up @@ -698,8 +626,6 @@ export {
popupSignOutAutologin,
popupCancelConfirm,
popupSetupVideo,
popupUpgradeNotification,
popupUpgradeProgress,
popupFileRename,
popupFolderDelete,
popupMoveToSharedFolder,
Expand Down

0 comments on commit 5fc3ed5

Please sign in to comment.