markStoryRead: More logging in unusual cases
This commit is contained in:
parent
b65890b07d
commit
44db76531e
8 changed files with 47 additions and 9 deletions
|
@ -53,6 +53,7 @@ SomeonesStory.args = {
|
|||
hasReplies: true,
|
||||
isUnread: true,
|
||||
messageId: '123',
|
||||
messageIdForLogging: 'for logging 123',
|
||||
sender: getDefaultConversation(),
|
||||
timestamp: Date.now(),
|
||||
expirationTimestamp: undefined,
|
||||
|
|
|
@ -145,8 +145,15 @@ export const StoryViewer = ({
|
|||
StoryViewType | undefined
|
||||
>();
|
||||
|
||||
const { attachment, canReply, isHidden, messageId, sendState, timestamp } =
|
||||
story;
|
||||
const {
|
||||
attachment,
|
||||
canReply,
|
||||
isHidden,
|
||||
messageId,
|
||||
messageIdForLogging,
|
||||
sendState,
|
||||
timestamp,
|
||||
} = story;
|
||||
const {
|
||||
acceptedMessageRequest,
|
||||
avatarPath,
|
||||
|
@ -323,8 +330,8 @@ export const StoryViewer = ({
|
|||
|
||||
useEffect(() => {
|
||||
markStoryRead(messageId);
|
||||
log.info('stories.markStoryRead', { messageId });
|
||||
}, [markStoryRead, messageId]);
|
||||
log.info('stories.markStoryRead', { message: messageIdForLogging });
|
||||
}, [markStoryRead, messageId, messageIdForLogging]);
|
||||
|
||||
const canFreelyNavigateStories =
|
||||
storyViewMode === StoryViewModeType.All ||
|
||||
|
|
|
@ -72,7 +72,9 @@ export function getContact(
|
|||
return window.ConversationController.get(id);
|
||||
}
|
||||
|
||||
export function getSource(message: MessageAttributesType): string | undefined {
|
||||
export function getSource(
|
||||
message: Pick<MessageAttributesType, 'type' | 'source'>
|
||||
): string | undefined {
|
||||
if (isIncoming(message) || isStory(message)) {
|
||||
return message.source;
|
||||
}
|
||||
|
@ -84,7 +86,7 @@ export function getSource(message: MessageAttributesType): string | undefined {
|
|||
}
|
||||
|
||||
export function getSourceDevice(
|
||||
message: MessageAttributesType
|
||||
message: Pick<MessageAttributesType, 'type' | 'sourceDevice'>
|
||||
): string | number | undefined {
|
||||
const { sourceDevice } = message;
|
||||
|
||||
|
@ -101,7 +103,7 @@ export function getSourceDevice(
|
|||
}
|
||||
|
||||
export function getSourceUuid(
|
||||
message: MessageAttributesType
|
||||
message: Pick<MessageAttributesType, 'type' | 'sourceUuid'>
|
||||
): UUIDStringType | undefined {
|
||||
if (isIncoming(message) || isStory(message)) {
|
||||
return message.sourceUuid;
|
||||
|
|
|
@ -72,6 +72,7 @@ export type StoryDataType = {
|
|||
| 'sendStateByConversationId'
|
||||
| 'source'
|
||||
| 'sourceUuid'
|
||||
| 'sourceDevice'
|
||||
| 'storyDistributionListId'
|
||||
| 'timestamp'
|
||||
| 'type'
|
||||
|
@ -426,16 +427,27 @@ function markStoryRead(
|
|||
!isDownloaded(matchingStory.attachment) &&
|
||||
!hasFailed(matchingStory.attachment)
|
||||
) {
|
||||
log.warn(
|
||||
`markStoryRead: not downloaded: ${messageId} ${
|
||||
matchingStory.attachment?.error
|
||||
? `error: ${matchingStory.attachment?.error}`
|
||||
: ''
|
||||
}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (matchingStory.readStatus !== ReadStatus.Unread) {
|
||||
log.warn(
|
||||
`markStoryRead: not unread, ${messageId} read status: ${matchingStory.readStatus}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const message = await getMessageById(messageId);
|
||||
|
||||
if (!message) {
|
||||
log.warn(`markStoryRead: no message found ${messageId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import { getUserConversationId } from './user';
|
|||
import { getDistributionListSelector } from './storyDistributionLists';
|
||||
import { getStoriesEnabled } from './items';
|
||||
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
|
||||
import { getMessageIdForLogging } from '../../util/idForLogging';
|
||||
|
||||
export const getStoriesState = (state: StateType): StoriesStateType =>
|
||||
state.stories;
|
||||
|
@ -191,12 +192,18 @@ export function getStoryView(
|
|||
views = innerViews;
|
||||
}
|
||||
|
||||
const messageIdForLogging = getMessageIdForLogging({
|
||||
...pick(story, 'type', 'sourceUuid', 'sourceDevice'),
|
||||
sent_at: story.timestamp,
|
||||
});
|
||||
|
||||
return {
|
||||
attachment,
|
||||
canReply: canReply(story, ourConversationId, conversationSelector),
|
||||
isHidden: Boolean(sender.hideStory),
|
||||
isUnread: story.readStatus === ReadStatus.Unread,
|
||||
messageId: story.messageId,
|
||||
messageIdForLogging,
|
||||
readAt,
|
||||
sender,
|
||||
sendState,
|
||||
|
|
|
@ -43,13 +43,16 @@ export function getFakeStoryView(
|
|||
): StoryViewType {
|
||||
const sender = getDefaultConversation();
|
||||
|
||||
const messageId = UUID.generate().toString();
|
||||
|
||||
return {
|
||||
attachment: getAttachmentWithThumbnail(
|
||||
attachmentUrl || '/fixtures/tina-rolf-269345-unsplash.jpg'
|
||||
),
|
||||
hasReplies: Boolean(casual.coin_flip),
|
||||
isUnread: Boolean(casual.coin_flip),
|
||||
messageId: UUID.generate().toString(),
|
||||
messageId,
|
||||
messageIdForLogging: `${messageId} (for logging)`,
|
||||
sender,
|
||||
timestamp: timestamp || Date.now() - 2 * durations.MINUTE,
|
||||
expirationTimestamp: undefined,
|
||||
|
|
|
@ -73,6 +73,7 @@ export type StoryViewType = {
|
|||
isHidden?: boolean;
|
||||
isUnread?: boolean;
|
||||
messageId: string;
|
||||
messageIdForLogging: string;
|
||||
readAt?: number;
|
||||
sender: Pick<
|
||||
ConversationType,
|
||||
|
|
|
@ -8,7 +8,12 @@ import type {
|
|||
import { getSource, getSourceDevice, getSourceUuid } from '../messages/helpers';
|
||||
import { isDirectConversation, isGroupV2 } from './whatTypeOfConversation';
|
||||
|
||||
export function getMessageIdForLogging(message: MessageAttributesType): string {
|
||||
export function getMessageIdForLogging(
|
||||
message: Pick<
|
||||
MessageAttributesType,
|
||||
'type' | 'sourceUuid' | 'sourceDevice' | 'sent_at'
|
||||
>
|
||||
): string {
|
||||
const account = getSourceUuid(message) || getSource(message);
|
||||
const device = getSourceDevice(message);
|
||||
const timestamp = message.sent_at;
|
||||
|
|
Loading…
Add table
Reference in a new issue