Drop expired stories from selector
Co-authored-by: Alvaro <110414366+alvaro-signal@users.noreply.github.com>
This commit is contained in:
parent
b99437578c
commit
859092a541
|
@ -36,6 +36,7 @@ import { getDistributionListSelector } from './storyDistributionLists';
|
|||
import { getStoriesEnabled } from './items';
|
||||
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
|
||||
import { getMessageIdForLogging } from '../../util/idForLogging';
|
||||
import * as log from '../../logging/log';
|
||||
|
||||
export const getStoriesState = (state: StateType): StoriesStateType =>
|
||||
state.stories;
|
||||
|
@ -342,6 +343,21 @@ export const getStories = createSelector(
|
|||
return;
|
||||
}
|
||||
|
||||
// if for some reason this story is already experied (bug)
|
||||
// log it and skip it
|
||||
if ((calculateExpirationTimestamp(story) ?? 0) < Date.now()) {
|
||||
const messageIdForLogging = getMessageIdForLogging({
|
||||
...pick(story, 'type', 'sourceUuid', 'sourceDevice'),
|
||||
sent_at: story.timestamp,
|
||||
});
|
||||
log.warn('selectors/getStories: story already expired', {
|
||||
message: messageIdForLogging,
|
||||
expireTimer: story.expireTimer,
|
||||
expirationStartTimestamp: story.expirationStartTimestamp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const conversationStory = getConversationStory(
|
||||
conversationSelector,
|
||||
ourConversationId,
|
||||
|
|
Loading…
Reference in New Issue