Drop expired stories from selector
This commit is contained in:
parent
538a809395
commit
449a9a701a
1 changed files with 16 additions and 0 deletions
|
@ -36,6 +36,7 @@ import { getDistributionListSelector } from './storyDistributionLists';
|
||||||
import { getStoriesEnabled } from './items';
|
import { getStoriesEnabled } from './items';
|
||||||
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
|
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
|
||||||
import { getMessageIdForLogging } from '../../util/idForLogging';
|
import { getMessageIdForLogging } from '../../util/idForLogging';
|
||||||
|
import * as log from '../../logging/log';
|
||||||
|
|
||||||
export const getStoriesState = (state: StateType): StoriesStateType =>
|
export const getStoriesState = (state: StateType): StoriesStateType =>
|
||||||
state.stories;
|
state.stories;
|
||||||
|
@ -343,6 +344,21 @@ export const getStories = createSelector(
|
||||||
return;
|
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(
|
const conversationStory = getConversationStory(
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue