Remove unused code and constants (#4423)
This commit is contained in:
parent
a577cfadfc
commit
a6d0102582
@ -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';
|
||||
|
||||
@ -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<OwnProps> = ({ text, noCopy }) => {
|
||||
const [isWordWrap, setWordWrap] = useState(true);
|
||||
|
||||
const handleWordWrapToggle = useCallback((wrap) => {
|
||||
setWordWrap(wrap);
|
||||
}, []);
|
||||
|
||||
const blockClass = buildClassName('text-entity-pre', !isWordWrap && 'no-word-wrap');
|
||||
|
||||
return (
|
||||
<pre className={blockClass}>
|
||||
<div className="pre-code custom-scroll-x">{text}</div>
|
||||
<CodeOverlay
|
||||
text={text}
|
||||
className="code-overlay"
|
||||
onWordWrapToggle={handleWordWrapToggle}
|
||||
noCopy={noCopy}
|
||||
/>
|
||||
</pre>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(PreBlock);
|
||||
@ -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<OwnProps> = (props) => {
|
||||
const NewChatStep1 = useModuleLoader(Bundles.Extra, 'NewChatStep1');
|
||||
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
return NewChatStep1 ? <NewChatStep1 {...props} /> : <Loading />;
|
||||
};
|
||||
|
||||
export default NewChatStep1Async;
|
||||
@ -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<OwnProps> = (props) => {
|
||||
const NewChatStep2 = useModuleLoader(Bundles.Extra, 'NewChatStep2');
|
||||
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
return NewChatStep2 ? <NewChatStep2 {...props} /> : <Loading />;
|
||||
};
|
||||
|
||||
export default NewChatStep2Async;
|
||||
@ -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
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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<ApiLimitType, readonly [number, number]> = {
|
||||
uploadMaxFileparts: [4000, 8000],
|
||||
|
||||
@ -1,99 +0,0 @@
|
||||
const RANDOM = 0.95;
|
||||
const DEBOUNCE = 3000;
|
||||
|
||||
export default class FrameDebugger {
|
||||
private durations: number[] = [];
|
||||
|
||||
private startedAtByFrameKey: Record<string, number | undefined> = {};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
export default function getElementHasScroll(el: HTMLElement): boolean {
|
||||
return el.scrollHeight > el.clientHeight;
|
||||
}
|
||||
@ -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') || {})
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
export class AbortError extends Error {
|
||||
constructor() {
|
||||
super('Aborted');
|
||||
}
|
||||
}
|
||||
|
||||
export default async function withAbortCheck<T>(abortSignal: AbortSignal, promise: Promise<T>): Promise<T> {
|
||||
const result = await promise;
|
||||
|
||||
if (abortSignal?.aborted) {
|
||||
throw new AbortError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user