From 9ba450a8b612764912d06518aebdfd78bd6692c5 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Tue, 8 Jun 2021 18:46:55 +0300 Subject: [PATCH] Changed auth fetching flow Added switches for another versions --- src/components/sidebarLeft/index.ts | 16 +++++++++- src/config/app.ts | 2 +- src/lang.ts | 4 ++- src/lib/appManagers/appStateManager.ts | 42 +++++++++++++------------- src/scss/partials/_fonts.scss | 2 +- src/scss/style.scss | 17 +++++++++++ 6 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/components/sidebarLeft/index.ts b/src/components/sidebarLeft/index.ts index 6c863915..64b83b68 100644 --- a/src/components/sidebarLeft/index.ts +++ b/src/components/sidebarLeft/index.ts @@ -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) => { diff --git a/src/config/app.ts b/src/config/app.ts index 261194ff..a50451a6 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -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[], diff --git a/src/lang.ts b/src/lang.ts index 2113e29e..a248fc8b 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -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 a–z, 0–9 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...", diff --git a/src/lib/appManagers/appStateManager.ts b/src/lib/appManagers/appStateManager.ts index b7e41407..05a39dc0 100644 --- a/src/lib/appManagers/appStateManager.ts +++ b/src/lib/appManagers/appStateManager.ts @@ -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'}; diff --git a/src/scss/partials/_fonts.scss b/src/scss/partials/_fonts.scss index 0dac77b0..bfdc938c 100644 --- a/src/scss/partials/_fonts.scss +++ b/src/scss/partials/_fonts.scss @@ -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; diff --git a/src/scss/style.scss b/src/scss/style.scss index 6b0a3fa1..57733fb8 100644 --- a/src/scss/style.scss +++ b/src/scss/style.scss @@ -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"; + } +}