diff --git a/src/components/animationIntersector.ts b/src/components/animationIntersector.ts
index 5844f42b..e64dd49e 100644
--- a/src/components/animationIntersector.ts
+++ b/src/components/animationIntersector.ts
@@ -1,5 +1,6 @@
import { isInDOM, $rootScope } from "../lib/utils";
import { RLottiePlayer } from "../lib/lottieLoader";
+import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
export interface AnimationItem {
el: HTMLElement,
@@ -166,7 +167,7 @@ export class AnimationIntersector {
}
const animationIntersector = new AnimationIntersector();
-if(process.env.NODE_ENV == 'development') {
- (window as any).animationIntersector = animationIntersector;
+if(MOUNT_CLASS_TO) {
+ MOUNT_CLASS_TO.animationIntersector = animationIntersector;
}
export default animationIntersector;
\ No newline at end of file
diff --git a/src/components/appMediaPlaybackController.ts b/src/components/appMediaPlaybackController.ts
index 5efe51a8..b86a628f 100644
--- a/src/components/appMediaPlaybackController.ts
+++ b/src/components/appMediaPlaybackController.ts
@@ -3,6 +3,7 @@ import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager";
import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise";
import { isSafari } from "../helpers/userAgent";
+import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
// TODO: если удалить сообщение, и при этом аудио будет играть - оно не остановится, и можно будет по нему перейти вникуда
@@ -232,8 +233,5 @@ class AppMediaPlaybackController {
}
const appMediaPlaybackController = new AppMediaPlaybackController();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appMediaPlaybackController = appMediaPlaybackController;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appMediaPlaybackController = appMediaPlaybackController);
export default appMediaPlaybackController;
\ No newline at end of file
diff --git a/src/components/audio.ts b/src/components/audio.ts
index 20a9bb70..fbd483a6 100644
--- a/src/components/audio.ts
+++ b/src/components/audio.ts
@@ -37,7 +37,6 @@ export function decodeWaveform(waveform: Uint8Array | number[]) {
} else {
var value = dataView.getUint16(byteIndex, true);
}
-
console.log('decoded waveform, setting last value:', value, byteIndex, bitShift);
result[valueCount - 1] = (value >> bitShift) & 0b00011111; */
return result;
@@ -296,7 +295,10 @@ export default class AudioElement extends HTMLElement {
const durationStr = String(doc.duration | 0).toHHMMSS(true);
- this.innerHTML = `
`;
+ this.innerHTML = ``;
const downloadDiv = document.createElement('div');
downloadDiv.classList.add('audio-download');
@@ -323,7 +325,7 @@ export default class AudioElement extends HTMLElement {
const onPlaying = () => {
audioTimeDiv.innerText = String(audio.currentTime | 0).toHHMMSS(true) + ' / ' + durationStr;
if(!audio.paused) {
- toggle.classList.remove('tgico-largeplay');
+ //toggle.classList.remove('tgico-largeplay');
toggle.classList.add('tgico-largepause');
}
};
@@ -339,7 +341,7 @@ export default class AudioElement extends HTMLElement {
});
this.addAudioListener('ended', () => {
- toggle.classList.add('tgico-largeplay');
+ //toggle.classList.add('tgico-largeplay');
toggle.classList.remove('tgico-largepause');
});
@@ -349,7 +351,7 @@ export default class AudioElement extends HTMLElement {
});
this.addAudioListener('pause', () => {
- toggle.classList.add('tgico-largeplay');
+ //toggle.classList.add('tgico-largeplay');
toggle.classList.remove('tgico-largepause');
});
diff --git a/src/components/emoticonsDropdown/index.ts b/src/components/emoticonsDropdown/index.ts
index e1bf65b2..103135d4 100644
--- a/src/components/emoticonsDropdown/index.ts
+++ b/src/components/emoticonsDropdown/index.ts
@@ -10,6 +10,7 @@ import Scrollable, { ScrollableX } from "../scrollable_new";
import EmojiTab from "./tabs/emoji";
import StickersTab from "./tabs/stickers";
import StickyIntersector from "../stickyIntersector";
+import { MOUNT_CLASS_TO } from "../../lib/mtproto/mtproto_config";
export const EMOTICONSSTICKERGROUP = 'emoticons-dropdown';
@@ -326,8 +327,5 @@ export class EmoticonsDropdown {
}
const emoticonsDropdown = new EmoticonsDropdown();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).emoticonsDropdown = emoticonsDropdown;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.emoticonsDropdown = emoticonsDropdown);
export default emoticonsDropdown;
\ No newline at end of file
diff --git a/src/components/sidebarLeft/settings.ts b/src/components/sidebarLeft/settings.ts
index 6d49499b..83ee6e77 100644
--- a/src/components/sidebarLeft/settings.ts
+++ b/src/components/sidebarLeft/settings.ts
@@ -31,10 +31,7 @@ export default class AppSettingsTab implements SliderTab {
});
this.logOutBtn.addEventListener('click', (e) => {
- apiManager.logOut().finally(() => {
- localStorage.clear();
- location.reload();
- });
+ apiManager.logOut();
});
this.buttons.edit.addEventListener('click', () => {
diff --git a/src/helpers/mediaSizes.ts b/src/helpers/mediaSizes.ts
index 6295f2e3..323f2924 100644
--- a/src/helpers/mediaSizes.ts
+++ b/src/helpers/mediaSizes.ts
@@ -1,3 +1,4 @@
+import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
import EventListenerBase from "./eventListenerBase";
type Size = Partial<{width: number, height: number}>;
@@ -112,7 +113,5 @@ class MediaSizes extends EventListenerBase<{
}
const mediaSizes = new MediaSizes();
-if(process.env.NODE_ENV != 'production') {
- (window as any).mediaSizes = mediaSizes;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.mediaSizes = mediaSizes);
export default mediaSizes;
\ No newline at end of file
diff --git a/src/lib/appManagers/appDocsManager.ts b/src/lib/appManagers/appDocsManager.ts
index 65ffab74..fcf9635f 100644
--- a/src/lib/appManagers/appDocsManager.ts
+++ b/src/lib/appManagers/appDocsManager.ts
@@ -7,6 +7,7 @@ import appPhotosManager from './appPhotosManager';
import { isServiceWorkerSupported } from '../config';
import { InputFileLocation, Document, PhotoSize } from '../../layer';
import referenceDatabase, { ReferenceContext } from '../mtproto/referenceDatabase';
+import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
export type MyDocument = Document.document;
@@ -22,8 +23,10 @@ class AppDocsManager {
const oldDoc = this.docs[doc.id];
- safeReplaceArrayInObject('file_reference', oldDoc, doc);
- referenceDatabase.saveContext(doc.file_reference, context);
+ if(doc.file_reference) { // * because we can have a new object w/o the file_reference while sending
+ safeReplaceArrayInObject('file_reference', oldDoc, doc);
+ referenceDatabase.saveContext(doc.file_reference, context);
+ }
//console.log('saveDoc', apiDoc, this.docs[apiDoc.id]);
if(oldDoc) {
@@ -319,8 +322,5 @@ class AppDocsManager {
}
const appDocsManager = new AppDocsManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appDocsManager = appDocsManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appDocsManager = appDocsManager);
export default appDocsManager;
diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts
index 0cbcfbbf..7dfe755b 100644
--- a/src/lib/appManagers/appImManager.ts
+++ b/src/lib/appManagers/appImManager.ts
@@ -41,6 +41,7 @@ import { ChatContextMenu } from '../../components/chat/contextMenu';
import { ChatSearch } from '../../components/chat/search';
import mediaSizes from '../../helpers/mediaSizes';
import { isAndroid, isApple, isSafari } from '../../helpers/userAgent';
+import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
//console.log('appImManager included33!');
@@ -2731,8 +2732,5 @@ export class AppImManager {
}
const appImManager = new AppImManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appImManager = appImManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appImManager = appImManager);
export default appImManager;
diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts
index cb47d577..8f7d5d06 100644
--- a/src/lib/appManagers/appMessagesManager.ts
+++ b/src/lib/appManagers/appMessagesManager.ts
@@ -3780,7 +3780,7 @@ export class AppMessagesManager {
let c = message.media.webpage || message.media;
const smth = c.photo || c.document;
- if(smth.file_reference) {
+ if(smth?.file_reference) {
referenceDatabase.deleteContext(smth.file_reference, {type: 'message', messageID});
}
}
diff --git a/src/lib/appManagers/appPhotosManager.ts b/src/lib/appManagers/appPhotosManager.ts
index 986d0322..67535c67 100644
--- a/src/lib/appManagers/appPhotosManager.ts
+++ b/src/lib/appManagers/appPhotosManager.ts
@@ -52,8 +52,10 @@ export class AppPhotosManager {
} */
const oldPhoto = this.photos[photo.id];
- safeReplaceArrayInObject('file_reference', oldPhoto, photo);
- referenceDatabase.saveContext(photo.file_reference, context);
+ if(photo.file_reference) { // * because we can have a new object w/o the file_reference while sending
+ safeReplaceArrayInObject('file_reference', oldPhoto, photo);
+ referenceDatabase.saveContext(photo.file_reference, context);
+ }
if(oldPhoto) {
return Object.assign(oldPhoto, photo);
diff --git a/src/lib/appManagers/appPollsManager.ts b/src/lib/appManagers/appPollsManager.ts
index afa084b6..40911b2b 100644
--- a/src/lib/appManagers/appPollsManager.ts
+++ b/src/lib/appManagers/appPollsManager.ts
@@ -6,6 +6,7 @@ import apiUpdatesManager from "./apiUpdatesManager";
import { $rootScope } from "../utils";
import { logger, LogLevels } from "../logger";
import appUsersManager from "./appUsersManager";
+import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
export type PollAnswer = {
_: 'pollAnswer',
@@ -206,8 +207,5 @@ class AppPollsManager {
}
const appPollsManager = new AppPollsManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appPollsManager = appPollsManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appPollsManager = appPollsManager);
export default appPollsManager;
\ No newline at end of file
diff --git a/src/lib/appManagers/appSidebarLeft.ts b/src/lib/appManagers/appSidebarLeft.ts
index 0dc4efc4..434ece27 100644
--- a/src/lib/appManagers/appSidebarLeft.ts
+++ b/src/lib/appManagers/appSidebarLeft.ts
@@ -21,6 +21,7 @@ import SidebarSlider from "../../components/slider";
import SearchInput from "../../components/searchInput";
import appStateManager from "./appStateManager";
import appChatsManager from "./appChatsManager";
+import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
AvatarElement;
@@ -301,8 +302,5 @@ export class AppSidebarLeft extends SidebarSlider {
}
const appSidebarLeft = new AppSidebarLeft();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appSidebarLeft = appSidebarLeft;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appSidebarLeft = appSidebarLeft);
export default appSidebarLeft;
diff --git a/src/lib/appManagers/appSidebarRight.ts b/src/lib/appManagers/appSidebarRight.ts
index 0f1f1c6c..e114280e 100644
--- a/src/lib/appManagers/appSidebarRight.ts
+++ b/src/lib/appManagers/appSidebarRight.ts
@@ -7,6 +7,7 @@ import mediaSizes, { ScreenSize } from "../../helpers/mediaSizes";
import AppPrivateSearchTab from "../../components/sidebarRight/search";
import AppSharedMediaTab from "../../components/sidebarRight/sharedMedia";
import AppForwardTab from "../../components/sidebarRight/forward";
+import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
export const RIGHT_COLUMN_ACTIVE_CLASSNAME = 'is-right-column-shown';
@@ -165,8 +166,5 @@ export class AppSidebarRight extends SidebarSlider {
}
const appSidebarRight = new AppSidebarRight();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appSidebarRight = appSidebarRight;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appSidebarRight = appSidebarRight);
export default appSidebarRight;
diff --git a/src/lib/appManagers/appStateManager.ts b/src/lib/appManagers/appStateManager.ts
index 831bafb0..fbaa582e 100644
--- a/src/lib/appManagers/appStateManager.ts
+++ b/src/lib/appManagers/appStateManager.ts
@@ -8,7 +8,7 @@ import apiUpdatesManager from './apiUpdatesManager';
import { $rootScope, copy } from '../utils';
import { logger } from '../logger';
import type { AppStickersManager } from './appStickersManager';
-import { App } from '../mtproto/mtproto_config';
+import { App, MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
const REFRESH_EVERY = 24 * 60 * 60 * 1000; // 1 day
const STATE_VERSION = App.version;
@@ -233,8 +233,5 @@ export class AppStateManager {
//console.trace('appStateManager include');
const appStateManager = new AppStateManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).appStateManager = appStateManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appStateManager = appStateManager);
export default appStateManager;
\ No newline at end of file
diff --git a/src/lib/appManagers/appStickersManager.ts b/src/lib/appManagers/appStickersManager.ts
index 87b6768a..5447f7ed 100644
--- a/src/lib/appManagers/appStickersManager.ts
+++ b/src/lib/appManagers/appStickersManager.ts
@@ -4,6 +4,7 @@ import { $rootScope } from '../utils';
import { StickerSet, InputStickerSet, StickerSetCovered, MessagesRecentStickers, Document, InputFileLocation, MessagesStickerSet, PhotoSize } from '../../layer';
import { Modify } from '../../types';
import appStateManager from './appStateManager';
+import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
export class AppStickersManager {
private stickerSets: {
@@ -259,7 +260,5 @@ export class AppStickersManager {
}
const appStickersManager = new AppStickersManager();
-if(process.env.NODE_ENV != 'production') {
- (window as any).appStickersManager = appStickersManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appStickersManager = appStickersManager);
export default appStickersManager;
diff --git a/src/lib/cacheStorage.ts b/src/lib/cacheStorage.ts
index 13847b05..df25dbf8 100644
--- a/src/lib/cacheStorage.ts
+++ b/src/lib/cacheStorage.ts
@@ -1,5 +1,6 @@
import {blobConstruct} from './bin_utils';
import FileManager from './filemanager';
+import { MOUNT_CLASS_TO } from './mtproto/mtproto_config';
//import { logger } from './polyfill';
class CacheStorageController {
@@ -95,8 +96,5 @@ class CacheStorageController {
}
const cacheStorage = new CacheStorageController();
-/* // @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).cacheStorage = cacheStorage;
-} */
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.cacheStorage = cacheStorage);
export default cacheStorage;
diff --git a/src/lib/logger.ts b/src/lib/logger.ts
index 8221a4d8..001088ac 100644
--- a/src/lib/logger.ts
+++ b/src/lib/logger.ts
@@ -1,3 +1,5 @@
+//import { DEBUG } from "./mtproto/mtproto_config";
+
export enum LogLevels {
log = 1,
warn = 2,
@@ -11,8 +13,7 @@ function dT() {
}
export function logger(prefix: string, level = LogLevels.log | LogLevels.warn | LogLevels.error) {
- // @ts-ignore
- if(process.env.NODE_ENV == 'production'/* || true */) {
+ if(process.env.NODE_ENV == 'development'/* || true */) {
level = LogLevels.error;
}
diff --git a/src/lib/lottieLoader.ts b/src/lib/lottieLoader.ts
index fb50dadc..79152fbc 100644
--- a/src/lib/lottieLoader.ts
+++ b/src/lib/lottieLoader.ts
@@ -5,6 +5,7 @@ import EventListenerBase from "../helpers/eventListenerBase";
import mediaSizes from "../helpers/mediaSizes";
import { isAndroid, isApple, isAppleMobile, isSafari } from "../helpers/userAgent";
import RLottieWorker from 'worker-loader!./rlottie/rlottie.worker';
+import { MOUNT_CLASS_TO } from "./mtproto/mtproto_config";
let convert = (value: number) => {
return Math.round(Math.min(Math.max(value, 0), 1) * 255);
@@ -720,8 +721,5 @@ class LottieLoader {
}
const lottieLoader = new LottieLoader();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).lottieLoader = lottieLoader;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.lottieLoader = lottieLoader);
export default lottieLoader;
diff --git a/src/lib/mtproto/apiFileManager.ts b/src/lib/mtproto/apiFileManager.ts
index 170fbad0..d0ce34fa 100644
--- a/src/lib/mtproto/apiFileManager.ts
+++ b/src/lib/mtproto/apiFileManager.ts
@@ -9,6 +9,7 @@ import cryptoWorker from "../crypto/cryptoworker";
import { notifySomeone, notifyAll } from "../../helpers/context";
import { InputFileLocation, FileLocation, InputFile, UploadFile } from "../../layer";
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise";
+import { MOUNT_CLASS_TO } from "./mtproto_config";
type Delayed = {
offset: number,
@@ -541,8 +542,5 @@ export class ApiFileManager {
}
const apiFileManager = new ApiFileManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (self as any).apiFileManager = apiFileManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiFileManager = apiFileManager);
export default apiFileManager;
diff --git a/src/lib/mtproto/apiManager.ts b/src/lib/mtproto/apiManager.ts
index d75902eb..0f15feb5 100644
--- a/src/lib/mtproto/apiManager.ts
+++ b/src/lib/mtproto/apiManager.ts
@@ -18,6 +18,17 @@ import { InvokeApiOptions } from '../../types';
//console.error('apiManager included!');
// TODO: если запрос словил флуд, нужно сохранять его параметры и возвращать тот же промис на новый такой же запрос, например - загрузка истории
+export type ApiError = Partial<{
+ code: number,
+ type: string,
+ description: string,
+ originalError: any,
+ stack: string,
+ handled: boolean,
+ input: string,
+ message: ApiError
+}>;
+
export class ApiManager {
public cachedNetworkers: {[x: number]: MTPNetworker} = {};
public cachedUploadNetworkers: {[x: number]: MTPNetworker} = {};
@@ -87,52 +98,17 @@ export class ApiManager {
}
return Promise.all(logoutPromises).then(() => {
- AppStorage.remove('dc', 'user_auth', 'stickerSets');
- this.baseDcID = 0;
- this.telegramMeNotify(false);
- this.mtpClearStorage();
}, (error) => {
- storageKeys.push('dc', 'user_auth', 'stickerSets');
- AppStorage.remove(storageKeys);
- this.baseDcID = 0;
error.handled = true;
+ }).finally(() => {
+ this.baseDcID = 0;
this.telegramMeNotify(false);
- this.mtpClearStorage();
+ AppStorage.clear();
})/* .then(() => {
location.pathname = '/';
}) */;
}
- public mtpClearStorage() {
- var saveKeys = ['user_auth', 't_user_auth', 'dc', 't_dc'];
-
- for(var dcID = 1; dcID <= 5; dcID++) {
- saveKeys.push('dc' + dcID + '_auth_key');
- saveKeys.push('dc' + dcID + '_auth_keyID');
- saveKeys.push('dc' + dcID + '_server_salt'); // new
- saveKeys.push('t_dc' + dcID + '_auth_key');
- saveKeys.push('t_dc' + dcID + '_auth_keyID');
- saveKeys.push('t_dc' + dcID + '_server_salt'); // new
- }
-
- AppStorage.noPrefix();
- AppStorage.get(saveKeys).then((values) => {
- AppStorage.clear().then(() => {
- var restoreObj: any = {};
-
- saveKeys.forEach((key, i) => {
- var value = values[i];
- if(value !== false && value !== undefined) {
- restoreObj[key] = value;
- }
- });
-
- AppStorage.noPrefix();
- return AppStorage.set(restoreObj);
- });
- });
- }
-
// mtpGetNetworker
public async getNetworker(dcID: number, options: InvokeApiOptions): Promise {
const upload = (options.fileUpload || options.fileDownload)
@@ -205,14 +181,19 @@ export class ApiManager {
///////this.log('Invoke api', method, params, options);
return new Promise((resolve, reject) => {
- let rejectPromise = (error: any) => {
+ let rejectPromise = (error: ApiError) => {
if(!error) {
error = {type: 'ERROR_EMPTY'};
- } else if (!isObject(error)) {
+ } else if(!isObject(error)) {
error = {message: error};
}
reject(error);
+
+ if(error.code == 401 && error.type == 'SESSION_REVOKED') {
+ this.logOut();
+ }
+
if(options.ignoreErrors) {
return;
}
@@ -245,8 +226,11 @@ export class ApiManager {
var performRequest = (networker: MTPNetworker) => {
return (cachedNetworker = networker)
.wrapApiCall(method, params, options)
- .then(resolve, (error: any) => {
- this.log.error('Error', error.code, error.type, this.baseDcID, dcID);
+ .then(resolve, (error: ApiError) => {
+ //if(!options.ignoreErrors) {
+ if(error.type != 'FILE_REFERENCE_EXPIRED') {
+ this.log.error('Error', error.code, error.type, this.baseDcID, dcID);
+ }
if(error.code == 401 && this.baseDcID == dcID) {
AppStorage.remove('dc', 'user_auth');
@@ -270,7 +254,7 @@ export class ApiManager {
(cachedNetworker = networker).wrapApiCall(method, params, options).then(resolve, rejectPromise);
}, rejectPromise);
} else if(error.code == 303) {
- var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_|USER_MIGRATE_)(\d+)/)[2];
+ var newDcID = +error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_|USER_MIGRATE_)(\d+)/)[2];
if(newDcID != dcID) {
if(options.dcID) {
options.dcID = newDcID;
@@ -283,7 +267,7 @@ export class ApiManager {
}, rejectPromise);
}
} else if(!options.rawError && error.code == 420) {
- var waitTime = error.type.match(/^FLOOD_WAIT_(\d+)/)[1] || 10;
+ var waitTime = +error.type.match(/^FLOOD_WAIT_(\d+)/)[1] || 10;
if(waitTime > (options.timeout !== undefined ? options.timeout : 60)) {
return rejectPromise(error);
diff --git a/src/lib/mtproto/mtproto.service.ts b/src/lib/mtproto/mtproto.service.ts
index 045e6d6b..33f3f03d 100644
--- a/src/lib/mtproto/mtproto.service.ts
+++ b/src/lib/mtproto/mtproto.service.ts
@@ -222,7 +222,4 @@ function alignLimit(limit: number) {
return 2 ** Math.ceil(Math.log(limit) / Math.log(2));
}
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (ctx as any).onFetch = onFetch;
-}
+//MOUNT_CLASS_TO && (MOUNT_CLASS_TO.onFetch = onFetch);
diff --git a/src/lib/mtproto/mtproto_config.ts b/src/lib/mtproto/mtproto_config.ts
index ee8c0197..fa10a17f 100644
--- a/src/lib/mtproto/mtproto_config.ts
+++ b/src/lib/mtproto/mtproto_config.ts
@@ -13,3 +13,6 @@ export const Modes = {
ssl: true, // location.search.indexOf('ssl=1') > 0 || location.protocol == 'https:' && location.search.indexOf('ssl=0') == -1,
multipleConnections: true
};
+
+export const DEBUG = process.env.NODE_ENV != 'production';
+export const MOUNT_CLASS_TO: any = DEBUG ? typeof(window) !== 'undefined' ? window : self : null;
diff --git a/src/lib/mtproto/mtprotoworker.ts b/src/lib/mtproto/mtprotoworker.ts
index b037f2ed..689bc202 100644
--- a/src/lib/mtproto/mtprotoworker.ts
+++ b/src/lib/mtproto/mtprotoworker.ts
@@ -8,6 +8,7 @@ import type { DownloadOptions } from './apiFileManager';
import type { ServiceWorkerTask, ServiceWorkerTaskResponse } from './mtproto.service';
import { isServiceWorkerSupported } from '../config';
import { MethodDeclMap } from '../../layer';
+import { MOUNT_CLASS_TO } from './mtproto_config';
type Task = {
taskID: number,
@@ -230,8 +231,5 @@ class ApiManagerProxy extends CryptoWorkerMethods {
}
const apiManagerProxy = new ApiManagerProxy();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).apiManagerProxy = apiManagerProxy;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiManagerProxy = apiManagerProxy);
export default apiManagerProxy;
diff --git a/src/lib/mtproto/passwordManager.ts b/src/lib/mtproto/passwordManager.ts
index b1d279ff..d69cb663 100644
--- a/src/lib/mtproto/passwordManager.ts
+++ b/src/lib/mtproto/passwordManager.ts
@@ -1,5 +1,6 @@
import apiManager from './mtprotoworker';
import { AccountPassword } from '../../layer';
+import { MOUNT_CLASS_TO } from './mtproto_config';
//import { computeCheck } from "../crypto/srp";
export class PasswordManager {
@@ -76,8 +77,5 @@ export class PasswordManager {
}
const passwordManager = new PasswordManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (self as any).passwordManager = passwordManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.passwordManager = passwordManager);
export default passwordManager;
diff --git a/src/lib/mtproto/referenceDatabase.ts b/src/lib/mtproto/referenceDatabase.ts
index f72251b4..e3b11826 100644
--- a/src/lib/mtproto/referenceDatabase.ts
+++ b/src/lib/mtproto/referenceDatabase.ts
@@ -1,5 +1,6 @@
import { Photo } from "../../layer";
import { deepEqual } from "../utils";
+import { MOUNT_CLASS_TO } from "./mtproto_config";
export type ReferenceContext = ReferenceContext.referenceContextProfilePhoto | ReferenceContext.referenceContextMessage;
export namespace ReferenceContext {
@@ -66,7 +67,5 @@ class ReferenceDatabase {
}
const referenceDatabase = new ReferenceDatabase();
-if(process.env.NODE_ENV != 'production') {
- (window as any).referenceDatabase = referenceDatabase;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.referenceDatabase = referenceDatabase);
export default referenceDatabase;
\ No newline at end of file
diff --git a/src/lib/opusDecodeController.ts b/src/lib/opusDecodeController.ts
index cfd11e67..b3e987b4 100644
--- a/src/lib/opusDecodeController.ts
+++ b/src/lib/opusDecodeController.ts
@@ -1,5 +1,6 @@
import { isSafari } from "../helpers/userAgent";
import { logger, LogLevels } from "./logger";
+import { MOUNT_CLASS_TO } from "./mtproto/mtproto_config";
type Result = {
bytes: Uint8Array,
@@ -172,8 +173,5 @@ export class OpusDecodeController {
}
const opusDecodeController = new OpusDecodeController();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).opusDecodeController = opusDecodeController;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.opusDecodeController = opusDecodeController);
export default opusDecodeController;
\ No newline at end of file
diff --git a/src/lib/richtextprocessor.ts b/src/lib/richtextprocessor.ts
index 896adcc2..ffdc3d19 100644
--- a/src/lib/richtextprocessor.ts
+++ b/src/lib/richtextprocessor.ts
@@ -3,6 +3,7 @@ import Config from './config';
import emojiRegExp from '../emoji/regex';
import { encodeEmoji } from '../emoji';
+import { MOUNT_CLASS_TO } from './mtproto/mtproto_config';
var EmojiHelper = {
emojiMap: (code: string) => { return code; },
@@ -778,10 +779,7 @@ let RichTextProcessor = {
emojiSupported: emojiSupported
};
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).RichTextProcessor = RichTextProcessor;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.RichTextProcessor = RichTextProcessor);
export {RichTextProcessor};
diff --git a/src/lib/storage.ts b/src/lib/storage.ts
index da1695a7..0465691f 100644
--- a/src/lib/storage.ts
+++ b/src/lib/storage.ts
@@ -121,17 +121,9 @@ class ConfigStorage {
}
}
- clear(callback: any) {
- if(this.useLs) {
- try {
- localStorage.clear();
- } catch (e) {
- this.useLs = false;
- }
- }
-
- this.cache = {};
- callback();
+ clear() {
+ localStorage.clear();
+ location.reload();
}
}
@@ -210,8 +202,8 @@ class AppStorage {
return this.proxy('remove', ...args);
}
- public clear(...args: any[]) {
- return this.proxy('clear', ...args);
+ public clear() {
+ return this.proxy('clear');
}
}
diff --git a/src/lib/webp/webpWorkerController.ts b/src/lib/webp/webpWorkerController.ts
index 62a40fa6..b23e86a3 100644
--- a/src/lib/webp/webpWorkerController.ts
+++ b/src/lib/webp/webpWorkerController.ts
@@ -1,6 +1,7 @@
import WebpWorker from 'worker-loader!./webp.worker';
import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise';
import apiManagerProxy from '../mtproto/mtprotoworker';
+import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
export type WebpConvertTask = {
type: 'convertWebp',
@@ -56,8 +57,5 @@ export class WebpWorkerController {
}
const webpWorkerController = new WebpWorkerController();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).webpWorkerController = webpWorkerController;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.webpWorkerController = webpWorkerController);
export default webpWorkerController;
\ No newline at end of file
diff --git a/src/pages/pageIm.ts b/src/pages/pageIm.ts
index d565b41b..61777b24 100644
--- a/src/pages/pageIm.ts
+++ b/src/pages/pageIm.ts
@@ -2,6 +2,7 @@ import { openBtnMenu/* , ripple */ } from "../components/misc";
//import {stackBlurImage} from '../lib/StackBlur';
import Page from "./page";
import { cancelEvent } from "../lib/utils";
+import { DEBUG } from "../lib/mtproto/mtproto_config";
let onFirstMount = () => {
//return;
@@ -21,8 +22,7 @@ let onFirstMount = () => {
alert('navigator.mediaDevices.getUserMedia:' + typeof(navigator.mediaDevices?.getUserMedia));
alert('global.WebAssembly:' + typeof(WebAssembly)); */
- // @ts-ignore
- if(process.env.NODE_ENV != 'production') {
+ if(DEBUG) {
import('../lib/services');
}
diff --git a/src/pages/pagesManager.ts b/src/pages/pagesManager.ts
index 21263663..727be7cc 100644
--- a/src/pages/pagesManager.ts
+++ b/src/pages/pagesManager.ts
@@ -2,6 +2,7 @@ import Page from "./page";
import { whichChild } from "../lib/utils";
import lottieLoader from "../lib/lottieLoader";
import { horizontalMenu } from "../components/horizontalMenu";
+import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
class PagesManager {
private pageID = -1;
@@ -38,8 +39,5 @@ class PagesManager {
}
const pagesManager = new PagesManager();
-// @ts-ignore
-if(process.env.NODE_ENV != 'production') {
- (window as any).pagesManager = pagesManager;
-}
+MOUNT_CLASS_TO && (MOUNT_CLASS_TO.pagesManager = pagesManager);
export default pagesManager;
\ No newline at end of file
diff --git a/src/scss/partials/_audio.scss b/src/scss/partials/_audio.scss
index 29b62a37..1773d4d5 100644
--- a/src/scss/partials/_audio.scss
+++ b/src/scss/partials/_audio.scss
@@ -12,11 +12,325 @@
&-toggle, &-download {
border-radius: 50%;
background-color: $color-blue;
- font-size: 2.3rem;
+ font-size: 0;
align-items: center;
+ }
- @include respond-to(handhelds) {
- font-size: 24px !important;
+ &-toggle {
+ transform: rotate(-119deg);
+ transition: transform .25s;
+ }
+
+ .tgico-largeplay {
+ .part {
+ position: absolute;
+ background-color: white;
+
+ @include respond-to(not-handhelds) {
+ height: 136px;
+ width: 136px;
+ }
+
+ @include respond-to(handhelds) {
+ height: 92px;
+ width: 92px;
+ }
+
+ &.one {
+ clip-path: polygon(
+ 43.77666% 55.85251%,
+ 43.77874% 55.46331%,
+ 43.7795% 55.09177%,
+ 43.77934% 54.74844%,
+ 43.77855% 54.44389%,
+ 43.77741% 54.18863%,
+ 43.77625% 53.99325%,
+ 43.77533% 53.86828%,
+ 43.77495% 53.82429%,
+ 43.77518% 53.55329%,
+ 43.7754% 53.2823%,
+ 43.77563% 53.01131%,
+ 43.77585% 52.74031%,
+ 43.77608% 52.46932%,
+ 43.7763% 52.19832%,
+ 43.77653% 51.92733%,
+ 43.77675% 51.65633%,
+ 43.77653% 51.38533%,
+ 43.7763% 51.11434%,
+ 43.77608% 50.84334%,
+ 43.77585% 50.57235%,
+ 43.77563% 50.30136%,
+ 43.7754% 50.03036%,
+ 43.77518% 49.75936%,
+ 43.77495% 49.48837%,
+ 44.48391% 49.4885%,
+ 45.19287% 49.48865%,
+ 45.90183% 49.48878%,
+ 46.61079% 49.48892%,
+ 47.31975% 49.48906%,
+ 48.0287% 49.4892%,
+ 48.73766% 49.48934%,
+ 49.44662% 49.48948%,
+ 50.72252% 49.48934%,
+ 51.99842% 49.4892%,
+ 53.27432% 49.48906%,
+ 54.55022% 49.48892%,
+ 55.82611% 49.48878%,
+ 57.10201% 49.48865%,
+ 58.3779% 49.4885%,
+ 59.6538% 49.48837%,
+ 59.57598% 49.89151%,
+ 59.31883% 50.28598%,
+ 58.84686% 50.70884%,
+ 58.12456% 51.19714%,
+ 57.11643% 51.78793%,
+ 55.78697% 52.51828%,
+ 54.10066% 53.42522%,
+ 52.02202% 54.54581%,
+ 49.96525% 55.66916%,
+ 48.3319% 56.57212%,
+ 47.06745% 57.27347%,
+ 46.11739% 57.79191%,
+ 45.42719% 58.14619%,
+ 44.94235% 58.35507%,
+ 44.60834% 58.43725%,
+ 44.37066% 58.41149%,
+ 44.15383% 58.27711%,
+ 43.99617% 58.0603%,
+ 43.88847% 57.77578%,
+ 43.82151% 57.43825%,
+ 43.78608% 57.06245%,
+ 43.77304% 56.66309%,
+ 43.773% 56.25486%
+ );
+ transition: clip-path 250ms;
+ }
+
+ &.two {
+ clip-path: polygon(
+ 43.77666% 43.83035%,
+ 43.77874% 44.21955%,
+ 43.7795% 44.59109%,
+ 43.77934% 44.93442%,
+ 43.77855% 45.23898%,
+ 43.77741% 45.49423%,
+ 43.77625% 45.68961%,
+ 43.77533% 45.81458%,
+ 43.77495% 45.85858%,
+ 43.77518% 46.12957%,
+ 43.7754% 46.40056%,
+ 43.77563% 46.67156%,
+ 43.77585% 46.94255%,
+ 43.77608% 47.21355%,
+ 43.7763% 47.48454%,
+ 43.77653% 47.75554%,
+ 43.77675% 48.02654%,
+ 43.77653% 48.29753%,
+ 43.7763% 48.56852%,
+ 43.77608% 48.83952%,
+ 43.77585% 49.11051%,
+ 43.77563% 49.38151%,
+ 43.7754% 49.65251%,
+ 43.77518% 49.9235%,
+ 43.77495% 50.1945%,
+ 44.48391% 50.19436%,
+ 45.19287% 50.19422%,
+ 45.90183% 50.19408%,
+ 46.61079% 50.19394%,
+ 47.31975% 50.1938%,
+ 48.0287% 50.19366%,
+ 48.73766% 50.19353%,
+ 49.44662% 50.19338%,
+ 50.72252% 50.19353%,
+ 51.99842% 50.19366%,
+ 53.27432% 50.1938%,
+ 54.55022% 50.19394%,
+ 55.82611% 50.19408%,
+ 57.10201% 50.19422%,
+ 58.3779% 50.19436%,
+ 59.6538% 50.1945%,
+ 59.57598% 49.79136%,
+ 59.31883% 49.39688%,
+ 58.84686% 48.97402%,
+ 58.12456% 48.48572%,
+ 57.11643% 47.89493%,
+ 55.78697% 47.16458%,
+ 54.10066% 46.25764%,
+ 52.02202% 45.13705%,
+ 49.96525% 44.01371%,
+ 48.3319% 43.11074%,
+ 47.06745% 42.4094%,
+ 46.11739% 41.89096%,
+ 45.42719% 41.53667%,
+ 44.94235% 41.3278%,
+ 44.60834% 41.24561%,
+ 44.37066% 41.27137%,
+ 44.15383% 41.40575%,
+ 43.99617% 41.62256%,
+ 43.88847% 41.90709%,
+ 43.82151% 42.24461%,
+ 43.78608% 42.62041%,
+ 43.77304% 43.01978%,
+ 43.773% 43.428%
+ );
+ transition: clip-path 250ms;
+ }
+ }
+ }
+
+ .tgico-largepause {
+ transform: rotate(-90deg);
+ .part {
+ position: absolute;
+ background-color: white;
+
+ @include respond-to(not-handhelds) {
+ height: 140px;
+ width: 140px;
+ }
+
+ @include respond-to(handhelds) {
+ height: 92px;
+ width: 92px;
+ }
+
+ &.one {
+ clip-path: polygon(
+ 56.42249% 57.01763%,
+ 54.93283% 57.0175%,
+ 53.00511% 57.01738%,
+ 50.83554% 57.01727%,
+ 48.62036% 57.01718%,
+ 46.55585% 57.01709%,
+ 44.83822% 57.01702%,
+ 43.66373% 57.01698%,
+ 43.22863% 57.01696%,
+ 42.86372% 57.01904%,
+ 42.56988% 57.01621%,
+ 42.3402% 56.99486%,
+ 42.16778% 56.94152%,
+ 42.0457% 56.84267%,
+ 41.96705% 56.68478%,
+ 41.92493% 56.45432%,
+ 41.91246% 56.13777%,
+ 41.91258% 55.76282%,
+ 41.9129% 55.37058%,
+ 41.91335% 54.96757%,
+ 41.91387% 54.56032%,
+ 41.91439% 54.15537%,
+ 41.91485% 53.75926%,
+ 41.91517% 53.3785%,
+ 41.91529% 53.01965%,
+ 41.94275% 52.72355%,
+ 42.02117% 52.51653%,
+ 42.14465% 52.38328%,
+ 42.30727% 52.30854%,
+ 42.50308% 52.27699%,
+ 42.72619% 52.27341%,
+ 42.97065% 52.28248%,
+ 43.23056% 52.2889%,
+ 43.94949% 52.28896%,
+ 45.45083% 52.28912%,
+ 47.47445% 52.28932%,
+ 49.76027% 52.28957%,
+ 52.04818% 52.28981%,
+ 54.07805% 52.29003%,
+ 55.5898% 52.29019%,
+ 56.32332% 52.29024%,
+ 56.58221% 52.28816%,
+ 56.83726% 52.28948%,
+ 57.07897% 52.30593%,
+ 57.29794% 52.34898%,
+ 57.48468% 52.43029%,
+ 57.62978% 52.56146%,
+ 57.72375% 52.7541%,
+ 57.75718% 53.01981%,
+ 57.75713% 53.37763%,
+ 57.75699% 53.81831%,
+ 57.75679% 54.31106%,
+ 57.75657% 54.82507%,
+ 57.75635% 55.32958%,
+ 57.75615% 55.79377%,
+ 57.75601% 56.18684%,
+ 57.75596% 56.47801%,
+ 57.7549% 56.50122%,
+ 57.74034% 56.5624%,
+ 57.6955% 56.64887%,
+ 57.60334% 56.748%,
+ 57.44691% 56.84712%,
+ 57.20925% 56.93358%,
+ 56.87342% 56.99471%
+ );
+ }
+
+ &.two {
+ clip-path: polygon(
+ 56.42249% 42.44625%,
+ 54.93283% 42.44637%,
+ 53.00511% 42.44649%,
+ 50.83554% 42.4466%,
+ 48.62036% 42.4467%,
+ 46.55585% 42.44679%,
+ 44.83822% 42.44685%,
+ 43.66373% 42.4469%,
+ 43.22863% 42.44691%,
+ 42.86372% 42.44483%,
+ 42.56988% 42.44767%,
+ 42.3402% 42.46902%,
+ 42.16778% 42.52235%,
+ 42.0457% 42.6212%,
+ 41.96705% 42.77909%,
+ 41.92493% 43.00956%,
+ 41.91246% 43.32611%,
+ 41.91258% 43.70105%,
+ 41.9129% 44.0933%,
+ 41.91335% 44.49631%,
+ 41.91387% 44.90355%,
+ 41.91439% 45.3085%,
+ 41.91485% 45.70462%,
+ 41.91517% 46.08537%,
+ 41.91529% 46.44422%,
+ 41.94275% 46.74032%,
+ 42.02117% 46.94735%,
+ 42.14465% 47.0806%,
+ 42.30727% 47.15534%,
+ 42.50308% 47.18688%,
+ 42.72619% 47.19047%,
+ 42.97065% 47.1814%,
+ 43.23056% 47.17497%,
+ 43.94949% 47.17491%,
+ 45.45083% 47.17476%,
+ 47.47445% 47.17455%,
+ 49.76027% 47.1743%,
+ 52.04818% 47.17406%,
+ 54.07805% 47.17384%,
+ 55.5898% 47.17369%,
+ 56.32332% 47.17363%,
+ 56.58221% 47.17571%,
+ 56.83726% 47.17439%,
+ 57.07897% 47.15795%,
+ 57.29794% 47.1149%,
+ 57.48468% 47.03359%,
+ 57.62978% 46.90242%,
+ 57.72375% 46.70977%,
+ 57.75718% 46.44406%,
+ 57.75713% 46.08625%,
+ 57.75699% 45.64557%,
+ 57.75679% 45.15282%,
+ 57.75657% 44.6388%,
+ 57.75635% 44.1343%,
+ 57.75615% 43.6701%,
+ 57.75601% 43.27703%,
+ 57.75596% 42.98586%,
+ 57.7549% 42.96265%,
+ 57.74034% 42.90148%,
+ 57.6955% 42.815%,
+ 57.60334% 42.71587%,
+ 57.44691% 42.61675%,
+ 57.20925% 42.53029%,
+ 56.87342% 42.46916%
+ );
+ }
}
}
diff --git a/src/scss/partials/_chat.scss b/src/scss/partials/_chat.scss
index b950e864..476fb16b 100644
--- a/src/scss/partials/_chat.scss
+++ b/src/scss/partials/_chat.scss
@@ -322,7 +322,7 @@
align-self: flex-end;
z-index: 2;
}
-
+
#btn-send {
color: #9e9e9e;
@@ -563,7 +563,7 @@
@include respond-to(handhelds) {
min-height: 46px;
padding: .5px .5rem;
- }
+ }
@include respond-to(esg-bottom) {
min-height: 46px;
@@ -1278,4 +1278,4 @@
border-bottom: 1px solid white;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss
index 5ab09e44..83d8123f 100644
--- a/src/scss/partials/_chatBubble.scss
+++ b/src/scss/partials/_chatBubble.scss
@@ -742,7 +742,7 @@ $bubble-margin: .25rem;
}
&-ico {
- font-size: 2.15rem;
+ font-size: 0;
@include respond-to(handhelds) {
margin-top: 1px;
@@ -792,11 +792,6 @@ $bubble-margin: .25rem;
} */
//}
- .tgico-largeplay:before {
- content: $tgico-largeplay;
- margin-right: -2px;
- }
-
/* @include respond-to(handhelds) {
.preloader-container .you-spin-me-round {
margin-top: 1px;
@@ -949,6 +944,10 @@ $bubble-margin: .25rem;
font-size: 34px;
line-height: 60px;
cursor: pointer;
+
+ @include respond-to(handhelds) {
+ line-height: unset;
+ }
}
&.is-edited.channel-post .time {
diff --git a/src/scss/partials/_rightSidebar.scss b/src/scss/partials/_rightSidebar.scss
index 6eb14c09..b1048076 100644
--- a/src/scss/partials/_rightSidebar.scss
+++ b/src/scss/partials/_rightSidebar.scss
@@ -434,8 +434,8 @@
@include respond-to(handhelds) {
width: 40px;
height: 40px;
- top: 9px;
- left: 2px;
+ top: 2px;
+ left: -12px;
}
@include respond-to(not-handhelds) {
@@ -466,10 +466,6 @@
&-ico {
width: 48px;
height: 48px;
-
- &.tgico-largeplay:before {
- margin-right: -1px;
- }
}
&-download {
@@ -483,8 +479,16 @@
}
}
- &-toggle, &-download {
- font-size: 1.9rem;
+ .part {
+ height: 112px;
+ width: 112px;
+ position: absolute;
+ background-color: white;
+
+ @include respond-to(handhelds) {
+ width: 100px;
+ height: 100px;
+ }
}
&-title {