((props, ref: any)
return;
};
+ if (code == J.Error.Code.ACCOUNT_STORE_NOT_MIGRATED) {
+ U.Router.go('/auth/migrate', {});
+ return;
+ };
+
setError(text);
phraseRef.current?.setError(true);
submitRef.current?.setLoading(false);
diff --git a/src/ts/component/page/auth/migrate.tsx b/src/ts/component/page/auth/migrate.tsx
new file mode 100644
index 0000000000..33840658c2
--- /dev/null
+++ b/src/ts/component/page/auth/migrate.tsx
@@ -0,0 +1,68 @@
+import React, { forwardRef, useEffect, useState } from 'react';
+import { observer } from 'mobx-react';
+import { Frame, Error, ProgressBar } from 'Component';
+import { I, C, S, U, Animation, Storage } from 'Lib';
+
+const PageAuthMigrate = observer(forwardRef<{}, I.PageComponent>((props, ref) => {
+
+ const { dataPath } = S.Common;
+ const accountId = Storage.get('accountId');
+ const spaceId = Storage.get('spaceId');
+ const [ error, setError ] = useState('');
+ const { networkConfig } = S.Auth;
+ const { mode, path } = networkConfig;
+ const types = [ I.ProgressType.Migrate ];
+ const list = S.Progress.getList(it => types.includes(it.type));
+ const progress = list.length ? list[0] : null;
+ const segments = [];
+
+ if (progress) {
+ segments.push({ name: 'migrate', caption: 'Migrate', percent: progress.current / progress.total, isActive: true });
+ };
+
+ useEffect(() => {
+ S.Auth.clearAll();
+
+ Animation.to(() => {
+ C.AccountMigrate(accountId, dataPath, (message: any) => {
+ if (message.error.code) {
+ setError(message.error.description);
+ return;
+ };
+
+ C.AccountSelect(accountId, dataPath, mode, path, (message: any) => {
+ const { account } = message;
+
+ if (!account) {
+ return;
+ };
+
+ S.Auth.accountSet(account);
+ S.Common.configSet(account.config, false);
+
+ const routeParam = { replace: true };
+
+ if (spaceId) {
+ U.Router.switchSpace(spaceId, '', false, routeParam);
+ } else {
+ U.Data.onAuthWithoutSpace(routeParam);
+ };
+
+ U.Data.onInfo(account.info);
+ U.Data.onAuthOnce(false);
+ });
+
+ });
+ });
+ }, []);
+
+ return (
+
+
+
+
+ );
+
+}));
+
+export default PageAuthMigrate;
\ No newline at end of file
diff --git a/src/ts/component/page/auth/setup.tsx b/src/ts/component/page/auth/setup.tsx
index d9f3795b87..800526c320 100644
--- a/src/ts/component/page/auth/setup.tsx
+++ b/src/ts/component/page/auth/setup.tsx
@@ -85,6 +85,11 @@ const PageAuthSetup = observer(forwardRef<{}, I.PageComponent>((props, ref) => {
return false;
};
+ if (error.code == J.Error.Code.ACCOUNT_STORE_NOT_MIGRATED) {
+ U.Router.go('/auth/migrate', {});
+ return;
+ };
+
setError(error);
return U.Common.checkErrorCommon(error.code);
};
diff --git a/src/ts/component/page/index.tsx b/src/ts/component/page/index.tsx
index 49edce50c0..89ab32ff28 100644
--- a/src/ts/component/page/index.tsx
+++ b/src/ts/component/page/index.tsx
@@ -11,6 +11,7 @@ import PageAuthPinCheck from './auth/pinCheck';
import PageAuthSetup from './auth/setup';
import PageAuthOnboard from './auth/onboard';
import PageAuthDeleted from './auth/deleted';
+import PageAuthMigrate from './auth/migrate';
import PageMainBlank from './main/blank';
import PageMainEmpty from './main/empty';
@@ -41,6 +42,7 @@ const Components = {
'auth/setup': PageAuthSetup,
'auth/onboard': PageAuthOnboard,
'auth/deleted': PageAuthDeleted,
+ 'auth/migrate': PageAuthMigrate,
'main/blank': PageMainBlank,
'main/empty': PageMainEmpty,
diff --git a/src/ts/component/util/progress.tsx b/src/ts/component/util/progress.tsx
index 5b651971c4..58b9759497 100644
--- a/src/ts/component/util/progress.tsx
+++ b/src/ts/component/util/progress.tsx
@@ -7,8 +7,9 @@ import { I, S, U, C, J, Storage, keyboard, translate } from 'Lib';
const Progress: FC = observer(() => {
const { show } = S.Progress;
- const list = S.Progress.getList();
- const percent = S.Progress.getPercent();
+ const skipType = [ I.ProgressType.Migrate ];
+ const list = S.Progress.getList(it => !skipType.includes(it.type));
+ const percent = S.Progress.getPercent(list);
const nodeRef = useRef(null);
const innerRef = useRef(null);
const dx = useRef(0);
diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts
index c2cad4cf22..d62c12c0ef 100644
--- a/src/ts/lib/api/command.ts
+++ b/src/ts/lib/api/command.ts
@@ -195,6 +195,15 @@ export const AccountSelect = (id: string, path: string, mode: I.NetworkMode, net
dispatcher.request(AccountSelect.name, request, callBack);
};
+export const AccountMigrate = (id: string, path: string, callBack?: (message: any) => void) => {
+ const request = new Rpc.Account.Migrate.Request();
+
+ request.setId(id);
+ request.setRootpath(path);
+
+ dispatcher.request(AccountMigrate.name, request, callBack);
+};
+
export const AccountStop = (removeData: boolean, callBack?: (message: any) => void) => {
const request = new Rpc.Account.Stop.Request();
diff --git a/src/ts/store/progress.ts b/src/ts/store/progress.ts
index 4416ffc197..d71ef7dd93 100644
--- a/src/ts/store/progress.ts
+++ b/src/ts/store/progress.ts
@@ -49,32 +49,28 @@ class ProgressStore {
this.showValue = Boolean(v);
};
- getList () {
+ getList (filter?: (it: I.Progress) => boolean) {
const { space } = S.Common;
- const skip = [ I.ProgressState.Done, I.ProgressState.Canceled ];
+ const skipState = [ I.ProgressState.Done, I.ProgressState.Canceled ];
- return this.list.filter(it => (!it.spaceId || (it.spaceId == space)) && !skip.includes(it.state));
+ return this.list.filter(it => {
+ let ret = true;
+
+ if (filter) {
+ ret = filter(it);
+ };
+
+ return ret && (!it.spaceId || (it.spaceId == space)) && !skipState.includes(it.state);
+ });
};
getItem (id: string): I.Progress {
return this.getList().find(it => it.id == id);
};
- getField (field: string): number {
- return this.getList().reduce((acc, it) => acc + (Number(it[field]) || 0), 0);
- };
-
- getCurrent (): number {
- return this.getField('current');
- };
-
- getTotal (): number {
- return this.getField('total');
- };
-
- getPercent (): number {
- const current = this.getCurrent();
- const total = this.getTotal();
+ getPercent (list: I.Progress[]): number {
+ const current = list.reduce((acc, it) => acc + (Number(it.current) || 0), 0);
+ const total = list.reduce((acc, it) => acc + (Number(it.total) || 0), 0);
return total > 0 ? Math.min(100, Math.ceil(current / total * 100)) : 0;
};