Browse Source

Changed auth fetching flow

Added switches for another versions
master
Eduard Kuzmenko 3 years ago
parent
commit
9ba450a8b6
  1. 16
      src/components/sidebarLeft/index.ts
  2. 2
      src/config/app.ts
  3. 4
      src/lang.ts
  4. 42
      src/lib/appManagers/appStateManager.ts
  5. 2
      src/scss/partials/_fonts.scss
  6. 17
      src/scss/style.scss

16
src/components/sidebarLeft/index.ts

@ -52,7 +52,7 @@ export class AppSidebarLeft extends SidebarSlider {
//private log = logger('SL'); //private log = logger('SL');
private searchGroups: {[k in 'contacts' | 'globalContacts' | 'messages' | 'people' | 'recent']: SearchGroup} = {} as any; private searchGroups: {[k in 'contacts' | 'globalContacts' | 'messages' | 'people' | 'recent']: SearchGroup} = {} as any;
searchSuper: AppSearchSuper; private searchSuper: AppSearchSuper;
constructor() { constructor() {
super({ super({
@ -167,6 +167,20 @@ export class AppSidebarLeft extends SidebarSlider {
a.remove(); a.remove();
}, 0); }, 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) => { this.toolsBtn = ButtonMenuToggle({}, 'bottom-right', menuButtons, (e) => {

2
src/config/app.ts

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

4
src/lang.ts

@ -25,7 +25,6 @@ const lang = {
"EditProfile.Username.Invalid": "Username is invalid", "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 a–z, 0–9 and underscores. Minimum length is 5 characters.", "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 a–z, 0–9 and underscores. Minimum length is 5 characters.",
"ExceptionModal.Search.Placeholder": "Add exception...", "ExceptionModal.Search.Placeholder": "Add exception...",
//"ChatList.Menu.Archived": "Archived",
"Chat.Menu.SelectMessages": "Select Messages", "Chat.Menu.SelectMessages": "Select Messages",
"Chat.Menu.ClearSelection": "Clear Selection", "Chat.Menu.ClearSelection": "Clear Selection",
"Chat.Input.UnpinAll": "Unpin All Messages", "Chat.Input.UnpinAll": "Unpin All Messages",
@ -43,6 +42,9 @@ const lang = {
}, },
"Chat.Search.NoMessagesFound": "No messages found", "Chat.Search.NoMessagesFound": "No messages found",
"Chat.Search.PrivateSearch": "Private Search", "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.ReconnectIn": "Reconnect in %ds, %s",
"ConnectionStatus.Reconnect": "reconnect", "ConnectionStatus.Reconnect": "reconnect",
"ConnectionStatus.Waiting": "Waiting for network...", "ConnectionStatus.Waiting": "Waiting for network...",

42
src/lib/appManagers/appStateManager.ts

@ -252,6 +252,27 @@ export class AppStateManager extends EventListenerBase<{
// * Read auth // * Read auth
let auth = arr.shift() as UserAuth | number; 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 if(!auth) { // try to read Webogram's session from localStorage
try { try {
const keys = Object.keys(localStorage); 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) { if(auth) {
// ! Warning ! DON'T delete this // ! Warning ! DON'T delete this
state.authState = {_: 'authStateSignedIn'}; state.authState = {_: 'authStateSignedIn'};

2
src/scss/partials/_fonts.scss

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

17
src/scss/style.scss

@ -1322,3 +1322,20 @@ middle-ellipsis-element {
@include hover-background-effect(); @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";
}
}

Loading…
Cancel
Save