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<{
//state = this.state = new Proxy(state, getHandler()); //state = this.state = new Proxy(state, getHandler());
// * support old version // * support old version
if(!state.settings.hasOwnProperty('themes') && state.settings.background) { if(!state.settings.hasOwnProperty('theme') && state.settings.hasOwnProperty('nightTheme')) {
const theme = STATE_INIT.settings.themes.find(t => t.name === STATE_INIT.settings.theme); state.settings.theme = state.settings.nightTheme ? 'night' : 'day';
if(theme) {
state.settings.themes.find(t => t.name === theme.name).background = copy(state.settings.background);
this.pushToState('settings', state.settings); this.pushToState('settings', state.settings);
} }
}
// * support old version // * support old version
if(!state.settings.hasOwnProperty('theme') && state.settings.hasOwnProperty('nightTheme')) { if(!state.settings.hasOwnProperty('themes') && state.settings.background) {
state.settings.theme = state.settings.nightTheme ? 'night' : 'day'; 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); this.pushToState('settings', state.settings);
} }
}
validateInitObject(STATE_INIT, state, (missingKey) => { validateInitObject(STATE_INIT, state, (missingKey) => {
// @ts-ignore // @ts-ignore

9
src/pages/pageSignQR.ts

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

Loading…
Cancel
Save