Browse Source

Fix support of old state

master
Eduard Kuzmenko 4 years ago
parent
commit
d5ceab476a
  1. 15
      src/lib/appManagers/appStateManager.ts
  2. 9
      src/pages/pageSignQR.ts

15
src/lib/appManagers/appStateManager.ts

@ -277,19 +277,20 @@ export class AppStateManager extends EventListenerBase<{ @@ -277,19 +277,20 @@ export class AppStateManager extends EventListenerBase<{
//state = this.state = new Proxy(state, getHandler());
// * support old version
if(!state.settings.hasOwnProperty('themes') && state.settings.background) {
const theme = STATE_INIT.settings.themes.find(t => t.name === STATE_INIT.settings.theme);
if(theme) {
state.settings.themes.find(t => t.name === theme.name).background = copy(state.settings.background);
if(!state.settings.hasOwnProperty('theme') && state.settings.hasOwnProperty('nightTheme')) {
state.settings.theme = state.settings.nightTheme ? 'night' : 'day';
this.pushToState('settings', state.settings);
}
}
// * support old version
if(!state.settings.hasOwnProperty('theme') && state.settings.hasOwnProperty('nightTheme')) {
state.settings.theme = state.settings.nightTheme ? 'night' : 'day';
if(!state.settings.hasOwnProperty('themes') && state.settings.background) {
state.settings.themes = copy(STATE_INIT.settings.themes);
const theme = state.settings.themes.find(t => t.name === state.settings.theme);
if(theme) {
theme.background = state.settings.background;
this.pushToState('settings', state.settings);
}
}
validateInitObject(STATE_INIT, state, (missingKey) => {
// @ts-ignore

9
src/pages/pageSignQR.ts

@ -6,9 +6,6 @@ @@ -6,9 +6,6 @@
import apiManager from '../lib/mtproto/mtprotoworker';
import Page from './page';
import pageIm from './pageIm';
import pagePassword from './pagePassword';
import pageSignIn from './pageSignIn';
import serverTimeManager from '../lib/mtproto/serverTimeManager';
import { AuthAuthorization, AuthLoginToken } from '../layer';
import { bytesCmp, bytesToBase64 } from '../helpers/bytes';
@ -48,7 +45,7 @@ let onFirstMount = async() => { @@ -48,7 +45,7 @@ let onFirstMount = async() => {
container.append(h4, helpList, inputWrapper);
btnBack.addEventListener('click', () => {
pageSignIn.mount();
import('./pageSignIn').then(m => m.default.mount());
stop = true;
});
@ -89,7 +86,7 @@ let onFirstMount = async() => { @@ -89,7 +86,7 @@ let onFirstMount = async() => {
if(loginToken._ === 'auth.loginTokenSuccess') {
const authorization = loginToken.authorization as any as AuthAuthorization.authAuthorization;
apiManager.setUserAuth(authorization.user.id);
pageIm.mount();
import('./pageIm').then(m => m.default.mount());
return true;
}
@ -201,7 +198,7 @@ let onFirstMount = async() => { @@ -201,7 +198,7 @@ let onFirstMount = async() => {
case 'SESSION_PASSWORD_NEEDED':
console.warn('pageSignQR: SESSION_PASSWORD_NEEDED');
err.handled = true;
pagePassword.mount();
import('./pagePassword').then(m => m.default.mount());
stop = true;
cachedPromise = null;
break;

Loading…
Cancel
Save