Better monospace text
This commit is contained in:
parent
ef5ca42290
commit
3d6c42432e
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { i18n, LangPackKey } from "../lib/langPack";
|
||||
import { ripple } from "./ripple";
|
||||
import ripple from "./ripple";
|
||||
|
||||
export type ButtonOptions = Partial<{
|
||||
noRipple: true,
|
||||
|
@ -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,
|
||||
|
@ -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";
|
||||
|
@ -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,
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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";
|
||||
|
@ -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 {
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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<boolean | void> = () => Promise.resolve(),
|
||||
onEnd: (id: number) => void = null,
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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 {
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -21,7 +21,7 @@ export interface CancellablePromise<T> extends Promise<T> {
|
||||
isRejected?: boolean
|
||||
}
|
||||
|
||||
export function deferredPromise<T>() {
|
||||
export default function deferredPromise<T>() {
|
||||
let deferredHelper: any = {
|
||||
isFulfilled: false,
|
||||
isRejected: false,
|
||||
@ -76,4 +76,4 @@ export function deferredPromise<T>() {
|
||||
Object.assign(deferred, deferredHelper);
|
||||
|
||||
return deferred;
|
||||
}
|
||||
}
|
||||
|
@ -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<{
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
@ -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";
|
||||
|
||||
|
@ -4,14 +4,53 @@
|
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
let promise: Promise<any>;
|
||||
export default function loadFonts(): Promise<any> {
|
||||
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<any>
|
||||
}
|
||||
} = {};
|
||||
|
||||
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<any> {
|
||||
if(!('fonts' in document)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const promises: Promise<any>[] = [];
|
||||
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)
|
||||
]);
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
18
src/helpers/dom/toggleAttributePolyfill.ts
Normal file
18
src/helpers/dom/toggleAttributePolyfill.ts
Normal file
@ -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;
|
||||
};
|
||||
}
|
||||
}
|
@ -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: {
|
||||
|
@ -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";
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
export const pause = (ms: number) => new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
export default function pause(ms: number) {
|
||||
return new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
@ -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";
|
||||
|
||||
|
20
src/helpers/setWorkerProxy.ts
Normal file
20
src/helpers/setWorkerProxy.ts
Normal file
@ -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;
|
||||
}
|
@ -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';
|
||||
|
613
src/index.ts
613
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'; */
|
||||
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';
|
||||
|
||||
//console.log('pineapples are in my head');
|
||||
document.addEventListener('DOMContentLoaded', async() => {
|
||||
toggleAttributePolyfill();
|
||||
|
||||
/* 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;
|
||||
};
|
||||
// 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;
|
||||
|
||||
//const vh = document.documentElement.scrollHeight * 0.01;
|
||||
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||
|
||||
//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);
|
||||
}
|
||||
} */
|
||||
};
|
||||
|
||||
lastVH = vh;
|
||||
setWorkerProxy();
|
||||
|
||||
//const vh = document.documentElement.scrollHeight * 0.01;
|
||||
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||
// 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.log('setVH', vh, setViewportVH ? w : window);
|
||||
/* 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; */
|
||||
|
||||
/* 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);
|
||||
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;
|
||||
|
||||
return new target(url);
|
||||
}
|
||||
};
|
||||
|
||||
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')
|
||||
]);
|
||||
let tabId: number;
|
||||
rootScope.addEventListener('im_tab_change', (id) => {
|
||||
const wasTabId = tabId !== undefined;
|
||||
tabId = id;
|
||||
|
||||
//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', () => {
|
||||
if(wasTabId || tabId === 1) {
|
||||
toggleResizeMode();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
rootScope.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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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');
|
||||
|
||||
/* document.addEventListener('focusin', (e) => {
|
||||
hasFocus = true;
|
||||
focusTime = Date.now();
|
||||
}, {passive: true});
|
||||
|
||||
document.addEventListener('focusout', () => {
|
||||
hasFocus = false;
|
||||
}, {passive: true}); */
|
||||
}
|
||||
|
||||
if(!touchSupport.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();
|
||||
|
||||
//import('./vendor/dateFormat');
|
||||
|
||||
const langPromise = I18n.default.getCacheLangPack();
|
||||
|
||||
const [state, langPack] = await Promise.all([
|
||||
appStateManager.default.getState(),
|
||||
langPromise
|
||||
]);
|
||||
//I18n.getCacheLangPack();
|
||||
//console.log('got auth:', auth);
|
||||
//console.timeEnd('get storage');
|
||||
|
||||
I18n.default.setTimeFormat(state.settings.timeFormat);
|
||||
|
||||
rootScope.default.setThemeListener();
|
||||
|
||||
if(langPack.appVersion !== App.langPackVersion) {
|
||||
I18n.default.getLangPack(langPack.lang_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* won't fire if font is loaded too fast
|
||||
*/
|
||||
function fadeInWhenFontsReady(elem: HTMLElement, promise: Promise<any>) {
|
||||
elem.style.opacity = '0';
|
||||
|
||||
promise.then(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
elem.style.opacity = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log('got state, time:', performance.now() - perf);
|
||||
|
||||
const authState = state.authState;
|
||||
if(authState._ !== 'authStateSignedIn'/* || 1 === 1 */) {
|
||||
console.log('Will mount auth page:', authState._, Date.now() / 1000);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
// * don't remove this line
|
||||
scrollable.style.opacity = '0';
|
||||
|
||||
const placeholder = document.createElement('div');
|
||||
placeholder.classList.add('auth-placeholder');
|
||||
|
||||
scrollable.prepend(placeholder);
|
||||
scrollable.append(placeholder.cloneNode());
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
import('./lib/mtproto/telegramMeWebManager'),
|
||||
import('./lib/mtproto/webPushApiManager')
|
||||
]).then(([meModule, pushModule]) => {
|
||||
meModule.default.setAuthorized(false);
|
||||
pushModule.default.forceUnsubscribe();
|
||||
});
|
||||
} catch(err) {
|
||||
|
||||
}
|
||||
|
||||
let pagePromise: Promise<void>;
|
||||
//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);
|
||||
}
|
||||
|
||||
/* computeCheck(password, {
|
||||
current_algo: {
|
||||
salt1,
|
||||
salt2,
|
||||
p,
|
||||
g
|
||||
},
|
||||
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();
|
||||
}
|
||||
|
||||
const ripple = (await import('./components/ripple')).ripple;
|
||||
(Array.from(document.getElementsByClassName('rp')) as HTMLElement[]).forEach(el => ripple(el));
|
||||
});
|
||||
//});
|
||||
|
||||
if(IS_FIREFOX) {
|
||||
document.documentElement.classList.add('is-firefox');
|
||||
}
|
||||
|
||||
if(IS_MOBILE) {
|
||||
document.documentElement.classList.add('is-mobile');
|
||||
}
|
||||
|
||||
if(IS_APPLE) {
|
||||
if(IS_SAFARI) {
|
||||
document.documentElement.classList.add('is-safari');
|
||||
}
|
||||
|
||||
// document.documentElement.classList.add('emoji-supported');
|
||||
|
||||
if(IS_APPLE_MOBILE) {
|
||||
document.documentElement.classList.add('is-ios');
|
||||
} else {
|
||||
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}); */
|
||||
}
|
||||
|
||||
let perf = performance.now();
|
||||
|
||||
const langPromise = I18n.getCacheLangPack();
|
||||
|
||||
const [state, langPack] = await Promise.all([
|
||||
appStateManager.getState(),
|
||||
langPromise
|
||||
]);
|
||||
I18n.setTimeFormat(state.settings.timeFormat);
|
||||
|
||||
rootScope.setThemeListener();
|
||||
|
||||
if(langPack.appVersion !== App.langPackVersion) {
|
||||
I18n.getLangPack(langPack.lang_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* won't fire if font is loaded too fast
|
||||
*/
|
||||
function fadeInWhenFontsReady(elem: HTMLElement, promise: Promise<any>) {
|
||||
elem.style.opacity = '0';
|
||||
|
||||
promise.then(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
elem.style.opacity = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log('got state, time:', performance.now() - perf);
|
||||
|
||||
const authState = state.authState;
|
||||
if(authState._ !== 'authStateSignedIn'/* || 1 === 1 */) {
|
||||
console.log('Will mount auth page:', authState._, Date.now() / 1000);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
// * don't remove this line
|
||||
scrollable.style.opacity = '0';
|
||||
|
||||
const placeholder = document.createElement('div');
|
||||
placeholder.classList.add('auth-placeholder');
|
||||
|
||||
scrollable.prepend(placeholder);
|
||||
scrollable.append(placeholder.cloneNode());
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
import('./lib/mtproto/telegramMeWebManager'),
|
||||
import('./lib/mtproto/webPushApiManager')
|
||||
]).then(([meModule, pushModule]) => {
|
||||
meModule.default.setAuthorized(false);
|
||||
pushModule.default.forceUnsubscribe();
|
||||
});
|
||||
} catch(err) {
|
||||
|
||||
}
|
||||
|
||||
let pagePromise: Promise<void>;
|
||||
//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([
|
||||
pause(1000),
|
||||
document.fonts.ready
|
||||
]) :
|
||||
Promise.resolve();
|
||||
fadeInWhenFontsReady(scrollable, promise);
|
||||
}
|
||||
|
||||
/* 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": ""
|
||||
});
|
||||
|
||||
(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();
|
||||
}
|
||||
});
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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,
|
||||
|
@ -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';
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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";
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user