From 96b41e8663db8adac445a4f1fcdb0a7ddf6afc77 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Tue, 11 Nov 2025 14:37:40 +0100 Subject: [PATCH] Story: Fix unsupported display (#6452) --- src/assets/localization/fallback.strings | 1 + src/components/story/MediaStory.module.scss | 2 +- src/components/story/MediaStory.tsx | 28 +++++++++++++------- src/components/story/Story.tsx | 22 ++++++++++----- src/components/story/StoryViewer.module.scss | 10 +++++++ src/global/helpers/media.ts | 7 ++++- src/types/language.d.ts | 1 + 7 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/assets/localization/fallback.strings b/src/assets/localization/fallback.strings index 4e6abf16b..2ff807534 100644 --- a/src/assets/localization/fallback.strings +++ b/src/assets/localization/fallback.strings @@ -2315,3 +2315,4 @@ "UserNoteHint" = "only visible to you"; "EditUserNoteHint" = "Notes are only visible to you."; "AriaStoryTogglerOpen" = "Open Story List"; +"StoryUnsupported" = "This story is not supported in Telegram Web A. Try viewing it in the Telegram app."; diff --git a/src/components/story/MediaStory.module.scss b/src/components/story/MediaStory.module.scss index 1069a33ea..b8c372c3c 100644 --- a/src/components/story/MediaStory.module.scss +++ b/src/components/story/MediaStory.module.scss @@ -22,7 +22,7 @@ object-fit: cover; } -.expiredIcon { +.mainIcon { font-size: 1.25rem; line-height: 0.9375rem; vertical-align: -0.1875rem; diff --git a/src/components/story/MediaStory.tsx b/src/components/story/MediaStory.tsx index 023037c1a..ad691be74 100644 --- a/src/components/story/MediaStory.tsx +++ b/src/components/story/MediaStory.tsx @@ -1,4 +1,3 @@ -import type React from '../../lib/teact/teact'; import { memo, useCallback, useEffect, useRef, } from '../../lib/teact/teact'; @@ -14,6 +13,7 @@ import stopEvent from '../../util/stopEvent'; import { preventMessageInputBlurWithBubbling } from '../middle/helpers/preventMessageInputBlur'; import useContextMenuHandlers from '../../hooks/useContextMenuHandlers'; +import useLang from '../../hooks/useLang'; import useLastCallback from '../../hooks/useLastCallback'; import useMedia from '../../hooks/useMedia'; import useOldLang from '../../hooks/useOldLang'; @@ -47,7 +47,8 @@ function MediaStory({ showNotification, } = getActions(); - const lang = useOldLang(); + const lang = useLang(); + const oldLang = useOldLang(); const containerRef = useRef(); const getTriggerElement = useLastCallback(() => containerRef.current); @@ -59,6 +60,7 @@ function MediaStory({ const isFullyLoaded = story && 'content' in story; const isOwn = isFullyLoaded && story.isOut; const isDeleted = story && 'isDeleted' in story; + const isUnsupportedStory = isFullyLoaded && Object.keys(story.content).length === 0; const video = isFullyLoaded ? (story).content.video : undefined; const duration = video && formatMediaDuration(video.duration); const imageHash = isFullyLoaded ? getStoryMediaHash(story) : undefined; @@ -97,7 +99,7 @@ function MediaStory({ toggleStoryInProfile({ peerId, storyId: story.id, isInProfile: true }); showNotification({ - message: lang('Story.ToastSavedToProfileText'), + message: oldLang('Story.ToastSavedToProfileText'), }); handleContextMenuClose(); }); @@ -107,7 +109,7 @@ function MediaStory({ toggleStoryInProfile({ peerId, storyId: story.id, isInProfile: false }); showNotification({ - message: lang('Story.ToastRemovedFromProfileText'), + message: oldLang('Story.ToastRemovedFromProfileText'), }); handleContextMenuClose(); }); @@ -127,8 +129,14 @@ function MediaStory({ > {isDeleted && ( - - {lang('ExpiredStory')} + + {oldLang('ExpiredStory')} + + )} + {isUnsupportedStory && ( + + + {lang('StoryUnsupported')} )} {isPinned && } @@ -162,22 +170,22 @@ function MediaStory({ > {isArchive && ( - {lang('StoryList.SaveToProfile')} + {oldLang('StoryList.SaveToProfile')} )} {!isArchive && ( - {lang('Story.Context.RemoveFromProfile')} + {oldLang('Story.Context.RemoveFromProfile')} )} {!isArchive && !isPinned && canPin && ( - {lang('StoryList.ItemAction.Pin')} + {oldLang('StoryList.ItemAction.Pin')} )} {!isArchive && isPinned && ( - {lang('StoryList.ItemAction.Unpin')} + {oldLang('StoryList.ItemAction.Unpin')} )} diff --git a/src/components/story/Story.tsx b/src/components/story/Story.tsx index f739d1e81..7c9dc75cc 100644 --- a/src/components/story/Story.tsx +++ b/src/components/story/Story.tsx @@ -197,6 +197,7 @@ function Story({ const isChatStory = !isUserStory; const isChannelStory = isChatStory && isChatChannel(peer as ApiChat); const isOut = isLoadedStory && story.isOut; + const isUnsupportedStory = isLoadedStory && Object.keys(story.content).length === 0; const canPinToProfile = useCurrentOrPrev( isOut ? !story.isInProfile : undefined, @@ -229,7 +230,8 @@ function Story({ ); const canPlayStory = Boolean( - hasFullData && !shouldForcePause && isAppFocused && !isComposerHasFocus && !isCaptionExpanded + (hasFullData || isUnsupportedStory) + && !shouldForcePause && isAppFocused && !isComposerHasFocus && !isCaptionExpanded && !isPausedBySpacebar && !isPausedByLongPress, ); @@ -244,11 +246,11 @@ function Story({ const { shouldRender: shouldRenderSkeleton, transitionClassNames: skeletonTransitionClassNames, - } = useShowTransitionDeprecated(!hasFullData); + } = useShowTransitionDeprecated(!hasFullData && !isUnsupportedStory); const { transitionClassNames: mediaTransitionClassNames, - } = useShowTransitionDeprecated(Boolean(fullMediaData)); + } = useShowTransitionDeprecated(Boolean(fullMediaData) && !isUnsupportedStory); const thumbRef = useCanvasBlur(thumbnail, !hasThumb); const previewTransitionClassNames = useMediaTransitionDeprecated(previewBlobUrl); @@ -340,17 +342,17 @@ function Story({ onEnd: handleLongPressEnd, }); - const isUnsupported = useUnsupportedMedia( + const isUnsupportedVideo = useUnsupportedMedia( videoRef, undefined, !isVideo || !fullMediaData || isStreamingSupported, ); const hasAllData = fullMediaData && (!altMediaHash || altMediaData); - // Play story after media has been downloaded useEffect(() => { - if (hasAllData && !isUnsupported) handlePlayStory(); - }, [hasAllData, isUnsupported]); + // Start progress to the nest slide after media has been downloaded or it is unsupported + if (hasAllData || isUnsupportedVideo || isUnsupportedStory) handlePlayStory(); + }, [hasAllData, isUnsupportedVideo, isUnsupportedStory]); useBackgroundMode(unmarkAppFocused, markAppFocused); @@ -842,6 +844,12 @@ function Story({ )} + {isUnsupportedStory && ( +
+ {lang('StoryUnsupported')} +
+ )} + {!isPausedByLongPress && !isComposerHasFocus && ( <>