From 3d6c42432e81c4b3c695ddfec197aee8de28be17 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 15 Apr 2022 15:09:21 +0300 Subject: [PATCH] Better monospace text --- src/components/appMediaPlaybackController.ts | 2 +- src/components/appMediaViewer.ts | 2 +- src/components/appMediaViewerBase.ts | 4 +- src/components/appMediaViewerNew.ts | 2 +- src/components/appNavigationController.ts | 2 +- src/components/appSearchSuper..ts | 4 +- src/components/appSelectPeers.ts | 2 +- src/components/audio.ts | 4 +- src/components/avatar.ts | 2 +- src/components/button.ts | 2 +- src/components/buttonMenu.ts | 4 +- src/components/buttonMenuToggle.ts | 2 +- src/components/call/button.ts | 2 +- src/components/chat/audio.ts | 2 +- src/components/chat/bubbles.ts | 8 +- src/components/chat/chat.ts | 2 +- src/components/chat/contextMenu.ts | 2 +- src/components/chat/input.ts | 2 +- src/components/chat/markupTooltip.ts | 2 +- src/components/chat/pinnedContainer.ts | 4 +- src/components/chat/pinnedMessage.ts | 2 +- src/components/chat/replies.ts | 2 +- src/components/chat/replyKeyboard.ts | 2 +- src/components/chat/search.ts | 4 +- src/components/chat/selection.ts | 2 +- src/components/chat/sendContextMenu.ts | 2 +- src/components/chat/topbar.ts | 2 +- src/components/checkboxField.ts | 2 +- src/components/connectionStatus.ts | 2 +- src/components/emoticonsDropdown/index.ts | 4 +- .../emoticonsDropdown/tabs/emoji.ts | 4 +- src/components/gifsMasonry.ts | 2 +- src/components/groupCall/participants.ts | 2 +- src/components/languageChangeButton.ts | 7 +- src/components/misc.ts | 2 +- src/components/passwordInputField.ts | 2 +- src/components/peerProfileAvatars.ts | 2 +- src/components/poll.ts | 4 +- src/components/popups/createPoll.ts | 2 +- src/components/popups/index.ts | 4 +- src/components/preloader.ts | 2 +- src/components/ripple.ts | 4 +- src/components/row.ts | 2 +- src/components/scrollable.ts | 2 +- src/components/sidebarLeft/index.ts | 2 +- src/components/sidebarLeft/tabs/2fa/email.ts | 2 +- .../sidebarLeft/tabs/2fa/enterPassword.ts | 2 +- src/components/sidebarLeft/tabs/2fa/hint.ts | 2 +- .../sidebarLeft/tabs/2fa/reEnterPassword.ts | 2 +- src/components/sidebarLeft/tabs/background.ts | 2 +- .../sidebarLeft/tabs/chatFolders.ts | 2 +- .../sidebarRight/tabs/pollResults.ts | 2 +- src/components/swipeHandler.ts | 2 +- src/components/topbarCall.ts | 2 +- src/components/transition.ts | 4 +- src/components/wrappers.ts | 4 +- src/helpers/animation.ts | 2 +- src/helpers/cancellablePromise.ts | 4 +- src/helpers/dom/anchorCopy.ts | 2 +- src/helpers/dom/attachListNavigation.ts | 2 +- src/helpers/dom/cancelEvent.ts | 2 +- src/helpers/dom/handleHorizontalSwipe.ts | 2 +- src/helpers/dom/loadFonts.ts | 59 +- src/helpers/dom/lockTouchScroll.ts | 2 +- src/helpers/dom/toggleAttributePolyfill.ts | 18 + src/helpers/files.ts | 2 +- src/helpers/heavyQueue.ts | 2 +- src/helpers/schedulers/pause.ts | 8 +- src/helpers/sequentialDom.ts | 2 +- src/helpers/setWorkerProxy.ts | 20 + src/hooks/useHeavyAnimationCheck.ts | 4 +- src/index.ts | 565 ++++++++---------- src/lib/appManagers/appDialogsManager.ts | 2 +- src/lib/appManagers/appDownloadManager.ts | 2 +- src/lib/appManagers/appImManager.ts | 4 +- src/lib/appManagers/appMessagesManager.ts | 2 +- .../appManagers/appNotificationsManager.ts | 2 +- src/lib/appManagers/appUsersManager.ts | 2 +- src/lib/mediaPlayer.ts | 2 +- src/lib/mtproto/apiFileManager.ts | 2 +- src/lib/mtproto/apiManager.ts | 4 +- src/lib/mtproto/mtprotoworker.ts | 2 +- src/lib/mtproto/networker.ts | 4 +- src/lib/mtproto/transports/controller.ts | 4 +- src/lib/mtproto/transports/http.ts | 2 +- src/lib/rlottie/lottieLoader.ts | 2 +- src/lib/rootScope.ts | 1 - src/lib/serviceWorker/cache.ts | 2 +- src/lib/serviceWorker/stream.ts | 2 +- src/lib/storage.ts | 2 +- src/lib/webp/webpWorkerController.ts | 2 +- src/pages/pageIm.ts | 6 - src/pages/pagePassword.ts | 2 +- src/pages/pageSignIn.ts | 4 +- src/pages/pageSignQR.ts | 2 +- 95 files changed, 448 insertions(+), 456 deletions(-) create mode 100644 src/helpers/dom/toggleAttributePolyfill.ts create mode 100644 src/helpers/setWorkerProxy.ts diff --git a/src/components/appMediaPlaybackController.ts b/src/components/appMediaPlaybackController.ts index ee8745ca..ca720cc4 100644 --- a/src/components/appMediaPlaybackController.ts +++ b/src/components/appMediaPlaybackController.ts @@ -7,7 +7,7 @@ import rootScope from "../lib/rootScope"; import appMessagesManager from "../lib/appManagers/appMessagesManager"; import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager"; -import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../helpers/cancellablePromise"; import { IS_APPLE, IS_SAFARI } from "../environment/userAgent"; import { MOUNT_CLASS_TO } from "../config/debug"; import appDownloadManager from "../lib/appManagers/appDownloadManager"; diff --git a/src/components/appMediaViewer.ts b/src/components/appMediaViewer.ts index dcb33cce..0ba9c7ce 100644 --- a/src/components/appMediaViewer.ts +++ b/src/components/appMediaViewer.ts @@ -5,7 +5,7 @@ */ import MEDIA_MIME_TYPES_SUPPORTED from "../environment/mediaMimeTypesSupport"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent, detachClickEvent } from "../helpers/dom/clickEvent"; import setInnerHTML from "../helpers/dom/setInnerHTML"; import mediaSizes from "../helpers/mediaSizes"; diff --git a/src/components/appMediaViewerBase.ts b/src/components/appMediaViewerBase.ts index 38c6791c..db3dfb0b 100644 --- a/src/components/appMediaViewerBase.ts +++ b/src/components/appMediaViewerBase.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise from "../helpers/cancellablePromise"; import mediaSizes from "../helpers/mediaSizes"; import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import { IS_MOBILE_SAFARI, IS_SAFARI } from "../environment/userAgent"; @@ -29,7 +29,7 @@ import findUpClassName from "../helpers/dom/findUpClassName"; import renderImageFromUrl, { renderImageFromUrlPromise } from "../helpers/dom/renderImageFromUrl"; import getVisibleRect from "../helpers/dom/getVisibleRect"; import appDownloadManager from "../lib/appManagers/appDownloadManager"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import fillPropertyValue from "../helpers/fillPropertyValue"; import generatePathData from "../helpers/generatePathData"; import replaceContent from "../helpers/dom/replaceContent"; diff --git a/src/components/appMediaViewerNew.ts b/src/components/appMediaViewerNew.ts index 66d51c18..b3e7c6a6 100644 --- a/src/components/appMediaViewerNew.ts +++ b/src/components/appMediaViewerNew.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -// import { deferredPromise } from "../helpers/cancellablePromise"; +// import deferredPromise from "../helpers/cancellablePromise"; // import mediaSizes from "../helpers/mediaSizes"; // import { isTouchSupported } from "../helpers/touchSupport"; // import { isSafari } from "../helpers/userAgent"; diff --git a/src/components/appNavigationController.ts b/src/components/appNavigationController.ts index 1649aa28..d09b909a 100644 --- a/src/components/appNavigationController.ts +++ b/src/components/appNavigationController.ts @@ -8,7 +8,7 @@ import { MOUNT_CLASS_TO } from "../config/debug"; import { IS_MOBILE_SAFARI } from "../environment/userAgent"; import { logger } from "../lib/logger"; import blurActiveElement from "../helpers/dom/blurActiveElement"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import isSwipingBackSafari from "../helpers/dom/isSwipingBackSafari"; import indexOfAndSplice from "../helpers/array/indexOfAndSplice"; diff --git a/src/components/appSearchSuper..ts b/src/components/appSearchSuper..ts index 7ea5a275..bb48f26f 100644 --- a/src/components/appSearchSuper..ts +++ b/src/components/appSearchSuper..ts @@ -18,7 +18,7 @@ import { SearchGroup, SearchGroupType } from "./appSearch"; import { horizontalMenu } from "./horizontalMenu"; import LazyLoadQueue from "./lazyLoadQueue"; import { attachContextMenuListener, openBtnMenu, positionMenu, putPreloader } from "./misc"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; import Scrollable, { ScrollableX } from "./scrollable"; import { wrapDocument, wrapPhoto, wrapVideo } from "./wrappers"; import useHeavyAnimationCheck, { getHeavyAnimationPromise } from "../hooks/useHeavyAnimationCheck"; @@ -44,7 +44,7 @@ import PopupDeleteMessages from "./popups/deleteMessages"; import Row from "./row"; import htmlToDocumentFragment from "../helpers/dom/htmlToDocumentFragment"; import { SearchSelection } from "./chat/selection"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent, simulateClickEvent } from "../helpers/dom/clickEvent"; import { MyDocument } from "../lib/appManagers/appDocsManager"; import AppMediaViewer from "./appMediaViewer"; diff --git a/src/components/appSelectPeers.ts b/src/components/appSelectPeers.ts index 14ce8844..bb18b5fa 100644 --- a/src/components/appSelectPeers.ts +++ b/src/components/appSelectPeers.ts @@ -17,7 +17,7 @@ import { i18n, LangPackKey, _i18n } from "../lib/langPack"; import findUpAttribute from "../helpers/dom/findUpAttribute"; import findUpClassName from "../helpers/dom/findUpClassName"; import PeerTitle from "./peerTitle"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import replaceContent from "../helpers/dom/replaceContent"; import debounce from "../helpers/schedulers/debounce"; import windowSize from "../helpers/windowSize"; diff --git a/src/components/audio.ts b/src/components/audio.ts index dfa47842..727b50ff 100644 --- a/src/components/audio.ts +++ b/src/components/audio.ts @@ -15,10 +15,10 @@ import { IS_SAFARI } from "../environment/userAgent"; import appMessagesManager from "../lib/appManagers/appMessagesManager"; import rootScope from "../lib/rootScope"; import './middleEllipsis'; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import LazyLoadQueue from "./lazyLoadQueue"; -import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../helpers/cancellablePromise"; import ListenerSetter, { Listener } from "../helpers/listenerSetter"; import noop from "../helpers/noop"; import findUpClassName from "../helpers/dom/findUpClassName"; diff --git a/src/components/avatar.ts b/src/components/avatar.ts index f1a46216..b1ad4db2 100644 --- a/src/components/avatar.ts +++ b/src/components/avatar.ts @@ -12,7 +12,7 @@ import appPeersManager from "../lib/appManagers/appPeersManager"; import appPhotosManager from "../lib/appManagers/appPhotosManager"; import type { LazyLoadQueueIntersector } from "./lazyLoadQueue"; import { attachClickEvent } from "../helpers/dom/clickEvent"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import appAvatarsManager from "../lib/appManagers/appAvatarsManager"; import AppMediaViewer from "./appMediaViewer"; import AppMediaViewerAvatar from "./appMediaViewerAvatar"; diff --git a/src/components/button.ts b/src/components/button.ts index 75ba4eed..bb1e252b 100644 --- a/src/components/button.ts +++ b/src/components/button.ts @@ -5,7 +5,7 @@ */ import { i18n, LangPackKey } from "../lib/langPack"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; export type ButtonOptions = Partial<{ noRipple: true, diff --git a/src/components/buttonMenu.ts b/src/components/buttonMenu.ts index da358d31..6b4a2ce5 100644 --- a/src/components/buttonMenu.ts +++ b/src/components/buttonMenu.ts @@ -4,13 +4,13 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { AttachClickOptions, attachClickEvent, CLICK_EVENT_NAME } from "../helpers/dom/clickEvent"; import ListenerSetter from "../helpers/listenerSetter"; import { FormatterArguments, i18n, LangPackKey } from "../lib/langPack"; import CheckboxField from "./checkboxField"; import { closeBtnMenu } from "./misc"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; export type ButtonMenuItemOptions = { icon?: string, diff --git a/src/components/buttonMenuToggle.ts b/src/components/buttonMenuToggle.ts index 1a334754..abc09839 100644 --- a/src/components/buttonMenuToggle.ts +++ b/src/components/buttonMenuToggle.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { AttachClickOptions, CLICK_EVENT_NAME } from "../helpers/dom/clickEvent"; import ListenerSetter from "../helpers/listenerSetter"; import ButtonIcon from "./buttonIcon"; diff --git a/src/components/call/button.ts b/src/components/call/button.ts index 1f162457..4491c781 100644 --- a/src/components/call/button.ts +++ b/src/components/call/button.ts @@ -7,7 +7,7 @@ import { attachClickEvent } from "../../helpers/dom/clickEvent"; import ListenerSetter from "../../helpers/listenerSetter"; import { i18n, LangPackKey } from "../../lib/langPack"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; export default function makeButton(className: string, listenerSetter: ListenerSetter, options: { text?: LangPackKey | HTMLElement, diff --git a/src/components/chat/audio.ts b/src/components/chat/audio.ts index c015fcda..7b0b343d 100644 --- a/src/components/chat/audio.ts +++ b/src/components/chat/audio.ts @@ -11,7 +11,7 @@ import appMediaPlaybackController, { AppMediaPlaybackController } from "../appMe import DivAndCaption from "../divAndCaption"; import PinnedContainer from "./pinnedContainer"; import Chat from "./chat"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../helpers/dom/clickEvent"; import replaceContent from "../../helpers/dom/replaceContent"; import PeerTitle from "../peerTitle"; diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 117756ea..5e98781f 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -34,7 +34,7 @@ import mediaSizes from "../../helpers/mediaSizes"; import { IS_ANDROID, IS_APPLE, IS_MOBILE, IS_SAFARI } from "../../environment/userAgent"; import I18n, { FormatterArguments, i18n, langPack, LangPackKey, UNSUPPORTED_LANG_PACK_KEY, _i18n } from "../../lib/langPack"; import AvatarElement from "../avatar"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import { wrapAlbum, wrapPhoto, wrapVideo, wrapDocument, wrapSticker, wrapPoll, wrapGroupedDocuments } from "../wrappers"; import { MessageRender } from "./messageRender"; import LazyLoadQueue from "../lazyLoadQueue"; @@ -46,7 +46,7 @@ import { NULL_PEER_ID, REPLIES_PEER_ID } from "../../lib/mtproto/mtproto_config" import { FocusDirection, ScrollStartCallbackDimensions } from "../../helpers/fastSmoothScroll"; import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent, interruptHeavyAnimation } from "../../hooks/useHeavyAnimationCheck"; import { fastRaf, fastRafPromise } from "../../helpers/schedulers"; -import { deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise from "../../helpers/cancellablePromise"; import RepliesElement from "./replies"; import DEBUG from "../../config/debug"; import { SliceEnd } from "../../helpers/slicedArray"; @@ -57,7 +57,7 @@ import findUpTag from "../../helpers/dom/findUpTag"; import { toast } from "../toast"; import { getElementByPoint } from "../../helpers/dom/getElementByPoint"; import { getMiddleware } from "../../helpers/middleware"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent, simulateClickEvent } from "../../helpers/dom/clickEvent"; import htmlToDocumentFragment from "../../helpers/dom/htmlToDocumentFragment"; import positionElementByIndex from "../../helpers/dom/positionElementByIndex"; @@ -89,7 +89,7 @@ import ReactionsElement, { REACTIONS_ELEMENTS } from "./reactions"; import type ReactionElement from "./reaction"; import type { AppReactionsManager } from "../../lib/appManagers/appReactionsManager"; import RLottiePlayer from "../../lib/rlottie/rlottiePlayer"; -import { pause } from "../../helpers/schedulers/pause"; +import pause from "../../helpers/schedulers/pause"; import ScrollSaver from "../../helpers/scrollSaver"; import getObjectKeysAndSort from "../../helpers/object/getObjectKeysAndSort"; import forEachReverse from "../../helpers/array/forEachReverse"; diff --git a/src/components/chat/chat.ts b/src/components/chat/chat.ts index 914ea7d4..467d5e04 100644 --- a/src/components/chat/chat.ts +++ b/src/components/chat/chat.ts @@ -44,7 +44,7 @@ import { IS_TOUCH_SUPPORTED } from "../../environment/touchSupport"; import getAutoDownloadSettingsByPeerId, { ChatAutoDownloadSettings } from "../../helpers/autoDownload"; import ChatBackgroundGradientRenderer from "./gradientRenderer"; import ChatBackgroundPatternRenderer from "./patternRenderer"; -import { pause } from "../../helpers/schedulers/pause"; +import pause from "../../helpers/schedulers/pause"; export type ChatType = 'chat' | 'pinned' | 'replies' | 'discussion' | 'scheduled'; diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index 085314c4..f4789d67 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -22,7 +22,7 @@ import PopupSendNow from "../popups/sendNow"; import { toast } from "../toast"; import I18n, { i18n, LangPackKey } from "../../lib/langPack"; import findUpClassName from "../../helpers/dom/findUpClassName"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent, simulateClickEvent } from "../../helpers/dom/clickEvent"; import isSelectionEmpty from "../../helpers/dom/isSelectionEmpty"; import { Message, Poll, Chat as MTChat, MessageMedia, AvailableReaction } from "../../layer"; diff --git a/src/components/chat/input.ts b/src/components/chat/input.ts index 83306f07..bc7de791 100644 --- a/src/components/chat/input.ts +++ b/src/components/chat/input.ts @@ -50,7 +50,7 @@ import { generateTail } from './bubbles'; import findUpClassName from '../../helpers/dom/findUpClassName'; import ButtonCorner from '../buttonCorner'; import blurActiveElement from '../../helpers/dom/blurActiveElement'; -import { cancelEvent } from '../../helpers/dom/cancelEvent'; +import cancelEvent from '../../helpers/dom/cancelEvent'; import cancelSelection from '../../helpers/dom/cancelSelection'; import { attachClickEvent, simulateClickEvent } from '../../helpers/dom/clickEvent'; import getRichValue from '../../helpers/dom/getRichValue'; diff --git a/src/components/chat/markupTooltip.ts b/src/components/chat/markupTooltip.ts index 7c7ff924..b10c7ff4 100644 --- a/src/components/chat/markupTooltip.ts +++ b/src/components/chat/markupTooltip.ts @@ -11,7 +11,7 @@ import { IS_TOUCH_SUPPORTED } from "../../environment/touchSupport"; import { IS_APPLE, IS_MOBILE } from "../../environment/userAgent"; import appNavigationController from "../appNavigationController"; import { _i18n } from "../../lib/langPack"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../helpers/dom/clickEvent"; import getSelectedNodes from "../../helpers/dom/getSelectedNodes"; import isSelectionEmpty from "../../helpers/dom/isSelectionEmpty"; diff --git a/src/components/chat/pinnedContainer.ts b/src/components/chat/pinnedContainer.ts index 3ec5b2f7..60f47e47 100644 --- a/src/components/chat/pinnedContainer.ts +++ b/src/components/chat/pinnedContainer.ts @@ -8,9 +8,9 @@ import type Chat from "./chat"; import type ChatTopbar from "./topbar"; import mediaSizes from "../../helpers/mediaSizes"; import DivAndCaption from "../divAndCaption"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import ListenerSetter from "../../helpers/listenerSetter"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../helpers/dom/clickEvent"; import { Message } from "../../layer"; import safeAssign from "../../helpers/object/safeAssign"; diff --git a/src/components/chat/pinnedMessage.ts b/src/components/chat/pinnedMessage.ts index 1cb3c56e..82d8d044 100644 --- a/src/components/chat/pinnedMessage.ts +++ b/src/components/chat/pinnedMessage.ts @@ -17,7 +17,7 @@ import ListenerSetter from "../../helpers/listenerSetter"; import ButtonIcon from "../buttonIcon"; import { getHeavyAnimationPromise } from "../../hooks/useHeavyAnimationCheck"; import { i18n } from "../../lib/langPack"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../helpers/dom/clickEvent"; import handleScrollSideEvent from "../../helpers/dom/handleScrollSideEvent"; import debounce from "../../helpers/schedulers/debounce"; diff --git a/src/components/chat/replies.ts b/src/components/chat/replies.ts index 151ec6f0..db6a7892 100644 --- a/src/components/chat/replies.ts +++ b/src/components/chat/replies.ts @@ -9,7 +9,7 @@ import { Message } from "../../layer"; import appMessagesManager from "../../lib/appManagers/appMessagesManager"; import appPeersManager from "../../lib/appManagers/appPeersManager"; import rootScope from "../../lib/rootScope"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import I18n from "../../lib/langPack"; import replaceContent from "../../helpers/dom/replaceContent"; import StackedAvatars from "../stackedAvatars"; diff --git a/src/components/chat/replyKeyboard.ts b/src/components/chat/replyKeyboard.ts index 5af78f66..ea7a90f6 100644 --- a/src/components/chat/replyKeyboard.ts +++ b/src/components/chat/replyKeyboard.ts @@ -14,7 +14,7 @@ import ListenerSetter, { Listener } from "../../helpers/listenerSetter"; import findUpClassName from "../../helpers/dom/findUpClassName"; import { IS_TOUCH_SUPPORTED } from "../../environment/touchSupport"; import findUpAsChild from "../../helpers/dom/findUpAsChild"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { getHeavyAnimationPromise } from "../../hooks/useHeavyAnimationCheck"; import confirmationPopup from "../confirmationPopup"; import safeAssign from "../../helpers/object/safeAssign"; diff --git a/src/components/chat/search.ts b/src/components/chat/search.ts index 7e49d8be..c6e35931 100644 --- a/src/components/chat/search.ts +++ b/src/components/chat/search.ts @@ -7,11 +7,11 @@ import type ChatTopbar from "./topbar"; import AppSearch, { SearchGroup } from "../appSearch"; import PopupDatePicker from "../popups/datePicker"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import InputSearch from "../inputSearch"; import type Chat from "./chat"; import findUpTag from "../../helpers/dom/findUpTag"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import whichChild from "../../helpers/dom/whichChild"; import replaceContent from "../../helpers/dom/replaceContent"; import { i18n } from "../../lib/langPack"; diff --git a/src/components/chat/selection.ts b/src/components/chat/selection.ts index d7646cda..55fee83e 100644 --- a/src/components/chat/selection.ts +++ b/src/components/chat/selection.ts @@ -23,7 +23,7 @@ import { IS_MOBILE_SAFARI } from "../../environment/userAgent"; import I18n, { i18n, _i18n } from "../../lib/langPack"; import findUpClassName from "../../helpers/dom/findUpClassName"; import blurActiveElement from "../../helpers/dom/blurActiveElement"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import cancelSelection from "../../helpers/dom/cancelSelection"; import getSelectedText from "../../helpers/dom/getSelectedText"; import rootScope from "../../lib/rootScope"; diff --git a/src/components/chat/sendContextMenu.ts b/src/components/chat/sendContextMenu.ts index 7d0b33f1..46f8d568 100644 --- a/src/components/chat/sendContextMenu.ts +++ b/src/components/chat/sendContextMenu.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import ListenerSetter from "../../helpers/listenerSetter"; import rootScope from "../../lib/rootScope"; import ButtonMenu, { ButtonMenuItemOptions } from "../buttonMenu"; diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index 34ab69d5..e82ba2d0 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -33,7 +33,7 @@ import PeerTitle from "../peerTitle"; import { i18n } from "../../lib/langPack"; import findUpClassName from "../../helpers/dom/findUpClassName"; import blurActiveElement from "../../helpers/dom/blurActiveElement"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../helpers/dom/clickEvent"; import findUpTag from "../../helpers/dom/findUpTag"; import { toast, toastNew } from "../toast"; diff --git a/src/components/checkboxField.ts b/src/components/checkboxField.ts index 49b836e7..0522ae65 100644 --- a/src/components/checkboxField.ts +++ b/src/components/checkboxField.ts @@ -5,7 +5,7 @@ */ import appStateManager from "../lib/appManagers/appStateManager"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; import { LangPackKey, _i18n } from "../lib/langPack"; import getDeepProperty from "../helpers/object/getDeepProperty"; diff --git a/src/components/connectionStatus.ts b/src/components/connectionStatus.ts index cd7242b9..20b946e2 100644 --- a/src/components/connectionStatus.ts +++ b/src/components/connectionStatus.ts @@ -16,7 +16,7 @@ import ProgressivePreloader from "./preloader"; import SetTransition from "./singleTransition"; import sessionStorage from '../lib/sessionStorage'; import { ConnectionStatus } from "../lib/mtproto/connectionStatus"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import apiManager from "../lib/mtproto/mtprotoworker"; import { attachClickEvent } from "../helpers/dom/clickEvent"; diff --git a/src/components/emoticonsDropdown/index.ts b/src/components/emoticonsDropdown/index.ts index bb40f133..98e0a946 100644 --- a/src/components/emoticonsDropdown/index.ts +++ b/src/components/emoticonsDropdown/index.ts @@ -23,9 +23,9 @@ import findUpClassName from "../../helpers/dom/findUpClassName"; import findUpTag from "../../helpers/dom/findUpTag"; import blurActiveElement from "../../helpers/dom/blurActiveElement"; import whichChild from "../../helpers/dom/whichChild"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import DropdownHover from "../../helpers/dropdownHover"; -import { pause } from "../../helpers/schedulers/pause"; +import pause from "../../helpers/schedulers/pause"; import appMessagesManager from "../../lib/appManagers/appMessagesManager"; import { IS_APPLE_MOBILE } from "../../environment/userAgent"; diff --git a/src/components/emoticonsDropdown/tabs/emoji.ts b/src/components/emoticonsDropdown/tabs/emoji.ts index f0d19213..decdc342 100644 --- a/src/components/emoticonsDropdown/tabs/emoji.ts +++ b/src/components/emoticonsDropdown/tabs/emoji.ts @@ -5,10 +5,10 @@ */ import emoticonsDropdown, { EmoticonsDropdown, EmoticonsTab } from ".."; -import { cancelEvent } from "../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../helpers/dom/cancelEvent"; import findUpClassName from "../../../helpers/dom/findUpClassName"; import { fastRaf } from "../../../helpers/schedulers"; -import { pause } from "../../../helpers/schedulers/pause"; +import pause from "../../../helpers/schedulers/pause"; import appEmojiManager from "../../../lib/appManagers/appEmojiManager"; import appImManager from "../../../lib/appManagers/appImManager"; import { i18n, LangPackKey } from "../../../lib/langPack"; diff --git a/src/components/gifsMasonry.ts b/src/components/gifsMasonry.ts index 9ffb4792..463f9878 100644 --- a/src/components/gifsMasonry.ts +++ b/src/components/gifsMasonry.ts @@ -9,7 +9,7 @@ import { wrapVideo } from "./wrappers"; import { LazyLoadQueueRepeat2 } from "./lazyLoadQueue"; import animationIntersector from "./animationIntersector"; import Scrollable from "./scrollable"; -import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../helpers/cancellablePromise"; import renderImageFromUrl from "../helpers/dom/renderImageFromUrl"; import calcImageInBox from "../helpers/calcImageInBox"; import { doubleRaf } from "../helpers/schedulers"; diff --git a/src/components/groupCall/participants.ts b/src/components/groupCall/participants.ts index 7b94d786..bf022cdf 100644 --- a/src/components/groupCall/participants.ts +++ b/src/components/groupCall/participants.ts @@ -5,7 +5,7 @@ */ import PopupGroupCall from "."; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import findUpClassName from "../../helpers/dom/findUpClassName"; import { addFullScreenListener, isFullScreen } from "../../helpers/dom/fullScreen"; import ListenerSetter from "../../helpers/listenerSetter"; diff --git a/src/components/languageChangeButton.ts b/src/components/languageChangeButton.ts index 5fd2fa59..b9029f08 100644 --- a/src/components/languageChangeButton.ts +++ b/src/components/languageChangeButton.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import loadFonts from "../helpers/dom/loadFonts"; import { Config, LangPackDifference, LangPackString } from "../layer"; @@ -53,9 +53,10 @@ export default function getLanguageChangeButton(appendTo: HTMLElement) { I18n.strings.set(string.key as LangPackKey, string); }); - const btnChangeLanguage = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Login.ContinueOnLanguage'}); + const key: LangPackKey = 'Login.ContinueOnLanguage'; + const btnChangeLanguage = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: key}); btnChangeLanguage.lastElementChild.classList.remove('i18n'); // prevent changing language - loadFonts().then(() => { + loadFonts({text: [I18n.format(key, true)]}).then(() => { window.requestAnimationFrame(() => { appendTo.append(btnChangeLanguage); }); diff --git a/src/components/misc.ts b/src/components/misc.ts index 42211adc..a93dfa5c 100644 --- a/src/components/misc.ts +++ b/src/components/misc.ts @@ -5,7 +5,7 @@ */ import { MOUNT_CLASS_TO } from "../config/debug"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { CLICK_EVENT_NAME } from "../helpers/dom/clickEvent"; import ListenerSetter from "../helpers/listenerSetter"; import mediaSizes from "../helpers/mediaSizes"; diff --git a/src/components/passwordInputField.ts b/src/components/passwordInputField.ts index ff6cb370..6539a048 100644 --- a/src/components/passwordInputField.ts +++ b/src/components/passwordInputField.ts @@ -5,7 +5,7 @@ */ // import { IS_MOBILE_SAFARI, IS_SAFARI } from "../environment/userAgent"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import InputField, { InputFieldOptions } from "./inputField"; export default class PasswordInputField extends InputField { diff --git a/src/components/peerProfileAvatars.ts b/src/components/peerProfileAvatars.ts index 0e6aff20..7a1132fc 100644 --- a/src/components/peerProfileAvatars.ts +++ b/src/components/peerProfileAvatars.ts @@ -7,7 +7,7 @@ import IS_PARALLAX_SUPPORTED from "../environment/parallaxSupport"; import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import findAndSplice from "../helpers/array/findAndSplice"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import filterChatPhotosMessages from "../helpers/filterChatPhotosMessages"; import ListenerSetter from "../helpers/listenerSetter"; diff --git a/src/components/poll.ts b/src/components/poll.ts index ed4c38f2..5a26dfdc 100644 --- a/src/components/poll.ts +++ b/src/components/poll.ts @@ -11,14 +11,14 @@ import appPollsManager from "../lib/appManagers/appPollsManager"; import serverTimeManager from "../lib/mtproto/serverTimeManager"; import { RichTextProcessor } from "../lib/richtextprocessor"; import rootScope from "../lib/rootScope"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; import appSidebarRight from "./sidebarRight"; import AppPollResultsTab from "./sidebarRight/tabs/pollResults"; import { i18n, LangPackKey } from "../lib/langPack"; import { fastRaf } from "../helpers/schedulers"; import SetTransition from "./singleTransition"; import findUpClassName from "../helpers/dom/findUpClassName"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent, detachClickEvent } from "../helpers/dom/clickEvent"; import replaceContent from "../helpers/dom/replaceContent"; import windowSize from "../helpers/windowSize"; diff --git a/src/components/popups/createPoll.ts b/src/components/popups/createPoll.ts index 6645d46a..5499dda8 100644 --- a/src/components/popups/createPoll.ts +++ b/src/components/popups/createPoll.ts @@ -13,7 +13,7 @@ import Scrollable from "../scrollable"; import SendContextMenu from "../chat/sendContextMenu"; import I18n, { _i18n } from "../../lib/langPack"; import findUpTag from "../../helpers/dom/findUpTag"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import getRichValue from "../../helpers/dom/getRichValue"; import isInputEmpty from "../../helpers/dom/isInputEmpty"; import whichChild from "../../helpers/dom/whichChild"; diff --git a/src/components/popups/index.ts b/src/components/popups/index.ts index 2e7f22a4..25dc67ef 100644 --- a/src/components/popups/index.ts +++ b/src/components/popups/index.ts @@ -5,7 +5,7 @@ */ import rootScope from "../../lib/rootScope"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import animationIntersector from "../animationIntersector"; import appNavigationController, { NavigationItem } from "../appNavigationController"; import { i18n, LangPackKey } from "../../lib/langPack"; @@ -14,7 +14,7 @@ import blurActiveElement from "../../helpers/dom/blurActiveElement"; import ListenerSetter from "../../helpers/listenerSetter"; import { attachClickEvent, simulateClickEvent } from "../../helpers/dom/clickEvent"; import isSendShortcutPressed from "../../helpers/dom/isSendShortcutPressed"; -import { cancelEvent } from "../../helpers/dom/cancelEvent"; +import cancelEvent from "../../helpers/dom/cancelEvent"; import EventListenerBase, { EventListenerListeners } from "../../helpers/eventListenerBase"; import { addFullScreenListener, getFullScreenElement } from "../../helpers/dom/fullScreen"; import indexOfAndSplice from "../../helpers/array/indexOfAndSplice"; diff --git a/src/components/preloader.ts b/src/components/preloader.ts index cff973d8..ca05693c 100644 --- a/src/components/preloader.ts +++ b/src/components/preloader.ts @@ -7,7 +7,7 @@ import { CancellablePromise } from "../helpers/cancellablePromise"; import SetTransition from "./singleTransition"; import { fastRaf } from "../helpers/schedulers"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import isInDOM from "../helpers/dom/isInDOM"; import safeAssign from "../helpers/object/safeAssign"; diff --git a/src/components/ripple.ts b/src/components/ripple.ts index a663c1b7..634a8f7b 100644 --- a/src/components/ripple.ts +++ b/src/components/ripple.ts @@ -6,12 +6,12 @@ import findUpClassName from "../helpers/dom/findUpClassName"; import sequentialDom from "../helpers/sequentialDom"; -import {IS_TOUCH_SUPPORTED} from "../environment/touchSupport"; +import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import rootScope from "../lib/rootScope"; import findUpAsChild from "../helpers/dom/findUpAsChild"; let rippleClickId = 0; -export function ripple( +export default function ripple( elem: HTMLElement, callback: (id: number) => Promise = () => Promise.resolve(), onEnd: (id: number) => void = null, diff --git a/src/components/row.ts b/src/components/row.ts index 51a23668..11a70afa 100644 --- a/src/components/row.ts +++ b/src/components/row.ts @@ -6,7 +6,7 @@ import CheckboxField from "./checkboxField"; import RadioField from "./radioField"; -import { ripple } from "./ripple"; +import ripple from "./ripple"; import { SliderSuperTab } from "./slider"; import RadioForm from "./radioForm"; import { i18n, LangPackKey } from "../lib/langPack"; diff --git a/src/components/scrollable.ts b/src/components/scrollable.ts index 2ad18203..61ac3f4c 100644 --- a/src/components/scrollable.ts +++ b/src/components/scrollable.ts @@ -8,7 +8,7 @@ import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import { logger, LogTypes } from "../lib/logger"; import fastSmoothScroll, { ScrollOptions } from "../helpers/fastSmoothScroll"; import useHeavyAnimationCheck from "../hooks/useHeavyAnimationCheck"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; /* var el = $0; var height = 0; diff --git a/src/components/sidebarLeft/index.ts b/src/components/sidebarLeft/index.ts index c0f2e1f0..6faabf18 100644 --- a/src/components/sidebarLeft/index.ts +++ b/src/components/sidebarLeft/index.ts @@ -45,7 +45,7 @@ import IS_GEOLOCATION_SUPPORTED from "../../environment/geolocationSupport"; import type SortedUserList from "../sortedUserList"; import Button, { ButtonOptions } from "../button"; import noop from "../../helpers/noop"; -import { ripple } from "../ripple"; +import ripple from "../ripple"; import indexOfAndSplice from "../../helpers/array/indexOfAndSplice"; import formatNumber from "../../helpers/number/formatNumber"; import AvatarElement from "../avatar"; diff --git a/src/components/sidebarLeft/tabs/2fa/email.ts b/src/components/sidebarLeft/tabs/2fa/email.ts index f3732955..92ca731f 100644 --- a/src/components/sidebarLeft/tabs/2fa/email.ts +++ b/src/components/sidebarLeft/tabs/2fa/email.ts @@ -17,7 +17,7 @@ import AppTwoStepVerificationSetTab from "./passwordSet"; import AppTwoStepVerificationEmailConfirmationTab from "./emailConfirmation"; import RichTextProcessor from "../../../../lib/richtextprocessor"; import PopupPeer from "../../../popups/peer"; -import { cancelEvent } from "../../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../../helpers/dom/cancelEvent"; import { canFocus } from "../../../../helpers/dom/canFocus"; import { attachClickEvent } from "../../../../helpers/dom/clickEvent"; diff --git a/src/components/sidebarLeft/tabs/2fa/enterPassword.ts b/src/components/sidebarLeft/tabs/2fa/enterPassword.ts index 56e97e55..dfe830ba 100644 --- a/src/components/sidebarLeft/tabs/2fa/enterPassword.ts +++ b/src/components/sidebarLeft/tabs/2fa/enterPassword.ts @@ -6,7 +6,7 @@ import AppTwoStepVerificationTab from "."; import { SettingSection } from "../.."; -import { cancelEvent } from "../../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../../helpers/dom/cancelEvent"; import { canFocus } from "../../../../helpers/dom/canFocus"; import { attachClickEvent } from "../../../../helpers/dom/clickEvent"; import replaceContent from "../../../../helpers/dom/replaceContent"; diff --git a/src/components/sidebarLeft/tabs/2fa/hint.ts b/src/components/sidebarLeft/tabs/2fa/hint.ts index fa6967b5..dd730058 100644 --- a/src/components/sidebarLeft/tabs/2fa/hint.ts +++ b/src/components/sidebarLeft/tabs/2fa/hint.ts @@ -14,7 +14,7 @@ import InputField from "../../../inputField"; import AppTwoStepVerificationEmailTab from "./email"; import { toast } from "../../../toast"; import I18n from "../../../../lib/langPack"; -import { cancelEvent } from "../../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../../../helpers/dom/clickEvent"; export default class AppTwoStepVerificationHintTab extends SliderSuperTab { diff --git a/src/components/sidebarLeft/tabs/2fa/reEnterPassword.ts b/src/components/sidebarLeft/tabs/2fa/reEnterPassword.ts index bd600797..a2ee27ab 100644 --- a/src/components/sidebarLeft/tabs/2fa/reEnterPassword.ts +++ b/src/components/sidebarLeft/tabs/2fa/reEnterPassword.ts @@ -12,7 +12,7 @@ import { SliderSuperTab } from "../../../slider"; import TrackingMonkey from "../../../monkeys/tracking"; import AppTwoStepVerificationHintTab from "./hint"; import { InputState } from "../../../inputField"; -import { cancelEvent } from "../../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../../../helpers/dom/clickEvent"; export default class AppTwoStepVerificationReEnterPasswordTab extends SliderSuperTab { diff --git a/src/components/sidebarLeft/tabs/background.ts b/src/components/sidebarLeft/tabs/background.ts index 71bd6a6b..6b710c63 100644 --- a/src/components/sidebarLeft/tabs/background.ts +++ b/src/components/sidebarLeft/tabs/background.ts @@ -7,7 +7,7 @@ import { generateSection } from ".."; import { averageColor, averageColorFromCanvas } from "../../../helpers/averageColor"; import blur from "../../../helpers/blur"; -import { deferredPromise } from "../../../helpers/cancellablePromise"; +import deferredPromise from "../../../helpers/cancellablePromise"; import { attachClickEvent } from "../../../helpers/dom/clickEvent"; import findUpClassName from "../../../helpers/dom/findUpClassName"; import { requestFile } from "../../../helpers/files"; diff --git a/src/components/sidebarLeft/tabs/chatFolders.ts b/src/components/sidebarLeft/tabs/chatFolders.ts index 99311637..0963ea19 100644 --- a/src/components/sidebarLeft/tabs/chatFolders.ts +++ b/src/components/sidebarLeft/tabs/chatFolders.ts @@ -20,7 +20,7 @@ import AppEditFolderTab from "./editFolder"; import Row from "../../row"; import { SettingSection } from ".."; import { i18n, i18n_, LangPackKey, join } from "../../../lib/langPack"; -import { cancelEvent } from "../../../helpers/dom/cancelEvent"; +import cancelEvent from "../../../helpers/dom/cancelEvent"; import { attachClickEvent } from "../../../helpers/dom/clickEvent"; import positionElementByIndex from "../../../helpers/dom/positionElementByIndex"; import RLottiePlayer from "../../../lib/rlottie/rlottiePlayer"; diff --git a/src/components/sidebarRight/tabs/pollResults.ts b/src/components/sidebarRight/tabs/pollResults.ts index 1209b4e3..eee5a503 100644 --- a/src/components/sidebarRight/tabs/pollResults.ts +++ b/src/components/sidebarRight/tabs/pollResults.ts @@ -10,7 +10,7 @@ import appPollsManager from "../../../lib/appManagers/appPollsManager"; import { roundPercents } from "../../poll"; import { RichTextProcessor } from "../../../lib/richtextprocessor"; import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; -import { ripple } from "../../ripple"; +import ripple from "../../ripple"; import { i18n } from "../../../lib/langPack"; export default class AppPollResultsTab extends SliderSuperTab { diff --git a/src/components/swipeHandler.ts b/src/components/swipeHandler.ts index e98389a6..4aa55b12 100644 --- a/src/components/swipeHandler.ts +++ b/src/components/swipeHandler.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import rootScope from "../lib/rootScope"; import safeAssign from "../helpers/object/safeAssign"; diff --git a/src/components/topbarCall.ts b/src/components/topbarCall.ts index 66f4dfab..a54673bc 100644 --- a/src/components/topbarCall.ts +++ b/src/components/topbarCall.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import ListenerSetter from "../helpers/listenerSetter"; import type { AppGroupCallsManager } from "../lib/appManagers/appGroupCallsManager"; diff --git a/src/components/transition.ts b/src/components/transition.ts index 91489ce8..9db90c7b 100644 --- a/src/components/transition.ts +++ b/src/components/transition.ts @@ -5,10 +5,10 @@ */ import rootScope from "../lib/rootScope"; -import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../helpers/cancellablePromise"; import { dispatchHeavyAnimationEvent } from "../hooks/useHeavyAnimationCheck"; import whichChild from "../helpers/dom/whichChild"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; function slideNavigation(tabContent: HTMLElement, prevTabContent: HTMLElement, toRight: boolean) { const width = prevTabContent.getBoundingClientRect().width; diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index cc132814..f70c3ccc 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -6,7 +6,7 @@ import type Chat from './chat/chat'; import { getEmojiToneIndex } from '../vendor/emoji'; -import { deferredPromise } from '../helpers/cancellablePromise'; +import deferredPromise from '../helpers/cancellablePromise'; import { formatFullSentTime } from '../helpers/date'; import mediaSizes, { MediaSizeType, ScreenSize } from '../helpers/mediaSizes'; import { IS_SAFARI } from '../environment/userAgent'; @@ -35,7 +35,7 @@ import sequentialDom from '../helpers/sequentialDom'; import { fastRaf } from '../helpers/schedulers'; import appDownloadManager, { DownloadBlob, ThumbCache } from '../lib/appManagers/appDownloadManager'; import appStickersManager from '../lib/appManagers/appStickersManager'; -import { cancelEvent } from '../helpers/dom/cancelEvent'; +import cancelEvent from '../helpers/dom/cancelEvent'; import { attachClickEvent, simulateClickEvent } from '../helpers/dom/clickEvent'; import isInDOM from '../helpers/dom/isInDOM'; import lottieLoader from '../lib/rlottie/lottieLoader'; diff --git a/src/helpers/animation.ts b/src/helpers/animation.ts index da352535..490a6e2c 100644 --- a/src/helpers/animation.ts +++ b/src/helpers/animation.ts @@ -7,7 +7,7 @@ // * Jolly Cobra's animation.ts import { fastRaf } from './schedulers'; -import { CancellablePromise, deferredPromise } from './cancellablePromise'; +import deferredPromise, { CancellablePromise } from './cancellablePromise'; interface AnimationInstance { isCancelled: boolean; diff --git a/src/helpers/cancellablePromise.ts b/src/helpers/cancellablePromise.ts index 65f3c0c8..675d2c9a 100644 --- a/src/helpers/cancellablePromise.ts +++ b/src/helpers/cancellablePromise.ts @@ -21,7 +21,7 @@ export interface CancellablePromise extends Promise { isRejected?: boolean } -export function deferredPromise() { +export default function deferredPromise() { let deferredHelper: any = { isFulfilled: false, isRejected: false, @@ -76,4 +76,4 @@ export function deferredPromise() { Object.assign(deferred, deferredHelper); return deferred; -} \ No newline at end of file +} diff --git a/src/helpers/dom/anchorCopy.ts b/src/helpers/dom/anchorCopy.ts index 971e2c71..df84fc14 100644 --- a/src/helpers/dom/anchorCopy.ts +++ b/src/helpers/dom/anchorCopy.ts @@ -6,7 +6,7 @@ import { toastNew } from "../../components/toast"; import { copyTextToClipboard } from "../clipboard"; -import { cancelEvent } from "./cancelEvent"; +import cancelEvent from "./cancelEvent"; import { attachClickEvent } from "./clickEvent"; export default function anchorCopy(options: Partial<{ diff --git a/src/helpers/dom/attachListNavigation.ts b/src/helpers/dom/attachListNavigation.ts index 3d2ebcfc..45d5384f 100644 --- a/src/helpers/dom/attachListNavigation.ts +++ b/src/helpers/dom/attachListNavigation.ts @@ -5,7 +5,7 @@ */ import fastSmoothScroll from "../fastSmoothScroll"; -import { cancelEvent } from "./cancelEvent"; +import cancelEvent from "./cancelEvent"; import { attachClickEvent, detachClickEvent } from "./clickEvent"; import findUpAsChild from "./findUpAsChild"; import findUpClassName from "./findUpClassName"; diff --git a/src/helpers/dom/cancelEvent.ts b/src/helpers/dom/cancelEvent.ts index 23aea1cd..dcfb24c3 100644 --- a/src/helpers/dom/cancelEvent.ts +++ b/src/helpers/dom/cancelEvent.ts @@ -9,7 +9,7 @@ * https://github.com/zhukov/webogram/blob/master/LICENSE */ -export function cancelEvent(event: Event) { +export default function cancelEvent(event: Event) { event = event || window.event; if(event) { // @ts-ignore diff --git a/src/helpers/dom/handleHorizontalSwipe.ts b/src/helpers/dom/handleHorizontalSwipe.ts index a3077850..4ee9c7e3 100644 --- a/src/helpers/dom/handleHorizontalSwipe.ts +++ b/src/helpers/dom/handleHorizontalSwipe.ts @@ -5,7 +5,7 @@ */ import SwipeHandler, { SwipeHandlerOptions } from "../../components/swipeHandler"; -import { cancelEvent } from "./cancelEvent"; +import cancelEvent from "./cancelEvent"; import findUpClassName from "./findUpClassName"; import isSwipingBackSafari from "./isSwipingBackSafari"; diff --git a/src/helpers/dom/loadFonts.ts b/src/helpers/dom/loadFonts.ts index 8b9416ae..4efb3819 100644 --- a/src/helpers/dom/loadFonts.ts +++ b/src/helpers/dom/loadFonts.ts @@ -4,14 +4,53 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -let promise: Promise; -export default function loadFonts(): Promise { - if(promise) return promise; - return promise = 'fonts' in document ? - Promise.race([ - // @ts-ignore - Promise.all(['400 1rem Roboto', '500 1rem Roboto', '500 1rem tgico'].map(font => document.fonts.load(font))), - new Promise((resolve) => setTimeout(resolve, 1e3)) - ]) : - Promise.resolve(); +import pause from "../schedulers/pause"; + +const texts = ['b', 'б']; +type FontType = 'text' | 'icons' | 'monospace'; + +const cache: { + [key: string]: { + [text: string]: Promise + } +} = {}; + +const fonts: {[type in FontType]: string} = { + text: 'Roboto', + icons: 'tgico', + monospace: 'Roboto Mono' +}; + +export default function loadFonts(types: {[type in FontType]?: string[] | 'all'} = { + text: texts, + icons: undefined, + monospace: texts +}): Promise { + if(!('fonts' in document)) { + return Promise.resolve(); + } + + const promises: Promise[] = []; + for(const type in types) { + let _texts = types[type as FontType]; + if(_texts === 'all') { + _texts = texts; + } + + const font = fonts[type as FontType]; + const weights = type === 'icons' ? [500] : [400, 500]; + for(const weight of weights) { + const _promises = (_texts || [undefined]).map(text => { + const key = [weight, '1rem', font].join(' '); + const promise = (cache[key] ??= {})[text || ''] ??= document.fonts.load(key, text); + return promise; + }); + promises.push(..._promises); + } + } + + return Promise.race([ + Promise.all(promises), + pause(1000) + ]); } diff --git a/src/helpers/dom/lockTouchScroll.ts b/src/helpers/dom/lockTouchScroll.ts index 4a7f8c13..ed1c7e24 100644 --- a/src/helpers/dom/lockTouchScroll.ts +++ b/src/helpers/dom/lockTouchScroll.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { cancelEvent } from "./cancelEvent"; +import cancelEvent from "./cancelEvent"; export default function lockTouchScroll(container: HTMLElement) { const onTouchMove = (e: TouchEvent) => { diff --git a/src/helpers/dom/toggleAttributePolyfill.ts b/src/helpers/dom/toggleAttributePolyfill.ts new file mode 100644 index 00000000..6192ac1f --- /dev/null +++ b/src/helpers/dom/toggleAttributePolyfill.ts @@ -0,0 +1,18 @@ +export default function toggleAttributePolyfill() { + if(!Element.prototype.toggleAttribute) { + Element.prototype.toggleAttribute = function(name, force) { + if(force !== void 0) force = !!force; + + if(this.hasAttribute(name)) { + if(force) return true; + + this.removeAttribute(name); + return false; + } + if(force === false) return false; + + this.setAttribute(name, ""); + return true; + }; + } +} diff --git a/src/helpers/files.ts b/src/helpers/files.ts index 4a2114d2..ba321a9e 100644 --- a/src/helpers/files.ts +++ b/src/helpers/files.ts @@ -5,7 +5,7 @@ */ import { makeMediaSize, MediaSize } from "./mediaSizes"; -import { pause } from "./schedulers/pause"; +import pause from "./schedulers/pause"; import { IS_APPLE_MOBILE } from "../environment/userAgent"; export function scaleMediaElement(options: { diff --git a/src/helpers/heavyQueue.ts b/src/helpers/heavyQueue.ts index b9ca36e0..f6107380 100644 --- a/src/helpers/heavyQueue.ts +++ b/src/helpers/heavyQueue.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { CancellablePromise, deferredPromise } from "./cancellablePromise"; +import deferredPromise, { CancellablePromise } from "./cancellablePromise"; import { getHeavyAnimationPromise } from "../hooks/useHeavyAnimationCheck"; import { fastRaf } from "./schedulers"; diff --git a/src/helpers/schedulers/pause.ts b/src/helpers/schedulers/pause.ts index 6c89f15f..3cd4a0aa 100644 --- a/src/helpers/schedulers/pause.ts +++ b/src/helpers/schedulers/pause.ts @@ -1,3 +1,5 @@ -export const pause = (ms: number) => new Promise((resolve) => { - setTimeout(resolve, ms); -}); +export default function pause(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +} diff --git a/src/helpers/sequentialDom.ts b/src/helpers/sequentialDom.ts index fef80c6f..919e7227 100644 --- a/src/helpers/sequentialDom.ts +++ b/src/helpers/sequentialDom.ts @@ -5,7 +5,7 @@ */ import { fastRaf } from "./schedulers"; -import { CancellablePromise, deferredPromise } from "./cancellablePromise"; +import deferredPromise, { CancellablePromise } from "./cancellablePromise"; import { MOUNT_CLASS_TO } from "../config/debug"; import isInDOM from "./dom/isInDOM"; diff --git a/src/helpers/setWorkerProxy.ts b/src/helpers/setWorkerProxy.ts new file mode 100644 index 00000000..c31301b0 --- /dev/null +++ b/src/helpers/setWorkerProxy.ts @@ -0,0 +1,20 @@ +/* + * https://github.com/morethanwords/tweb + * Copyright (C) 2019-2021 Eduard Kuzmenko + * https://github.com/morethanwords/tweb/blob/master/LICENSE + */ + +export default function setWorkerProxy() { + // * hook worker constructor to set search parameters (test, debug, etc) + const workerHandler = { + construct(target: any, args: any) { + //console.log(target, args); + const url = args[0] + location.search; + + return new target(url); + } + }; + + const workerProxy = new Proxy(Worker, workerHandler); + Worker = workerProxy; +} diff --git a/src/hooks/useHeavyAnimationCheck.ts b/src/hooks/useHeavyAnimationCheck.ts index 709570da..776c20d0 100644 --- a/src/hooks/useHeavyAnimationCheck.ts +++ b/src/hooks/useHeavyAnimationCheck.ts @@ -8,10 +8,10 @@ import { AnyToVoidFunction } from '../types'; import ListenerSetter from '../helpers/listenerSetter'; -import { CancellablePromise, deferredPromise } from '../helpers/cancellablePromise'; +import deferredPromise, { CancellablePromise } from '../helpers/cancellablePromise'; import rootScope from '../lib/rootScope'; import DEBUG from '../config/debug'; -import { pause } from '../helpers/schedulers/pause'; +import pause from '../helpers/schedulers/pause'; const ANIMATION_START_EVENT = 'event-heavy-animation-start'; const ANIMATION_END_EVENT = 'event-heavy-animation-end'; diff --git a/src/index.ts b/src/index.ts index 3f031a1d..93f4cb4b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,380 +6,299 @@ import App from './config/app'; import blurActiveElement from './helpers/dom/blurActiveElement'; -import { cancelEvent } from './helpers/dom/cancelEvent'; +import cancelEvent from './helpers/dom/cancelEvent'; import { IS_STICKY_INPUT_BUGGED } from './helpers/dom/fixSafariStickyInputFocusing'; import loadFonts from './helpers/dom/loadFonts'; import IS_EMOJI_SUPPORTED from './environment/emojiSupport'; -import { IS_MOBILE_SAFARI } from './environment/userAgent'; +import { IS_ANDROID, IS_APPLE, IS_APPLE_MOBILE, IS_FIREFOX, IS_MOBILE, IS_MOBILE_SAFARI, IS_SAFARI } from './environment/userAgent'; import './materialize.scss'; import './scss/style.scss'; -/* import { computeCheck } from './lib/crypto/srp'; -import { salt1, salt2, g, p, srp_id, secure_random, srp_B, password } from './mock/srp'; */ - -//console.log('pineapples are in my head'); - -/* console.time('get storage1'); -import * as a from './lib/config'; -import * as b from './lib/mtproto/mtproto_config'; -import * as c from './helpers/userAgent'; -import * as d from './lib/mtproto/mtprotoworker'; -import * as e from './lib/polyfill'; -import * as f from './lib/storage'; -a && b && c && d && e && f; -console.timeEnd('get storage1'); */ - -/* Promise.all([ - import('./components/pageIm'), - import('./components/pageSignIn'), - import('./components/misc'), - import('./lib/storage') -]).then(imports => { - let [pageIm, pageSignIn, misc, AppStorage] = imports; */ - - document.addEventListener('DOMContentLoaded', async() => { - //let socket = new Socket(2); - - if(!Element.prototype.toggleAttribute) { - Element.prototype.toggleAttribute = function(name, force) { - if(force !== void 0) force = !!force; - - if(this.hasAttribute(name)) { - if(force) return true; - - this.removeAttribute(name); - return false; - } - if(force === false) return false; - - this.setAttribute(name, ""); - return true; - }; +import pause from './helpers/schedulers/pause'; +import setWorkerProxy from './helpers/setWorkerProxy'; +import toggleAttributePolyfill from './helpers/dom/toggleAttributePolyfill'; +import rootScope from './lib/rootScope'; +import IS_TOUCH_SUPPORTED from './environment/touchSupport'; +import appStateManager from './lib/appManagers/appStateManager'; +import I18n from './lib/langPack'; +import './helpers/peerIdPolyfill'; +import './lib/polyfill'; + +document.addEventListener('DOMContentLoaded', async() => { + toggleAttributePolyfill(); + + // We listen to the resize event (https://css-tricks.com/the-trick-to-viewport-units-on-mobile/) + const w = window.visualViewport || window; // * handle iOS keyboard + let setViewportVH = false/* , hasFocus = false */; + let lastVH: number; + const setVH = () => { + const vh = (setViewportVH && !rootScope.isOverlayActive ? (w as VisualViewport).height || (w as Window).innerHeight : window.innerHeight) * 0.01; + if(lastVH === vh) { + return; + } else if(IS_TOUCH_SUPPORTED && lastVH < vh && (vh - lastVH) > 1) { + blurActiveElement(); // (Android) fix blurring inputs when keyboard is being closed (e.g. closing keyboard by back arrow and touching a bubble) } - // We listen to the resize event (https://css-tricks.com/the-trick-to-viewport-units-on-mobile/) - // @ts-ignore - const w = window.visualViewport || window; // * handle iOS keyboard - let setViewportVH = false/* , hasFocus = false */; - let lastVH: number; - const setVH = () => { - // @ts-ignore - const vh = (setViewportVH && !rootScope.default.isOverlayActive ? w.height || w.innerHeight : window.innerHeight) * 0.01; - if(lastVH === vh) { - return; - } else if(touchSupport.IS_TOUCH_SUPPORTED && lastVH < vh && (vh - lastVH) > 1) { - blurActiveElement(); // (Android) fix blurring inputs when keyboard is being closed (e.g. closing keyboard by back arrow and touching a bubble) - } - - lastVH = vh; + lastVH = vh; - //const vh = document.documentElement.scrollHeight * 0.01; - document.documentElement.style.setProperty('--vh', `${vh}px`); + //const vh = document.documentElement.scrollHeight * 0.01; + document.documentElement.style.setProperty('--vh', `${vh}px`); - //console.log('setVH', vh, setViewportVH ? w : window); + //console.log('setVH', vh, setViewportVH ? w : window); - /* if(setViewportVH && userAgent.isSafari && touchSupport.isTouchSupported && document.activeElement && (document.activeElement as HTMLElement).blur) { - const rect = document.activeElement.getBoundingClientRect(); - if(rect.top < 0 || rect.bottom >= (w as any).height) { - fastSmoothScroll(findUpClassName(document.activeElement, 'scrollable-y') || window as any, document.activeElement as HTMLElement, 'center', 4, undefined, FocusDirection.Static); + /* if(setViewportVH && userAgent.isSafari && touchSupport.isTouchSupported && document.activeElement && (document.activeElement as HTMLElement).blur) { + const rect = document.activeElement.getBoundingClientRect(); + if(rect.top < 0 || rect.bottom >= (w as any).height) { + fastSmoothScroll(findUpClassName(document.activeElement, 'scrollable-y') || window as any, document.activeElement as HTMLElement, 'center', 4, undefined, FocusDirection.Static); + } + } */ + }; + + setWorkerProxy(); + + // const [_, touchSupport, userAgent, _rootScope, _appStateManager, _I18n, __/* , ___ */] = await Promise.all([ + // import('./lib/polyfill'), + // import('./environment/touchSupport'), + // import('./environment/userAgent'), + // import('./lib/rootScope'), + // import('./lib/appManagers/appStateManager'), + // import('./lib/langPack'), + // import('./helpers/peerIdPolyfill'), + // // import('./helpers/cacheFunctionPolyfill') + // ]); + + /* const {IS_TOUCH_SUPPORTED} = touchSupport; + const {IS_FIREFOX, IS_MOBILE, IS_APPLE, IS_SAFARI, IS_APPLE_MOBILE, IS_ANDROID} = userAgent; + const rootScope = _rootScope.default; + const appStateManager = _appStateManager.default; + const I18n = _I18n.default; */ + + window.addEventListener('resize', setVH); + setVH(); + + if(IS_STICKY_INPUT_BUGGED) { + const toggleResizeMode = () => { + setViewportVH = tabId === 1 && IS_STICKY_INPUT_BUGGED && !rootScope.isOverlayActive; + setVH(); + + if(w !== window) { + if(setViewportVH) { + window.removeEventListener('resize', setVH); + w.addEventListener('resize', setVH); + } else { + w.removeEventListener('resize', setVH); + window.addEventListener('resize', setVH); } - } */ + } }; - // * hook worker constructor to set search parameters (test, debug, etc) - const workerHandler = { - construct(target: any, args: any) { - //console.log(target, args); - const url = args[0] + location.search; + let tabId: number; + rootScope.addEventListener('im_tab_change', (id) => { + const wasTabId = tabId !== undefined; + tabId = id; - return new target(url); + if(wasTabId || tabId === 1) { + toggleResizeMode(); } - }; + }); - const workerProxy = new Proxy(Worker, workerHandler); - Worker = workerProxy; - - const [_, touchSupport, userAgent, rootScope, appStateManager, I18n, __/* , ___ */] = await Promise.all([ - import('./lib/polyfill'), - import('./environment/touchSupport'), - import('./environment/userAgent'), - import('./lib/rootScope'), - import('./lib/appManagers/appStateManager'), - import('./lib/langPack'), - import('./helpers/peerIdPolyfill'), - // import('./helpers/cacheFunctionPolyfill') - ]); - - //console.timeEnd('get storage'); - - window.addEventListener('resize', setVH); - setVH(); - - //console.log(new Uint8Array([255, 200, 145]).hex); - - if(IS_STICKY_INPUT_BUGGED) { - const toggleResizeMode = () => { - setViewportVH = tabId === 1 && IS_STICKY_INPUT_BUGGED && !rootScope.default.isOverlayActive; - setVH(); - - if(w !== window) { - if(setViewportVH) { - window.removeEventListener('resize', setVH); - w.addEventListener('resize', setVH); - } else { - w.removeEventListener('resize', setVH); - window.addEventListener('resize', setVH); - } - } - }; - - let tabId: number; - rootScope.default.addEventListener('im_tab_change', (id) => { - const wasTabId = tabId !== undefined; - tabId = id; - - if(wasTabId || tabId === 1) { - toggleResizeMode(); - } - }); - - rootScope.default.addEventListener('overlay_toggle', () => { - toggleResizeMode(); - }); - } - - if(userAgent.IS_FIREFOX && !IS_EMOJI_SUPPORTED) { - document.addEventListener('dragstart', (e) => { - const target = e.target as HTMLElement; - if(target.tagName === 'IMG' && target.classList.contains('emoji')) { - cancelEvent(e); - return false; - } - }); - } + rootScope.addEventListener('overlay_toggle', () => { + toggleResizeMode(); + }); + } - // prevent firefox image dragging + if(IS_FIREFOX && !IS_EMOJI_SUPPORTED) { document.addEventListener('dragstart', (e) => { - if((e.target as HTMLElement)?.tagName === "IMG") { - e.preventDefault(); + const target = e.target as HTMLElement; + if(target.tagName === 'IMG' && target.classList.contains('emoji')) { + cancelEvent(e); return false; } }); + } - if(userAgent.IS_FIREFOX) { - document.documentElement.classList.add('is-firefox'); + // prevent firefox image dragging + document.addEventListener('dragstart', (e) => { + if((e.target as HTMLElement)?.tagName === "IMG") { + e.preventDefault(); + return false; } + }); - if(userAgent.IS_MOBILE) { - document.documentElement.classList.add('is-mobile'); - } - - if(userAgent.IS_APPLE) { - if(userAgent.IS_SAFARI) { - document.documentElement.classList.add('is-safari'); - } - - // document.documentElement.classList.add('emoji-supported'); - - if(userAgent.IS_APPLE_MOBILE) { - document.documentElement.classList.add('is-ios'); - } else { - document.documentElement.classList.add('is-mac'); - } - } else if(userAgent.IS_ANDROID) { - document.documentElement.classList.add('is-android'); + if(IS_FIREFOX) { + document.documentElement.classList.add('is-firefox'); + } - /* document.addEventListener('focusin', (e) => { - hasFocus = true; - focusTime = Date.now(); - }, {passive: true}); + if(IS_MOBILE) { + document.documentElement.classList.add('is-mobile'); + } - document.addEventListener('focusout', () => { - hasFocus = false; - }, {passive: true}); */ + if(IS_APPLE) { + if(IS_SAFARI) { + document.documentElement.classList.add('is-safari'); } + + // document.documentElement.classList.add('emoji-supported'); - if(!touchSupport.IS_TOUCH_SUPPORTED) { - document.documentElement.classList.add('no-touch'); + if(IS_APPLE_MOBILE) { + document.documentElement.classList.add('is-ios'); } else { - document.documentElement.classList.add('is-touch'); - /* document.addEventListener('touchmove', (event: any) => { - event = event.originalEvent || event; - if(event.scale && event.scale !== 1) { - event.preventDefault(); - } - }, {capture: true, passive: false}); */ + document.documentElement.classList.add('is-mac'); } + } else if(IS_ANDROID) { + document.documentElement.classList.add('is-android'); + + /* document.addEventListener('focusin', (e) => { + hasFocus = true; + focusTime = Date.now(); + }, {passive: true}); + + document.addEventListener('focusout', () => { + hasFocus = false; + }, {passive: true}); */ + } + + if(!IS_TOUCH_SUPPORTED) { + document.documentElement.classList.add('no-touch'); + } else { + document.documentElement.classList.add('is-touch'); + /* document.addEventListener('touchmove', (event: any) => { + event = event.originalEvent || event; + if(event.scale && event.scale !== 1) { + event.preventDefault(); + } + }, {capture: true, passive: false}); */ + } - /* if(config.isServiceWorkerSupported) { - await navigator.serviceWorker.ready; - navigator.serviceWorker.controller ? true : await new Promise((resolve, reject) => { - navigator.serviceWorker.addEventListener('controllerchange', resolve); - }); - } */ - - //console.time('get storage'); - - const perf = performance.now(); + let perf = performance.now(); - //import('./vendor/dateFormat'); + const langPromise = I18n.getCacheLangPack(); - const langPromise = I18n.default.getCacheLangPack(); + const [state, langPack] = await Promise.all([ + appStateManager.getState(), + langPromise + ]); + I18n.setTimeFormat(state.settings.timeFormat); - const [state, langPack] = await Promise.all([ - appStateManager.default.getState(), - langPromise - ]); - //I18n.getCacheLangPack(); - //console.log('got auth:', auth); - //console.timeEnd('get storage'); + rootScope.setThemeListener(); - I18n.default.setTimeFormat(state.settings.timeFormat); + if(langPack.appVersion !== App.langPackVersion) { + I18n.getLangPack(langPack.lang_code); + } - rootScope.default.setThemeListener(); + /** + * won't fire if font is loaded too fast + */ + function fadeInWhenFontsReady(elem: HTMLElement, promise: Promise) { + elem.style.opacity = '0'; - if(langPack.appVersion !== App.langPackVersion) { - I18n.default.getLangPack(langPack.lang_code); - } + promise.then(() => { + window.requestAnimationFrame(() => { + elem.style.opacity = ''; + }); + }); + } - /** - * won't fire if font is loaded too fast - */ - function fadeInWhenFontsReady(elem: HTMLElement, promise: Promise) { - elem.style.opacity = '0'; + console.log('got state, time:', performance.now() - perf); - promise.then(() => { - window.requestAnimationFrame(() => { - elem.style.opacity = ''; - }); - }); - } + const authState = state.authState; + if(authState._ !== 'authStateSignedIn'/* || 1 === 1 */) { + console.log('Will mount auth page:', authState._, Date.now() / 1000); - console.log('got state, time:', performance.now() - perf); + const el = document.getElementById('auth-pages'); + let scrollable: HTMLElement; + if(el) { + scrollable = el.querySelector('.scrollable') as HTMLElement; + if((!IS_TOUCH_SUPPORTED || IS_MOBILE_SAFARI)) { + scrollable.classList.add('no-scrollbar'); + } - const authState = state.authState; - if(authState._ !== 'authStateSignedIn'/* || 1 === 1 */) { - console.log('Will mount auth page:', authState._, Date.now() / 1000); + // * don't remove this line + scrollable.style.opacity = '0'; - const el = document.getElementById('auth-pages'); - let scrollable: HTMLElement; - if(el) { - scrollable = el.querySelector('.scrollable') as HTMLElement; - if((!touchSupport.IS_TOUCH_SUPPORTED || IS_MOBILE_SAFARI)) { - scrollable.classList.add('no-scrollbar'); - } + const placeholder = document.createElement('div'); + placeholder.classList.add('auth-placeholder'); - // * don't remove this line - scrollable.style.opacity = '0'; + scrollable.prepend(placeholder); + scrollable.append(placeholder.cloneNode()); + } - const placeholder = document.createElement('div'); - placeholder.classList.add('auth-placeholder'); + try { + await Promise.all([ + import('./lib/mtproto/telegramMeWebManager'), + import('./lib/mtproto/webPushApiManager') + ]).then(([meModule, pushModule]) => { + meModule.default.setAuthorized(false); + pushModule.default.forceUnsubscribe(); + }); + } catch(err) { + + } - scrollable.prepend(placeholder); - scrollable.append(placeholder.cloneNode()); + let pagePromise: Promise; + //langPromise.then(async() => { + switch(authState._) { + case 'authStateSignIn': + pagePromise = (await import('./pages/pageSignIn')).default.mount(); + break; + case 'authStateSignQr': + pagePromise = (await import('./pages/pageSignQR')).default.mount(); + break; + case 'authStateAuthCode': + pagePromise = (await import('./pages/pageAuthCode')).default.mount(authState.sentCode); + break; + case 'authStatePassword': + pagePromise = (await import('./pages/pagePassword')).default.mount(); + break; + case 'authStateSignUp': + pagePromise = (await import('./pages/pageSignUp')).default.mount(authState.authCode); + break; } + //}); - try { - await Promise.all([ - import('./lib/mtproto/telegramMeWebManager'), - import('./lib/mtproto/webPushApiManager') - ]).then(([meModule, pushModule]) => { - meModule.default.setAuthorized(false); - pushModule.default.forceUnsubscribe(); - }); - } catch(err) { - + if(scrollable) { + // wait for text appear + if(pagePromise) { + await pagePromise; } - let pagePromise: Promise; - //langPromise.then(async() => { - switch(authState._) { - case 'authStateSignIn': - pagePromise = (await import('./pages/pageSignIn')).default.mount(); - break; - case 'authStateSignQr': - pagePromise = (await import('./pages/pageSignQR')).default.mount(); - break; - case 'authStateAuthCode': - pagePromise = (await import('./pages/pageAuthCode')).default.mount(authState.sentCode); - break; - case 'authStatePassword': - pagePromise = (await import('./pages/pagePassword')).default.mount(); - break; - case 'authStateSignUp': - pagePromise = (await import('./pages/pageSignUp')).default.mount(authState.authCode); - break; - } - //}); - - if(scrollable) { - // wait for text appear - if(pagePromise) { - await pagePromise; - } - - const promise = 'fonts' in document ? - Promise.race([ - new Promise((resolve) => setTimeout(resolve, 1e3)), - // @ts-ignore - document.fonts.ready - ]) : - Promise.resolve(); - fadeInWhenFontsReady(scrollable, promise); - } + const promise = 'fonts' in document ? + Promise.race([ + pause(1000), + document.fonts.ready + ]) : + Promise.resolve(); + fadeInWhenFontsReady(scrollable, promise); + } - /* computeCheck(password, { - current_algo: { - salt1, - salt2, - p, - g + /* setTimeout(async() => { + (await import('./pages/pageAuthCode')).default.mount({ + "_": "auth.sentCode", + "pFlags": {}, + "flags": 6, + "type": { + "_": "auth.sentCodeTypeSms", + "length": 5 }, - srp_id, - srp_B, - secure_random, - }).then(res => { - console.log(res); - }); */ - - /* setTimeout(async() => { - (await import('./pages/pageAuthCode')).default.mount({ - "_": "auth.sentCode", - "pFlags": {}, - "flags": 6, - "type": { - "_": "auth.sentCodeTypeSms", - "length": 5 - }, - "phone_code_hash": "", - "next_type": { - "_": "auth.codeTypeCall" - }, - "timeout": 120, - "phone_number": "" - }); - }, 500); */ - /* setTimeout(async() => { - (await import('./pages/pageSignQR')).default.mount(); - }, 500); */ - /* setTimeout(async() => { - (await import('./pages/pagePassword')).default.mount(); - }, 500); */ - /* setTimeout(async() => { - (await import('./pages/pageSignUp')).default.mount({ - "phone_code_hash": "", - "phone_number": "" - }); - }, 500); */ - } else { - console.log('Will mount IM page:', Date.now() / 1000); - fadeInWhenFontsReady(document.getElementById('main-columns'), loadFonts()); - (await import('./pages/pageIm')).default.mount(); - //getNearestDc(); - } + "phone_code_hash": "", + "next_type": { + "_": "auth.codeTypeCall" + }, + "timeout": 120, + "phone_number": "" + }); - const ripple = (await import('./components/ripple')).ripple; - (Array.from(document.getElementsByClassName('rp')) as HTMLElement[]).forEach(el => ripple(el)); - }); -//}); + (await import('./pages/pageSignQR')).default.mount(); + (await import('./pages/pagePassword')).default.mount(); + (await import('./pages/pageSignUp')).default.mount({ + "phone_code_hash": "", + "phone_number": "" + }); + }, 500); */ + } else { + console.log('Will mount IM page:', Date.now() / 1000); + fadeInWhenFontsReady(document.getElementById('main-columns'), loadFonts()); + (await import('./pages/pageIm')).default.mount(); + } +}); diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 9b45f8de..0a7f3f89 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -11,7 +11,7 @@ import AvatarElement from "../../components/avatar"; import DialogsContextMenu from "../../components/dialogsContextMenu"; import { horizontalMenu } from "../../components/horizontalMenu"; import { attachContextMenuListener, putPreloader } from "../../components/misc"; -import { ripple } from "../../components/ripple"; +import ripple from "../../components/ripple"; //import Scrollable from "../../components/scrollable"; import Scrollable, { ScrollableX, SliceSides } from "../../components/scrollable"; import { formatDateAccordingToTodayNew } from "../../helpers/date"; diff --git a/src/lib/appManagers/appDownloadManager.ts b/src/lib/appManagers/appDownloadManager.ts index b34142c8..a319664a 100644 --- a/src/lib/appManagers/appDownloadManager.ts +++ b/src/lib/appManagers/appDownloadManager.ts @@ -10,7 +10,7 @@ import type { MyDocument } from "./appDocsManager"; import type { MyPhoto } from "./appPhotosManager"; import rootScope from "../rootScope"; import apiManager from "../mtproto/mtprotoworker"; -import { deferredPromise, CancellablePromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import { InputFile } from "../../layer"; import { getFileNameByLocation } from "../../helpers/fileName"; import CacheStorageController from "../cacheStorage"; diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index f3cfc85c..497a95e8 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -50,7 +50,7 @@ import PeerTitle from '../../components/peerTitle'; import PopupPeer from '../../components/popups/peer'; import { SliceEnd } from '../../helpers/slicedArray'; import blurActiveElement from '../../helpers/dom/blurActiveElement'; -import { cancelEvent } from '../../helpers/dom/cancelEvent'; +import cancelEvent from '../../helpers/dom/cancelEvent'; import disableTransition from '../../helpers/dom/disableTransition'; import placeCaretAtEnd from '../../helpers/dom/placeCaretAtEnd'; import replaceContent from '../../helpers/dom/replaceContent'; @@ -62,7 +62,7 @@ import PopupStickers from '../../components/popups/stickers'; import PopupJoinChatInvite from '../../components/popups/joinChatInvite'; import { toast, toastNew } from '../../components/toast'; import debounce from '../../helpers/schedulers/debounce'; -import { pause } from '../../helpers/schedulers/pause'; +import pause from '../../helpers/schedulers/pause'; import appMessagesIdsManager from './appMessagesIdsManager'; import { InternalLink, InternalLinkTypeMap, INTERNAL_LINK_TYPE } from './internalLink'; import RichTextProcessor from '../richtextprocessor'; diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index dd459a05..ed98edfb 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -11,7 +11,7 @@ import { LazyLoadQueueBase } from "../../components/lazyLoadQueue"; import ProgressivePreloader from "../../components/preloader"; -import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import { formatDateAccordingToTodayNew, formatTime, tsNow } from "../../helpers/date"; import { createPosterForVideo } from "../../helpers/files"; import { randomLong } from "../../helpers/random"; diff --git a/src/lib/appManagers/appNotificationsManager.ts b/src/lib/appManagers/appNotificationsManager.ts index 91dd3871..a3f5f010 100644 --- a/src/lib/appManagers/appNotificationsManager.ts +++ b/src/lib/appManagers/appNotificationsManager.ts @@ -11,7 +11,7 @@ import { fontFamily } from "../../components/middleEllipsis"; import { MOUNT_CLASS_TO } from "../../config/debug"; -import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import { tsNow } from "../../helpers/date"; import { IS_MOBILE } from "../../environment/userAgent"; import { InputNotifyPeer, InputPeerNotifySettings, NotifyPeer, PeerNotifySettings, Update } from "../../layer"; diff --git a/src/lib/appManagers/appUsersManager.ts b/src/lib/appManagers/appUsersManager.ts index 84d8eb3f..069bfb1a 100644 --- a/src/lib/appManagers/appUsersManager.ts +++ b/src/lib/appManagers/appUsersManager.ts @@ -13,7 +13,7 @@ import { MOUNT_CLASS_TO } from "../../config/debug"; import filterUnique from "../../helpers/array/filterUnique"; import findAndSplice from "../../helpers/array/findAndSplice"; import indexOfAndSplice from "../../helpers/array/indexOfAndSplice"; -import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import cleanSearchText from "../../helpers/cleanSearchText"; import cleanUsername from "../../helpers/cleanUsername"; import { formatFullSentTimeRaw, tsNow } from "../../helpers/date"; diff --git a/src/lib/mediaPlayer.ts b/src/lib/mediaPlayer.ts index beaa9d39..67169c5a 100644 --- a/src/lib/mediaPlayer.ts +++ b/src/lib/mediaPlayer.ts @@ -9,7 +9,7 @@ import { IS_APPLE_MOBILE } from "../environment/userAgent"; import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import RangeSelector from "../components/rangeSelector"; import { onMediaLoad } from "../helpers/files"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import ListenerSetter from "../helpers/listenerSetter"; import ButtonMenu from "../components/buttonMenu"; import { ButtonMenuToggleHandler } from "../components/buttonMenuToggle"; diff --git a/src/lib/mtproto/apiFileManager.ts b/src/lib/mtproto/apiFileManager.ts index c1b3fc67..a096fc40 100644 --- a/src/lib/mtproto/apiFileManager.ts +++ b/src/lib/mtproto/apiFileManager.ts @@ -12,7 +12,7 @@ import type { ReferenceBytes } from "./referenceDatabase"; import { MOUNT_CLASS_TO } from "../../config/debug"; import Modes from "../../config/modes"; -import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import { notifyAll, notifySomeone } from "../../helpers/context"; import { getFileNameByLocation } from "../../helpers/fileName"; import { randomLong } from "../../helpers/random"; diff --git a/src/lib/mtproto/apiManager.ts b/src/lib/mtproto/apiManager.ts index 63f415f2..35729e4d 100644 --- a/src/lib/mtproto/apiManager.ts +++ b/src/lib/mtproto/apiManager.ts @@ -19,7 +19,7 @@ import dcConfigurator, { ConnectionType, DcConfigurator, TransportType } from '. import { logger } from '../logger'; import type { DcAuthKey, DcId, DcServerSalt, InvokeApiOptions } from '../../types'; import type { MethodDeclMap } from '../../layer'; -import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise'; +import deferredPromise, { CancellablePromise } from '../../helpers/cancellablePromise'; //import { clamp } from '../../helpers/number'; import { IS_SAFARI } from '../../environment/userAgent'; import App from '../../config/app'; @@ -32,7 +32,7 @@ import Modes from '../../config/modes'; import bytesFromHex from '../../helpers/bytes/bytesFromHex'; import bytesToHex from '../../helpers/bytes/bytesToHex'; import isObject from '../../helpers/object/isObject'; -import { pause } from '../../helpers/schedulers/pause'; +import pause from '../../helpers/schedulers/pause'; /// #if !MTPROTO_WORKER import rootScope from '../rootScope'; diff --git a/src/lib/mtproto/mtprotoworker.ts b/src/lib/mtproto/mtprotoworker.ts index c7765496..c674760b 100644 --- a/src/lib/mtproto/mtprotoworker.ts +++ b/src/lib/mtproto/mtprotoworker.ts @@ -28,7 +28,7 @@ import appRuntimeManager from '../appManagers/appRuntimeManager'; import { SocketProxyTask } from './transports/socketProxied'; import telegramMeWebManager from './telegramMeWebManager'; import { CacheStorageDbName } from '../cacheStorage'; -import { pause } from '../../helpers/schedulers/pause'; +import pause from '../../helpers/schedulers/pause'; import IS_WEBP_SUPPORTED from '../../environment/webpSupport'; import type { ApiError } from './apiManager'; import { MTAppConfig } from './appConfig'; diff --git a/src/lib/mtproto/networker.ts b/src/lib/mtproto/networker.ts index 2b67ea08..64eea213 100644 --- a/src/lib/mtproto/networker.ts +++ b/src/lib/mtproto/networker.ts @@ -41,8 +41,8 @@ import isObject from '../../helpers/object/isObject'; import forEachReverse from '../../helpers/array/forEachReverse'; import sortLongsArray from '../../helpers/long/sortLongsArray'; import randomize from '../../helpers/array/randomize'; -import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise'; -import { pause } from '../../helpers/schedulers/pause'; +import deferredPromise, { CancellablePromise } from '../../helpers/cancellablePromise'; +import pause from '../../helpers/schedulers/pause'; //console.error('networker included!', new Error().stack); diff --git a/src/lib/mtproto/transports/controller.ts b/src/lib/mtproto/transports/controller.ts index b39a358a..9a9675f9 100644 --- a/src/lib/mtproto/transports/controller.ts +++ b/src/lib/mtproto/transports/controller.ts @@ -5,9 +5,9 @@ */ import App from "../../../config/app"; -import { deferredPromise } from "../../../helpers/cancellablePromise"; +import deferredPromise from "../../../helpers/cancellablePromise"; import EventListenerBase from "../../../helpers/eventListenerBase"; -import { pause } from "../../../helpers/schedulers/pause"; +import pause from "../../../helpers/schedulers/pause"; import dcConfigurator, { TransportType } from "../dcConfigurator"; import type HTTP from "./http"; import type TcpObfuscated from "./tcpObfuscated"; diff --git a/src/lib/mtproto/transports/http.ts b/src/lib/mtproto/transports/http.ts index b6e6802f..a8c242ef 100644 --- a/src/lib/mtproto/transports/http.ts +++ b/src/lib/mtproto/transports/http.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { pause } from '../../../helpers/schedulers/pause'; +import pause from '../../../helpers/schedulers/pause'; import { DcId } from '../../../types'; import { logger, LogTypes } from '../../logger'; import type MTPNetworker from '../networker'; diff --git a/src/lib/rlottie/lottieLoader.ts b/src/lib/rlottie/lottieLoader.ts index 6ec10536..3ae386f7 100644 --- a/src/lib/rlottie/lottieLoader.ts +++ b/src/lib/rlottie/lottieLoader.ts @@ -7,7 +7,7 @@ import RLottieWorker from 'worker-loader!./rlottie.worker'; import animationIntersector from "../../components/animationIntersector"; import { MOUNT_CLASS_TO } from '../../config/debug'; -import { pause } from '../../helpers/schedulers/pause'; +import pause from '../../helpers/schedulers/pause'; import { logger, LogTypes } from "../logger"; import apiManager from "../mtproto/mtprotoworker"; import RLottiePlayer, { RLottieOptions } from './rlottiePlayer'; diff --git a/src/lib/rootScope.ts b/src/lib/rootScope.ts index d07175f1..38ddf946 100644 --- a/src/lib/rootScope.ts +++ b/src/lib/rootScope.ts @@ -117,7 +117,6 @@ export type BroadcastEvents = { 'event-heavy-animation-start': void, 'event-heavy-animation-end': void, - 'im_mount': void, 'im_tab_change': number, 'idle': boolean, diff --git a/src/lib/serviceWorker/cache.ts b/src/lib/serviceWorker/cache.ts index b0417fd6..3ed593ed 100644 --- a/src/lib/serviceWorker/cache.ts +++ b/src/lib/serviceWorker/cache.ts @@ -4,7 +4,7 @@ * https://github.com/morethanwords/tweb/blob/master/LICENSE */ -import { pause } from "../../helpers/schedulers/pause"; +import pause from "../../helpers/schedulers/pause"; const ctx = self as any as ServiceWorkerGlobalScope; export const CACHE_ASSETS_NAME = 'cachedAssets'; diff --git a/src/lib/serviceWorker/stream.ts b/src/lib/serviceWorker/stream.ts index ff6a9037..83d9a94f 100644 --- a/src/lib/serviceWorker/stream.ts +++ b/src/lib/serviceWorker/stream.ts @@ -5,7 +5,7 @@ */ import readBlobAsUint8Array from "../../helpers/blob/readBlobAsUint8Array"; -import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../../helpers/cancellablePromise"; import { getWindowClients } from "../../helpers/context"; import debounce from "../../helpers/schedulers/debounce"; import { InputFileLocation, UploadFile } from "../../layer"; diff --git a/src/lib/storage.ts b/src/lib/storage.ts index b055fcb4..695a5960 100644 --- a/src/lib/storage.ts +++ b/src/lib/storage.ts @@ -11,7 +11,7 @@ import { Database } from "../config/databases"; //import DATABASE_SESSION from "../config/databases/session"; -import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise"; +import deferredPromise, { CancellablePromise } from "../helpers/cancellablePromise"; import throttle from "../helpers/schedulers/throttle"; //import { WorkerTaskTemplate } from "../types"; import IDBStorage from "./idb"; diff --git a/src/lib/webp/webpWorkerController.ts b/src/lib/webp/webpWorkerController.ts index 50c87aea..af758b5c 100644 --- a/src/lib/webp/webpWorkerController.ts +++ b/src/lib/webp/webpWorkerController.ts @@ -6,7 +6,7 @@ import WebpWorker from 'worker-loader!./webp.worker'; import { MOUNT_CLASS_TO } from '../../config/debug'; -import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise'; +import deferredPromise, { CancellablePromise } from '../../helpers/cancellablePromise'; import apiManagerProxy from '../mtproto/mtprotoworker'; export type WebpConvertTask = { diff --git a/src/pages/pageIm.ts b/src/pages/pageIm.ts index 235df455..84054f5e 100644 --- a/src/pages/pageIm.ts +++ b/src/pages/pageIm.ts @@ -8,17 +8,13 @@ import blurActiveElement from "../helpers/dom/blurActiveElement"; import loadFonts from "../helpers/dom/loadFonts"; import appStateManager from "../lib/appManagers/appStateManager"; import I18n from "../lib/langPack"; -import rootScope from "../lib/rootScope"; import Page from "./page"; let onFirstMount = () => { - //return; appStateManager.pushToState('authState', {_: 'authStateSignedIn'}); // ! TOO SLOW /* appStateManager.saveState(); */ - rootScope.dispatchEvent('im_mount'); - if(!I18n.requestedServerLanguage) { I18n.getCacheLangPack().then(langPack => { if(langPack.local) { @@ -28,8 +24,6 @@ let onFirstMount = () => { } page.pageEl.style.display = ''; - - //alert('pageIm!'); //AudioContext && global.navigator && global.navigator.mediaDevices && global.navigator.mediaDevices.getUserMedia && global.WebAssembly; diff --git a/src/pages/pagePassword.ts b/src/pages/pagePassword.ts index 705bbbd8..140b24bc 100644 --- a/src/pages/pagePassword.ts +++ b/src/pages/pagePassword.ts @@ -16,7 +16,7 @@ import PasswordMonkey from '../components/monkeys/password'; import RichTextProcessor from '../lib/richtextprocessor'; import I18n from '../lib/langPack'; import LoginPage from './loginPage'; -import { cancelEvent } from '../helpers/dom/cancelEvent'; +import cancelEvent from '../helpers/dom/cancelEvent'; import { attachClickEvent } from '../helpers/dom/clickEvent'; import htmlToSpan from '../helpers/dom/htmlToSpan'; import replaceContent from '../helpers/dom/replaceContent'; diff --git a/src/pages/pageSignIn.ts b/src/pages/pageSignIn.ts index a1916ec3..6e86c674 100644 --- a/src/pages/pageSignIn.ts +++ b/src/pages/pageSignIn.ts @@ -18,7 +18,7 @@ import { IS_TOUCH_SUPPORTED } from "../environment/touchSupport"; import App from "../config/app"; import I18n, { _i18n, i18n } from "../lib/langPack"; import lottieLoader from "../lib/rlottie/lottieLoader"; -import { ripple } from "../components/ripple"; +import ripple from "../components/ripple"; import findUpTag from "../helpers/dom/findUpTag"; import findUpClassName from "../helpers/dom/findUpClassName"; import { randomLong } from "../helpers/random"; @@ -26,7 +26,7 @@ import AppStorage from "../lib/storage"; import CacheStorageController from "../lib/cacheStorage"; import pageSignQR from "./pageSignQR"; import getLanguageChangeButton from "../components/languageChangeButton"; -import { cancelEvent } from "../helpers/dom/cancelEvent"; +import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent } from "../helpers/dom/clickEvent"; import replaceContent from "../helpers/dom/replaceContent"; import toggleDisability from "../helpers/dom/toggleDisability"; diff --git a/src/pages/pageSignQR.ts b/src/pages/pageSignQR.ts index 2c15c6cb..70aa8c14 100644 --- a/src/pages/pageSignQR.ts +++ b/src/pages/pageSignQR.ts @@ -17,7 +17,7 @@ import appStateManager from '../lib/appManagers/appStateManager'; import rootScope from '../lib/rootScope'; import { putPreloader } from '../components/misc'; import getLanguageChangeButton from '../components/languageChangeButton'; -import { pause } from '../helpers/schedulers/pause'; +import pause from '../helpers/schedulers/pause'; import fixBase64String from '../helpers/fixBase64String'; import bytesCmp from '../helpers/bytes/bytesCmp'; import bytesToBase64 from '../helpers/bytes/bytesToBase64';