Story: Fix various problems (#5935)
This commit is contained in:
parent
bd096e2a01
commit
eaca13c851
@ -119,7 +119,7 @@ export function addDocumentToLocalDb(document: GramJs.TypeDocument) {
|
|||||||
export function addStoryRepairInfo<T extends GramJs.TypeDocument | GramJs.TypeWebDocument | GramJs.TypePhoto>(
|
export function addStoryRepairInfo<T extends GramJs.TypeDocument | GramJs.TypeWebDocument | GramJs.TypePhoto>(
|
||||||
media: T, peerId: string, story: GramJs.TypeStoryItem,
|
media: T, peerId: string, story: GramJs.TypeStoryItem,
|
||||||
): T & RepairInfo {
|
): T & RepairInfo {
|
||||||
if (!(media instanceof GramJs.Document && media instanceof GramJs.Photo)) return media;
|
if (!(media instanceof GramJs.Document || media instanceof GramJs.Photo)) return media;
|
||||||
const repairableMedia = media as T & RepairInfo;
|
const repairableMedia = media as T & RepairInfo;
|
||||||
repairableMedia.localRepairInfo = {
|
repairableMedia.localRepairInfo = {
|
||||||
type: 'story',
|
type: 'story',
|
||||||
|
|||||||
@ -489,7 +489,6 @@ export async function repairFileReference({
|
|||||||
url: string;
|
url: string;
|
||||||
}) {
|
}) {
|
||||||
const parsed = parseMediaUrl(url);
|
const parsed = parseMediaUrl(url);
|
||||||
|
|
||||||
if (!parsed) return undefined;
|
if (!parsed) return undefined;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -65,21 +65,22 @@ function StoryCaption({
|
|||||||
canExpand, undefined, true, 'slow', true,
|
canExpand, undefined, true, 'slow', true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Setup gradient to clip caption before button
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
requestMeasure(() => {
|
requestMeasure(() => {
|
||||||
if (!showMoreButtonRef.current) {
|
const container = contentRef.current;
|
||||||
|
const button = showMoreButtonRef.current;
|
||||||
|
if (!container || !button) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const button = showMoreButtonRef.current;
|
|
||||||
|
|
||||||
const { offsetWidth } = button;
|
const { offsetWidth } = button;
|
||||||
|
|
||||||
requestMutation(() => {
|
requestMutation(() => {
|
||||||
button.style.setProperty('--expand-button-width', `${offsetWidth}px`);
|
container.style.setProperty('--expand-button-width', `${offsetWidth}px`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, []);
|
}, [shouldRenderShowMore, lang]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
requestForcedReflow(() => {
|
requestForcedReflow(() => {
|
||||||
|
|||||||
@ -97,7 +97,7 @@ function StoryPreview({
|
|||||||
export default memo(withGlobal<OwnProps>((global, { peer }): StateProps => {
|
export default memo(withGlobal<OwnProps>((global, { peer }): StateProps => {
|
||||||
const {
|
const {
|
||||||
storyViewer: {
|
storyViewer: {
|
||||||
lastViewedByPeerIds,
|
lastViewedByPeerId: lastViewedByPeerIds,
|
||||||
origin,
|
origin,
|
||||||
storyList,
|
storyList,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -97,7 +97,7 @@ addActionHandler('closeStoryViewer', (global, actions, payload): ActionReturnTyp
|
|||||||
isMuted,
|
isMuted,
|
||||||
isRibbonShown,
|
isRibbonShown,
|
||||||
isArchivedRibbonShown,
|
isArchivedRibbonShown,
|
||||||
lastViewedByPeerIds: undefined,
|
lastViewedByPeerId: undefined,
|
||||||
storyList: undefined,
|
storyList: undefined,
|
||||||
},
|
},
|
||||||
}, tabId);
|
}, tabId);
|
||||||
|
|||||||
@ -47,10 +47,9 @@ function checkStoryExpiration() {
|
|||||||
Object.values(global.stories.byPeerId).forEach((peerStories) => {
|
Object.values(global.stories.byPeerId).forEach((peerStories) => {
|
||||||
const stories = Object.values(peerStories.byId);
|
const stories = Object.values(peerStories.byId);
|
||||||
stories.forEach((story) => {
|
stories.forEach((story) => {
|
||||||
if (!('expireDate' in story)) return;
|
if (story['@type'] !== 'story') return;
|
||||||
if (story.expireDate > serverTime) return;
|
if (story.expireDate > serverTime) return;
|
||||||
if ('isInProfile' in story && story.isInProfile) return;
|
if (story.isInProfile) return;
|
||||||
if ('isPublic' in story && !story.isPublic) return;
|
|
||||||
|
|
||||||
global = removePeerStory(global, story.peerId, story.id);
|
global = removePeerStory(global, story.peerId, story.id);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -200,8 +200,8 @@ export function updateLastViewedStoryForPeer<T extends GlobalState>(
|
|||||||
return updateTabState(global, {
|
return updateTabState(global, {
|
||||||
storyViewer: {
|
storyViewer: {
|
||||||
...storyViewer,
|
...storyViewer,
|
||||||
lastViewedByPeerIds: {
|
lastViewedByPeerId: {
|
||||||
...storyViewer.lastViewedByPeerIds,
|
...storyViewer.lastViewedByPeerId,
|
||||||
[peerId]: lastViewedId,
|
[peerId]: lastViewedId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -313,7 +313,7 @@ export function removePeerStory<T extends GlobalState>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
Object.values(global.byTabId).forEach((tab) => {
|
Object.values(global.byTabId).forEach((tab) => {
|
||||||
if (tab.storyViewer.lastViewedByPeerIds?.[peerId] === storyId) {
|
if (tab.storyViewer.lastViewedByPeerId && tab.storyViewer.lastViewedByPeerId[peerId] === storyId) {
|
||||||
global = updateLastViewedStoryForPeer(global, peerId, previousStoryId, tab.id);
|
global = updateLastViewedStoryForPeer(global, peerId, previousStoryId, tab.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -303,7 +303,7 @@ export type TabState = {
|
|||||||
isArchive?: boolean;
|
isArchive?: boolean;
|
||||||
// Last viewed story id in current view session.
|
// Last viewed story id in current view session.
|
||||||
// Used for better switch animation between peers.
|
// Used for better switch animation between peers.
|
||||||
lastViewedByPeerIds?: Record<string, number>;
|
lastViewedByPeerId?: Record<string, number>;
|
||||||
isPrivacyModalOpen?: boolean;
|
isPrivacyModalOpen?: boolean;
|
||||||
isPaymentConfirmDialogOpen?: boolean;
|
isPaymentConfirmDialogOpen?: boolean;
|
||||||
isStealthModalOpen?: boolean;
|
isStealthModalOpen?: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user