mirror of https://github.com/BTCPrivate/copay.git
Fix: Return to onboarding page if the process of creating or importing wallet has not been completed
This commit is contained in:
parent
65a9d6bc5f
commit
f3f65f4419
|
@ -104,9 +104,9 @@ export class CopayApp {
|
|||
this.profile.createProfile();
|
||||
this.rootPage = OnboardingPage;
|
||||
}
|
||||
}).catch((err: any) => {
|
||||
}).catch((err: Error) => {
|
||||
this.logger.warn(err);
|
||||
this.rootPage = DisclaimerPage;
|
||||
this.rootPage = err.message == 'ONBOARDINGNONCOMPLETED: Onboarding non completed' ? OnboardingPage : DisclaimerPage;
|
||||
});
|
||||
}).catch((err) => {
|
||||
this.logger.error('Could not initialize the app');
|
||||
|
|
|
@ -4,6 +4,7 @@ export class Profile {
|
|||
public createdOn: number;
|
||||
public credentials: any[];
|
||||
public disclaimerAccepted: boolean;
|
||||
public onboardingCompleted: boolean;
|
||||
public checked: any;
|
||||
public checkedUA?: any;
|
||||
public dirty: boolean;
|
||||
|
@ -18,6 +19,7 @@ export class Profile {
|
|||
x.createdOn = Date.now();
|
||||
x.credentials = opts.credentials || [];
|
||||
x.disclaimerAccepted = false;
|
||||
x.onboardingCompleted = false;
|
||||
x.checked = {};
|
||||
return x;
|
||||
};
|
||||
|
@ -28,6 +30,7 @@ export class Profile {
|
|||
x.createdOn = obj.createdOn;
|
||||
x.credentials = obj.credentials;
|
||||
x.disclaimerAccepted = obj.disclaimerAccepted;
|
||||
x.onboardingCompleted = obj.onboardingCompleted;
|
||||
x.checked = obj.checked || {};
|
||||
x.checkedUA = obj.checkedUA || {};
|
||||
|
||||
|
|
|
@ -206,9 +206,14 @@ export class ImportWalletPage {
|
|||
this.profileProvider.setBackupFlag(wallet.credentials.walletId);
|
||||
this.events.publish('status:updated');
|
||||
if (this.fromOnboarding) {
|
||||
this.profileProvider.setDisclaimerAccepted().catch((err: any) => {
|
||||
this.profileProvider.setOnboardingCompleted().then(() => {
|
||||
this.profileProvider.setDisclaimerAccepted().catch((err: any) => {
|
||||
this.logger.error(err);
|
||||
});
|
||||
}).catch((err: any) => {
|
||||
this.logger.error(err);
|
||||
});
|
||||
|
||||
this.navCtrl.setRoot(TabsPage);
|
||||
this.navCtrl.popToRoot();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||
import { AlertController, NavController, NavParams } from 'ionic-angular';
|
||||
import { Logger } from '../../../providers/logger/logger';
|
||||
|
||||
// Pages
|
||||
import { BackupWarningPage } from '../../backup/backup-warning/backup-warning';
|
||||
import { DisclaimerPage } from '../disclaimer/disclaimer';
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { CollectEmailPage } from '../collect-email/collect-email';
|
|||
|
||||
// providers
|
||||
import { OnGoingProcessProvider } from '../../../providers/on-going-process/on-going-process';
|
||||
import { PersistenceProvider } from '../../../providers/persistence/persistence';
|
||||
import { ProfileProvider } from '../../../providers/profile/profile';
|
||||
import { RateProvider } from '../../../providers/rate/rate';
|
||||
import { TxFormatProvider } from '../../../providers/tx-format/tx-format';
|
||||
|
@ -30,7 +31,8 @@ export class TourPage {
|
|||
private profileProvider: ProfileProvider,
|
||||
private rateProvider: RateProvider,
|
||||
private txFormatProvider: TxFormatProvider,
|
||||
private onGoingProcessProvider: OnGoingProcessProvider
|
||||
private onGoingProcessProvider: OnGoingProcessProvider,
|
||||
private persistenceProvider: PersistenceProvider
|
||||
) {
|
||||
this.currentIndex = 0;
|
||||
this.rateProvider.whenRatesAvailable().then(() => {
|
||||
|
@ -69,6 +71,7 @@ export class TourPage {
|
|||
this.onGoingProcessProvider.set('creatingWallet');
|
||||
this.profileProvider.createDefaultWallet().then((wallet) => {
|
||||
this.onGoingProcessProvider.clear();
|
||||
this.persistenceProvider.setOnboardingCompleted();
|
||||
this.navCtrl.push(CollectEmailPage, { walletId: wallet.id });
|
||||
})
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ const Keys = {
|
|||
LAST_ADDRESS: walletId => 'lastAddress-' + walletId,
|
||||
LAST_CURRENCY_USED: 'lastCurrencyUsed',
|
||||
MERCADO_LIBRE: network => 'MercadoLibreGiftCards-' + network,
|
||||
ONBOARDING_COMPLETED: 'onboardingCompleted',
|
||||
PROFILE: 'profile',
|
||||
REMOTE_PREF_STORED: 'remotePrefStored',
|
||||
TX_CONFIRM_NOTIF: txid => 'txConfirmNotif-' + txid,
|
||||
|
@ -167,11 +168,19 @@ export class PersistenceProvider {
|
|||
return this.storage.set(Keys.AGREE_DISCLAIMER, true);
|
||||
}
|
||||
|
||||
setOnboardingCompleted(): Promise<any> {
|
||||
return this.storage.set(Keys.ONBOARDING_COMPLETED, true);
|
||||
}
|
||||
|
||||
// for compatibility
|
||||
getCopayDisclaimerFlag(): Promise<any> {
|
||||
return this.storage.get(Keys.AGREE_DISCLAIMER);
|
||||
};
|
||||
|
||||
getCopayOnboardingFlag(): Promise<any> {
|
||||
return this.storage.get(Keys.ONBOARDING_COMPLETED);
|
||||
};
|
||||
|
||||
setRemotePrefsStoredFlag(): Promise<void> {
|
||||
return this.storage.set(Keys.REMOTE_PREF_STORED, true);
|
||||
};
|
||||
|
|
|
@ -632,11 +632,22 @@ export class ProfileProvider {
|
|||
};
|
||||
|
||||
bindWallets().then(() => {
|
||||
this.isDisclaimerAccepted().then(() => {
|
||||
return resolve();
|
||||
this.isOnboardingCompleted().then(() => {
|
||||
this.isDisclaimerAccepted().then(() => {
|
||||
return resolve();
|
||||
}).catch(() => {
|
||||
return reject(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
});
|
||||
}).catch(() => {
|
||||
this.persistenceProvider.setHomeTipAccepted('accepted');
|
||||
return reject(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
this.isDisclaimerAccepted().then(() => {
|
||||
this.setOnboardingCompleted().then(() => {
|
||||
return resolve();
|
||||
}).catch((err: any) => {
|
||||
this.logger.error(err);
|
||||
});
|
||||
}).catch(() => {
|
||||
return reject(new Error('ONBOARDINGNONCOMPLETED: Onboarding non completed'));
|
||||
});
|
||||
});
|
||||
}).catch((err: any) => {
|
||||
return reject(err);
|
||||
|
@ -662,6 +673,23 @@ export class ProfileProvider {
|
|||
});
|
||||
}
|
||||
|
||||
public isOnboardingCompleted(): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let onboardingCompleted = this.profile && this.profile.onboardingCompleted;
|
||||
if (onboardingCompleted) return resolve();
|
||||
|
||||
this.persistenceProvider.getCopayOnboardingFlag().then((val) => {
|
||||
if (val) {
|
||||
this.profile.onboardingCompleted = true;
|
||||
return resolve();
|
||||
} else {
|
||||
return reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private bindWallet(credentials: any): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -933,6 +961,17 @@ export class ProfileProvider {
|
|||
});
|
||||
}
|
||||
|
||||
public setOnboardingCompleted(): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.profile.onboardingCompleted = true;
|
||||
this.persistenceProvider.storeProfile(this.profile).then(() => {
|
||||
return resolve();
|
||||
}).catch((err) => {
|
||||
return reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public getWallets(opts?: any) {
|
||||
|
||||
if (opts && !_.isObject(opts)) throw new Error("bad argument");
|
||||
|
|
Loading…
Reference in New Issue