Changed auth fetching flow

Added switches for another versions
This commit is contained in:
Eduard Kuzmenko 2021-06-08 18:46:55 +03:00
parent c98b6828ee
commit 9ba450a8b6
6 changed files with 58 additions and 25 deletions

View File

@ -52,7 +52,7 @@ export class AppSidebarLeft extends SidebarSlider {
//private log = logger('SL');
private searchGroups: {[k in 'contacts' | 'globalContacts' | 'messages' | 'people' | 'recent']: SearchGroup} = {} as any;
searchSuper: AppSearchSuper;
private searchSuper: AppSearchSuper;
constructor() {
super({
@ -167,6 +167,20 @@ export class AppSidebarLeft extends SidebarSlider {
a.remove();
}, 0);
}
}, {
icon: 'char z',
text: 'ChatList.Menu.SwitchTo.Z',
onClick: () => {
location.href = 'https://web.telegram.org/z/';
},
verify: () => location.hostname === 'web.telegram.org'
}, {
icon: 'char w',
text: 'ChatList.Menu.SwitchTo.Webogram',
onClick: () => {
location.href = 'https://web.telegram.org/';
},
verify: () => location.hostname === 'web.telegram.org'
}];
this.toolsBtn = ButtonMenuToggle({}, 'bottom-right', menuButtons, (e) => {

View File

@ -13,7 +13,7 @@ const App = {
id: 1025907,
hash: '452b0359b988148995f22ff0f4229750',
version: '0.5.6',
langPackVersion: '0.1.9',
langPackVersion: '0.2.0',
langPack: 'macos',
langPackCode: 'en',
domains: [] as string[],

View File

@ -25,7 +25,6 @@ const lang = {
"EditProfile.Username.Invalid": "Username is invalid",
"EditProfile.Username.Help": "You can choose a username on Telegram. If you do, people will be able to find you by this username and contact you without needing your phone number.\n\nYou can use az, 09 and underscores. Minimum length is 5 characters.",
"ExceptionModal.Search.Placeholder": "Add exception...",
//"ChatList.Menu.Archived": "Archived",
"Chat.Menu.SelectMessages": "Select Messages",
"Chat.Menu.ClearSelection": "Clear Selection",
"Chat.Input.UnpinAll": "Unpin All Messages",
@ -43,6 +42,9 @@ const lang = {
},
"Chat.Search.NoMessagesFound": "No messages found",
"Chat.Search.PrivateSearch": "Private Search",
//"ChatList.Menu.Archived": "Archived",
"ChatList.Menu.SwitchTo.Webogram": "Switch to Webogram",
"ChatList.Menu.SwitchTo.Z": "Switch to Z version",
"ConnectionStatus.ReconnectIn": "Reconnect in %ds, %s",
"ConnectionStatus.Reconnect": "reconnect",
"ConnectionStatus.Waiting": "Waiting for network...",

View File

@ -252,6 +252,27 @@ export class AppStateManager extends EventListenerBase<{
// * Read auth
let auth = arr.shift() as UserAuth | number;
let shiftedWebKAuth = arr.shift() as UserAuth | number;
if(!auth && shiftedWebKAuth) { // support old webk auth
auth = shiftedWebKAuth;
const keys: string[] = ['dc', 'server_time_offset', 'xt_instance'];
for(let i = 1; i <= 5; ++i) {
keys.push(`dc${i}_server_salt`);
keys.push(`dc${i}_auth_key`);
}
const values = await Promise.all(keys.map(key => stateStorage.get(key as any)));
keys.push('user_auth');
values.push(typeof(auth) === 'number' ? {dcID: values[0] || App.baseDcId, id: auth} : auth);
let obj: any = {};
keys.forEach((key, idx) => {
obj[key] = values[idx];
});
await sessionStorage.set(obj);
}
if(!auth) { // try to read Webogram's session from localStorage
try {
const keys = Object.keys(localStorage);
@ -276,27 +297,6 @@ export class AppStateManager extends EventListenerBase<{
}
}
let shiftedWebKAuth = arr.shift() as UserAuth | number;
if(!auth && shiftedWebKAuth) { // support old webk auth
auth = shiftedWebKAuth;
const keys: string[] = ['dc', 'server_time_offset', 'xt_instance'];
for(let i = 1; i <= 5; ++i) {
keys.push(`dc${i}_server_salt`);
keys.push(`dc${i}_auth_key`);
}
const values = await Promise.all(keys.map(key => stateStorage.get(key as any)));
keys.push('user_auth');
values.push(typeof(auth) === 'number' ? {dcID: values[0] || App.baseDcId, id: auth} : auth);
let obj: any = {};
keys.forEach((key, idx) => {
obj[key] = values[idx];
});
await sessionStorage.set(obj);
}
if(auth) {
// ! Warning ! DON'T delete this
state.authState = {_: 'authStateSignedIn'};

View File

@ -24,7 +24,7 @@
.tgico:after,
[class*=" tgico-"]:before,
[class*=" tgico-"]:after {
font-family: "#{$tgico-font-family}" !important;
font-family: "#{$tgico-font-family}";
speak: never;
font-style: normal;
font-weight: normal;

View File

@ -1322,3 +1322,20 @@ middle-ellipsis-element {
@include hover-background-effect();
}
}
.tgico-char {
&:before {
font-family: "Roboto" !important;
font-weight: 500;
width: 1.5rem;
text-align: center;
}
&.z:before {
content: "Z";
}
&.w:before {
content: "W";
}
}