diff --git a/src/components/common/AnimatedSticker.tsx b/src/components/common/AnimatedSticker.tsx index ae05f85b2..02150825c 100644 --- a/src/components/common/AnimatedSticker.tsx +++ b/src/components/common/AnimatedSticker.tsx @@ -24,7 +24,7 @@ export type OwnProps = { playSegment?: [number, number]; speed?: number; noLoop?: boolean; - size: number; + size?: number; quality?: number; color?: [number, number, number]; isLowPriority?: boolean; diff --git a/src/components/common/StickerView.tsx b/src/components/common/StickerView.tsx index 2414ca179..3d53fc006 100644 --- a/src/components/common/StickerView.tsx +++ b/src/components/common/StickerView.tsx @@ -115,14 +115,13 @@ const StickerView: FC = ({ const noTransition = isLottie && preloadedPreviewData; const bounds = useBoundsInSharedCanvas(containerRef, sharedCanvasRef); - const realSize = size || bounds.size; // Preload preview for Message Input and local message useMedia(previewMediaHash, !shouldLoad || !shouldPreloadPreview, undefined, cacheBuster); const randomIdPrefix = useMemo(() => generateIdFor(ID_STORE, true), []); const renderId = [ - (withSharedAnimation ? SHARED_PREFIX : randomIdPrefix), id, realSize, customColor?.join(','), + (withSharedAnimation ? SHARED_PREFIX : randomIdPrefix), id, size, customColor?.join(','), ].filter(Boolean).join('_'); return ( @@ -143,7 +142,7 @@ const StickerView: FC = ({ { const { editMessage, setEditingDraft, toggleMessageWebPage } = getActions(); - const [shouldForceShowEditing, setShouldForceShowEditing] = useState(); + const [shouldForceShowEditing, setShouldForceShowEditing] = useState(false); useEffectWithPrevDeps(([prevEditedMessage, prevReplyingToId]) => { if (!editedMessage) { diff --git a/src/components/middle/message/Video.tsx b/src/components/middle/message/Video.tsx index 17ec5ee9c..348e7eebd 100644 --- a/src/components/middle/message/Video.tsx +++ b/src/components/middle/message/Video.tsx @@ -94,7 +94,7 @@ const Video: FC = ({ const { isMobile } = useAppLayout(); const [isLoadAllowed, setIsLoadAllowed] = useState(canAutoLoad); const shouldLoad = Boolean(isLoadAllowed && isIntersectingForLoading && lastSyncTime); - const [isPlayAllowed, setIsPlayAllowed] = useState(canAutoPlay && !isSpoilerShown); + const [isPlayAllowed, setIsPlayAllowed] = useState(Boolean(canAutoPlay && !isSpoilerShown)); const fullMediaHash = getMessageMediaHash(message, 'inline'); const [isFullMediaPreloaded] = useState(Boolean(fullMediaHash && mediaLoader.getFromMemory(fullMediaHash))); diff --git a/src/components/right/management/ManageChatPrivacyType.tsx b/src/components/right/management/ManageChatPrivacyType.tsx index e1191d2b6..7fe5445c3 100644 --- a/src/components/right/management/ManageChatPrivacyType.tsx +++ b/src/components/right/management/ManageChatPrivacyType.tsx @@ -135,7 +135,7 @@ const ManageChatPrivacyType: FC = ({ if (isPublic && privacyType === 'private') { openUsernameLostDialog(); } else { - updatePublicLink({ username: privacyType === 'public' ? editableUsername : '' }); + updatePublicLink({ username: privacyType === 'public' ? (editableUsername || '') : '' }); } }, [isPublic, openUsernameLostDialog, privacyType, updatePublicLink, editableUsername]); diff --git a/src/components/right/management/ManageDiscussion.tsx b/src/components/right/management/ManageDiscussion.tsx index 36266d2ba..95fd44959 100644 --- a/src/components/right/management/ManageDiscussion.tsx +++ b/src/components/right/management/ManageDiscussion.tsx @@ -61,8 +61,8 @@ const ManageDiscussion: FC = ({ const [linkedGroupId, setLinkedGroupId] = useState(); const [isConfirmUnlinkGroupDialogOpen, openConfirmUnlinkGroupDialog, closeConfirmUnlinkGroupDialog] = useFlag(); const [isConfirmLinkGroupDialogOpen, openConfirmLinkGroupDialog, closeConfirmLinkGroupDialog] = useFlag(); - const [isJoinToSend, setIsJoinToSend] = useState(linkedChat?.isJoinToSend); - const [isJoinRequest, setIsJoinRequest] = useState(linkedChat?.isJoinRequest); + const [isJoinToSend, setIsJoinToSend] = useState(Boolean(linkedChat?.isJoinToSend)); + const [isJoinRequest, setIsJoinRequest] = useState(Boolean(linkedChat?.isJoinRequest)); const lang = useLang(); const linkedChatId = linkedChat?.id; @@ -92,7 +92,7 @@ const ManageDiscussion: FC = ({ const handleLinkGroupSessions = useCallback(() => { closeConfirmLinkGroupDialog(); - linkDiscussionGroup({ channelId: chatId, chatId: linkedGroupId }); + linkDiscussionGroup({ channelId: chatId, chatId: linkedGroupId! }); }, [closeConfirmLinkGroupDialog, linkDiscussionGroup, chatId, linkedGroupId]); const handleJoinToSendCheck = useCallback((checked: boolean) => { @@ -128,11 +128,9 @@ const ManageDiscussion: FC = ({ } function renderLinkGroupHeader() { + if (!linkedGroupId) return undefined; const linkedGroup = chatsByIds[linkedGroupId]; - - if (!linkedGroup) { - return undefined; - } + if (!linkedGroup) return undefined; return (
@@ -148,11 +146,9 @@ const ManageDiscussion: FC = ({ } function renderLinkGroupConfirmText() { + if (!linkedGroupId) return undefined; const linkedGroup = chatsByIds[linkedGroupId]; - - if (!linkedGroup) { - return undefined; - } + if (!linkedGroup) return undefined; if (linkedGroup.hasPrivateLink) { return renderText( diff --git a/src/hooks/useResize.ts b/src/hooks/useResize.ts index 510646152..93439d441 100644 --- a/src/hooks/useResize.ts +++ b/src/hooks/useResize.ts @@ -12,8 +12,8 @@ export function useResize( cssPropertyName?: string, ) { const [isActive, markIsActive, unmarkIsActive] = useFlag(); - const [initialMouseX, setInitialMouseX] = useState(); - const [initialElementWidth, setInitialElementWidth] = useState(); + const [initialMouseX, setInitialMouseX] = useState(0); + const [initialElementWidth, setInitialElementWidth] = useState(0); const setElementStyle = useCallback((width?: number) => { if (!elementRef.current) { diff --git a/src/lib/teact/teact.ts b/src/lib/teact/teact.ts index 2b9d5c08c..2e9b3d009 100644 --- a/src/lib/teact/teact.ts +++ b/src/lib/teact/teact.ts @@ -528,6 +528,8 @@ function forceUpdateComponent(componentInstance: ComponentInstance) { } } +export function useState(): [T | undefined, StateHookSetter]; +export function useState(initial: T, debugKey?: string): [T, StateHookSetter]; export function useState(initial?: T, debugKey?: string): [T, StateHookSetter] { const { cursor, byCursor } = renderingInstance.hooks.state;