diff --git a/src/bundles/extra.ts b/src/bundles/extra.ts index 2fd6b9156..3c4e34c74 100644 --- a/src/bundles/extra.ts +++ b/src/bundles/extra.ts @@ -39,8 +39,6 @@ export { default as LeftSearch } from '../components/left/search/LeftSearch'; export { default as Settings } from '../components/left/settings/Settings'; export { default as ContactList } from '../components/left/main/ContactList'; export { default as NewChat } from '../components/left/newChat/NewChat'; -export { default as NewChatStep1 } from '../components/left/newChat/NewChatStep1'; -export { default as NewChatStep2 } from '../components/left/newChat/NewChatStep2'; export { default as ArchivedChats } from '../components/left/ArchivedChats'; export { default as ChatFolderModal } from '../components/left/ChatFolderModal'; export { default as MuteChatModal } from '../components/left/MuteChatModal'; diff --git a/src/components/common/code/PreBlock.tsx b/src/components/common/code/PreBlock.tsx deleted file mode 100644 index 3428cf948..000000000 --- a/src/components/common/code/PreBlock.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import type { FC } from '../../../lib/teact/teact'; -import React, { memo, useCallback, useState } from '../../../lib/teact/teact'; - -import buildClassName from '../../../util/buildClassName'; - -import CodeOverlay from './CodeOverlay'; - -type OwnProps = { - text: string; - noCopy?: boolean; -}; - -const PreBlock: FC = ({ text, noCopy }) => { - const [isWordWrap, setWordWrap] = useState(true); - - const handleWordWrapToggle = useCallback((wrap) => { - setWordWrap(wrap); - }, []); - - const blockClass = buildClassName('text-entity-pre', !isWordWrap && 'no-word-wrap'); - - return ( -
-      
{text}
- -
- ); -}; - -export default memo(PreBlock); diff --git a/src/components/left/newChat/NewChatStep1.async.tsx b/src/components/left/newChat/NewChatStep1.async.tsx deleted file mode 100644 index a4aa54691..000000000 --- a/src/components/left/newChat/NewChatStep1.async.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import type { FC } from '../../../lib/teact/teact'; -import React from '../../../lib/teact/teact'; - -import type { OwnProps } from './NewChatStep1'; - -import { Bundles } from '../../../util/moduleLoader'; - -import useModuleLoader from '../../../hooks/useModuleLoader'; - -import Loading from '../../ui/Loading'; - -const NewChatStep1Async: FC = (props) => { - const NewChatStep1 = useModuleLoader(Bundles.Extra, 'NewChatStep1'); - - // eslint-disable-next-line react/jsx-props-no-spreading - return NewChatStep1 ? : ; -}; - -export default NewChatStep1Async; diff --git a/src/components/left/newChat/NewChatStep2.async.tsx b/src/components/left/newChat/NewChatStep2.async.tsx deleted file mode 100644 index c25829da2..000000000 --- a/src/components/left/newChat/NewChatStep2.async.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import type { FC } from '../../../lib/teact/teact'; -import React from '../../../lib/teact/teact'; - -import type { OwnProps } from './NewChatStep2'; - -import { Bundles } from '../../../util/moduleLoader'; - -import useModuleLoader from '../../../hooks/useModuleLoader'; - -import Loading from '../../ui/Loading'; - -const NewChatStep2Async: FC = (props) => { - const NewChatStep2 = useModuleLoader(Bundles.Extra, 'NewChatStep2'); - - // eslint-disable-next-line react/jsx-props-no-spreading - return NewChatStep2 ? : ; -}; - -export default NewChatStep2Async; diff --git a/src/components/middle/composer/MessageInput.tsx b/src/components/middle/composer/MessageInput.tsx index 2b1d004d5..bfb65ddfa 100644 --- a/src/components/middle/composer/MessageInput.tsx +++ b/src/components/middle/composer/MessageInput.tsx @@ -34,7 +34,7 @@ import useLastCallback from '../../../hooks/useLastCallback'; import useInputCustomEmojis from './hooks/useInputCustomEmojis'; import TextTimer from '../../ui/TextTimer'; -import TextFormatter from './TextFormatter'; +import TextFormatter from './TextFormatter.async'; const CONTEXT_MENU_CLOSE_DELAY_MS = 100; // Focus slows down animation, also it breaks transition layout in Chrome diff --git a/src/components/middle/message/ContextMenuContainer.tsx b/src/components/middle/message/ContextMenuContainer.tsx index 653d6d018..be3476549 100644 --- a/src/components/middle/message/ContextMenuContainer.tsx +++ b/src/components/middle/message/ContextMenuContainer.tsx @@ -63,7 +63,7 @@ import useSchedule from '../../../hooks/useSchedule'; import useShowTransition from '../../../hooks/useShowTransition'; import DeleteMessageModal from '../../common/DeleteMessageModal'; -import PinMessageModal from '../../common/PinMessageModal'; +import PinMessageModal from '../../common/PinMessageModal.async'; import ReportModal from '../../common/ReportModal'; import ConfirmDialog from '../../ui/ConfirmDialog'; import MessageContextMenu from './MessageContextMenu'; diff --git a/src/config.ts b/src/config.ts index c1519e5a4..63773b45b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -47,8 +47,6 @@ export const MEDIA_CACHE_NAME = 'tt-media'; export const MEDIA_CACHE_NAME_AVATARS = 'tt-media-avatars'; export const MEDIA_PROGRESSIVE_CACHE_DISABLED = false; export const MEDIA_PROGRESSIVE_CACHE_NAME = 'tt-media-progressive'; -export const CUSTOM_EMOJI_PREVIEW_CACHE_DISABLED = false; -export const CUSTOM_EMOJI_PREVIEW_CACHE_NAME = 'tt-custom-emoji-preview'; export const MEDIA_CACHE_MAX_BYTES = 512 * 1024; // 512 KB export const CUSTOM_BG_CACHE_NAME = 'tt-custom-bg'; export const LANG_CACHE_NAME = 'tt-lang-packs-v32'; @@ -327,7 +325,6 @@ export const MAX_UPLOAD_FILEPART_SIZE = 524288; // Group calls export const GROUP_CALL_VOLUME_MULTIPLIER = 100; export const GROUP_CALL_DEFAULT_VOLUME = 100 * GROUP_CALL_VOLUME_MULTIPLIER; -export const GROUP_CALL_THUMB_VIDEO_DISABLED = true; export const DEFAULT_LIMITS: Record = { uploadMaxFileparts: [4000, 8000], diff --git a/src/util/FrameDebugger.ts b/src/util/FrameDebugger.ts deleted file mode 100644 index fac14a617..000000000 --- a/src/util/FrameDebugger.ts +++ /dev/null @@ -1,99 +0,0 @@ -const RANDOM = 0.95; -const DEBOUNCE = 3000; - -export default class FrameDebugger { - private durations: number[] = []; - - private startedAtByFrameKey: Record = {}; - - private passedFrames: string[] = []; - - private timeout: number | undefined; - - constructor(private name: string = '[No name]') { - } - - onFrameStart(frameKey = '0') { - if (this.passedFrames.includes(frameKey)) { - // debugger - } - - if (this.startedAtByFrameKey[frameKey]) { - return; - } - - this.startedAtByFrameKey[frameKey] = performance.now(); - } - - onFrameEnd(frameKey = '0', onAnimationEnd?: AnyToVoidFunction) { - if (!this.startedAtByFrameKey[frameKey]) { - return; - } - - const duration = performance.now() - this.startedAtByFrameKey[frameKey]!; - - if (this.passedFrames.includes(frameKey)) { - // debugger - } - - this.passedFrames.push(frameKey); - this.durations.push(duration); - - this.startedAtByFrameKey[frameKey] = undefined; - - if (Math.random() < RANDOM) { - return; - } - - if (this.timeout) { - clearTimeout(this.timeout); - } - - // eslint-disable-next-line no-restricted-globals - this.timeout = self.setTimeout(() => { - if (!this.durations.length) { - return; - } - - const max = Math.max(...this.durations); - const min = Math.max(...this.durations); - const maxIndex = this.durations.indexOf(max); - const minIndex = this.durations.indexOf(min); - const reduced = this.durations.slice(); - reduced.splice(maxIndex, 1); - reduced.splice(minIndex, 1); - const avg = reduced.reduce((acc, cur) => acc + cur, 0) / this.durations.length; - - // eslint-disable-next-line no-console - console.log( - '!!!', - this.name, - 'total frames:', - this.durations.length, - ', avg duration:', - avg.toFixed(2), - ', max duration:', - Math.max(...reduced).toFixed(2), - ', min duration:', - Math.min(...reduced).toFixed(2), - ); - - onAnimationEnd?.(); - - this.reset(); - }, DEBOUNCE); - } - - reset() { - this.durations = []; - - this.startedAtByFrameKey = {}; - - this.passedFrames = []; - - if (this.timeout) { - clearTimeout(this.timeout); - this.timeout = undefined; - } - } -} diff --git a/src/util/getElementHasScroll.ts b/src/util/getElementHasScroll.ts deleted file mode 100644 index 7d0233f3b..000000000 --- a/src/util/getElementHasScroll.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default function getElementHasScroll(el: HTMLElement): boolean { - return el.scrollHeight > el.clientHeight; -} diff --git a/src/util/windowEnvironment.ts b/src/util/windowEnvironment.ts index 5d0ebbedd..2eb2bdced 100644 --- a/src/util/windowEnvironment.ts +++ b/src/util/windowEnvironment.ts @@ -60,12 +60,10 @@ export const IS_VOICE_RECORDING_SUPPORTED = Boolean( window.AudioContext || (window as any).webkitAudioContext ), ); -export const IS_SMOOTH_SCROLL_SUPPORTED = 'scrollBehavior' in document.documentElement.style; export const IS_EMOJI_SUPPORTED = PLATFORM_ENV && (IS_MAC_OS || IS_IOS) && isLastEmojiVersionSupported(); export const IS_SERVICE_WORKER_SUPPORTED = 'serviceWorker' in navigator; // TODO Consider failed service worker export const IS_PROGRESSIVE_SUPPORTED = IS_SERVICE_WORKER_SUPPORTED; -export const IS_STREAMING_SUPPORTED = 'MediaSource' in window; export const IS_OPUS_SUPPORTED = Boolean((new Audio()).canPlayType('audio/ogg; codecs=opus')); export const IS_CANVAS_FILTER_SUPPORTED = ( !IS_TEST && 'filter' in (document.createElement('canvas').getContext('2d') || {}) diff --git a/src/util/withAbortCheck.ts b/src/util/withAbortCheck.ts deleted file mode 100644 index 41471f40a..000000000 --- a/src/util/withAbortCheck.ts +++ /dev/null @@ -1,15 +0,0 @@ -export class AbortError extends Error { - constructor() { - super('Aborted'); - } -} - -export default async function withAbortCheck(abortSignal: AbortSignal, promise: Promise): Promise { - const result = await promise; - - if (abortSignal?.aborted) { - throw new AbortError(); - } - - return result; -}