2021-03-03 20:09:58 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-26 20:31:41 +00:00
|
|
|
import * as React from 'react';
|
2021-06-02 17:27:12 +00:00
|
|
|
import * as moment from 'moment';
|
|
|
|
import { isBoolean, times } from 'lodash';
|
2021-06-01 23:30:25 +00:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2020-08-26 20:31:41 +00:00
|
|
|
import { storiesOf } from '@storybook/react';
|
2021-04-05 23:12:00 +00:00
|
|
|
import { text, boolean, number } from '@storybook/addon-knobs';
|
2020-08-26 20:31:41 +00:00
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
|
|
|
import { setup as setupI18n } from '../../../js/modules/i18n';
|
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
2020-12-01 16:42:35 +00:00
|
|
|
import { PropsType, Timeline } from './Timeline';
|
2020-08-26 20:31:41 +00:00
|
|
|
import { TimelineItem, TimelineItemType } from './TimelineItem';
|
2021-04-05 23:12:00 +00:00
|
|
|
import { ConversationHero } from './ConversationHero';
|
2021-04-21 16:31:12 +00:00
|
|
|
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
|
2020-08-26 20:31:41 +00:00
|
|
|
import { LastSeenIndicator } from './LastSeenIndicator';
|
|
|
|
import { TimelineLoadingRow } from './TimelineLoadingRow';
|
|
|
|
import { TypingBubble } from './TypingBubble';
|
2021-06-01 23:30:25 +00:00
|
|
|
import { ContactSpoofingType } from '../../util/contactSpoofing';
|
2020-08-26 20:31:41 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf('Components/Conversation/Timeline', module);
|
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
// eslint-disable-next-line
|
2020-08-26 20:31:41 +00:00
|
|
|
const noop = () => {};
|
|
|
|
|
|
|
|
Object.assign(window, {
|
|
|
|
registerForActive: noop,
|
|
|
|
unregisterForActive: noop,
|
|
|
|
});
|
|
|
|
|
|
|
|
const items: Record<string, TimelineItemType> = {
|
|
|
|
'id-1': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({
|
2021-04-30 22:59:37 +00:00
|
|
|
phoneNumber: '(202) 555-2001',
|
2021-05-28 16:15:17 +00:00
|
|
|
color: 'forest',
|
2021-06-02 17:27:12 +00:00
|
|
|
}),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'forest',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
|
|
|
direction: 'incoming',
|
|
|
|
id: 'id-1',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
text: '🔥',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-2': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'forest' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'forest',
|
|
|
|
conversationId: 'conversation-id',
|
2020-08-26 20:31:41 +00:00
|
|
|
conversationType: 'group',
|
|
|
|
direction: 'incoming',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-2',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
text: 'Hello there from the new world! http://somewhere.com',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-2.5': {
|
|
|
|
type: 'unsupportedMessage',
|
|
|
|
data: {
|
|
|
|
id: 'id-2.5',
|
|
|
|
canProcessNow: false,
|
|
|
|
contact: {
|
2021-06-02 17:27:12 +00:00
|
|
|
id: '061d3783-5736-4145-b1a2-6b6cf1156393',
|
|
|
|
isMe: false,
|
2020-08-26 20:31:41 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
profileName: 'Mr. Pig',
|
|
|
|
title: 'Mr. Pig',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-3': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'crimson' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'crimson',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'incoming',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-3',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
text: 'Hello there from the new world!',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-4': {
|
|
|
|
type: 'timerNotification',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
disabled: false,
|
|
|
|
expireTimer: moment.duration(2, 'hours').asSeconds(),
|
|
|
|
title: "It's Me",
|
2020-08-26 20:31:41 +00:00
|
|
|
type: 'fromMe',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-5': {
|
|
|
|
type: 'timerNotification',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
disabled: false,
|
|
|
|
expireTimer: moment.duration(2, 'hours').asSeconds(),
|
2020-08-26 20:31:41 +00:00
|
|
|
phoneNumber: '(202) 555-0000',
|
2021-06-02 17:27:12 +00:00
|
|
|
title: '(202) 555-0000',
|
|
|
|
type: 'fromOther',
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-6': {
|
|
|
|
type: 'safetyNumberNotification',
|
|
|
|
data: {
|
|
|
|
contact: {
|
|
|
|
id: '+1202555000',
|
|
|
|
phoneNumber: '(202) 555-0000',
|
|
|
|
profileName: 'Mr. Fire',
|
2021-06-02 17:27:12 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
2021-06-02 17:27:12 +00:00
|
|
|
isGroup: true,
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-7': {
|
|
|
|
type: 'verificationNotification',
|
|
|
|
data: {
|
|
|
|
contact: {
|
|
|
|
name: 'Mrs. Ice',
|
2021-06-02 17:27:12 +00:00
|
|
|
phoneNumber: '(202) 555-0001',
|
|
|
|
title: 'Mrs. Ice',
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
isLocal: true,
|
|
|
|
type: 'markVerified',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-8': {
|
|
|
|
type: 'groupNotification',
|
|
|
|
data: {
|
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'name',
|
|
|
|
newName: 'Squirrels and their uses',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
|
|
|
{
|
|
|
|
phoneNumber: '(202) 555-0002',
|
|
|
|
profileName: 'Mr. Fire',
|
|
|
|
title: 'Mr. Fire',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
phoneNumber: '(202) 555-0003',
|
|
|
|
profileName: 'Ms. Water',
|
|
|
|
title: 'Ms. Water',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
from: {
|
|
|
|
phoneNumber: '(202) 555-0001',
|
|
|
|
name: 'Mrs. Ice',
|
|
|
|
title: 'Mrs. Ice',
|
2021-06-02 17:27:12 +00:00
|
|
|
isMe: false,
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-9': {
|
|
|
|
type: 'resetSessionNotification',
|
|
|
|
data: null,
|
|
|
|
},
|
|
|
|
'id-10': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'plum' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'plum',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'outgoing',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-6',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
status: 'sent',
|
|
|
|
text: '🔥',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-11': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'plum' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'crimson',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'outgoing',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-7',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
status: 'read',
|
|
|
|
text: 'Hello there from the new world! http://somewhere.com',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-12': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'crimson' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'crimson',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'outgoing',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-8',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
status: 'sent',
|
|
|
|
text: 'Hello there from the new world! 🔥',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-13': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'blue' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'crimson',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'outgoing',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-9',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
status: 'sent',
|
|
|
|
text:
|
|
|
|
'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-14': {
|
|
|
|
type: 'message',
|
|
|
|
data: {
|
2021-06-02 17:27:12 +00:00
|
|
|
author: getDefaultConversation({ color: 'crimson' }),
|
|
|
|
canDeleteForEveryone: false,
|
|
|
|
canDownload: true,
|
|
|
|
canReply: true,
|
|
|
|
conversationColor: 'crimson',
|
|
|
|
conversationId: 'conversation-id',
|
|
|
|
conversationType: 'group',
|
2020-08-26 20:31:41 +00:00
|
|
|
direction: 'outgoing',
|
2021-06-02 17:27:12 +00:00
|
|
|
id: 'id-10',
|
|
|
|
isBlocked: false,
|
|
|
|
isMessageRequestAccepted: true,
|
|
|
|
previews: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
status: 'read',
|
|
|
|
text:
|
|
|
|
'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.',
|
2021-06-02 17:27:12 +00:00
|
|
|
timestamp: Date.now(),
|
2020-08-26 20:31:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'id-15': {
|
|
|
|
type: 'linkNotification',
|
|
|
|
data: null,
|
|
|
|
},
|
2021-06-02 17:27:12 +00:00
|
|
|
};
|
2020-08-26 20:31:41 +00:00
|
|
|
|
|
|
|
const actions = () => ({
|
2021-06-01 23:30:25 +00:00
|
|
|
acknowledgeGroupMemberNameCollisions: action(
|
|
|
|
'acknowledgeGroupMemberNameCollisions'
|
|
|
|
),
|
2020-08-26 20:31:41 +00:00
|
|
|
clearChangedMessages: action('clearChangedMessages'),
|
2021-03-03 20:09:58 +00:00
|
|
|
clearInvitedConversationsForNewlyCreatedGroup: action(
|
|
|
|
'clearInvitedConversationsForNewlyCreatedGroup'
|
|
|
|
),
|
2020-08-26 20:31:41 +00:00
|
|
|
setLoadCountdownStart: action('setLoadCountdownStart'),
|
|
|
|
setIsNearBottom: action('setIsNearBottom'),
|
|
|
|
loadAndScroll: action('loadAndScroll'),
|
|
|
|
loadOlderMessages: action('loadOlderMessages'),
|
|
|
|
loadNewerMessages: action('loadNewerMessages'),
|
|
|
|
loadNewestMessages: action('loadNewestMessages'),
|
|
|
|
markMessageRead: action('markMessageRead'),
|
|
|
|
selectMessage: action('selectMessage'),
|
|
|
|
clearSelectedMessage: action('clearSelectedMessage'),
|
|
|
|
updateSharedGroups: action('updateSharedGroups'),
|
|
|
|
|
|
|
|
reactToMessage: action('reactToMessage'),
|
|
|
|
replyToMessage: action('replyToMessage'),
|
|
|
|
retrySend: action('retrySend'),
|
|
|
|
deleteMessage: action('deleteMessage'),
|
2020-09-29 22:55:56 +00:00
|
|
|
deleteMessageForEveryone: action('deleteMessageForEveryone'),
|
2020-08-26 20:31:41 +00:00
|
|
|
showMessageDetail: action('showMessageDetail'),
|
|
|
|
openConversation: action('openConversation'),
|
|
|
|
showContactDetail: action('showContactDetail'),
|
2020-11-11 17:36:05 +00:00
|
|
|
showContactModal: action('showContactModal'),
|
2021-01-29 22:58:28 +00:00
|
|
|
kickOffAttachmentDownload: action('kickOffAttachmentDownload'),
|
2021-03-22 18:51:53 +00:00
|
|
|
markAttachmentAsCorrupted: action('markAttachmentAsCorrupted'),
|
2020-08-26 20:31:41 +00:00
|
|
|
showVisualAttachment: action('showVisualAttachment'),
|
|
|
|
downloadAttachment: action('downloadAttachment'),
|
|
|
|
displayTapToViewMessage: action('displayTapToViewMessage'),
|
|
|
|
|
|
|
|
openLink: action('openLink'),
|
|
|
|
scrollToQuotedMessage: action('scrollToQuotedMessage'),
|
|
|
|
showExpiredIncomingTapToViewToast: action(
|
|
|
|
'showExpiredIncomingTapToViewToast'
|
|
|
|
),
|
|
|
|
showExpiredOutgoingTapToViewToast: action(
|
|
|
|
'showExpiredOutgoingTapToViewToast'
|
|
|
|
),
|
2021-04-27 22:35:35 +00:00
|
|
|
showForwardMessageModal: action('showForwardMessageModal'),
|
2020-08-26 20:31:41 +00:00
|
|
|
|
|
|
|
showIdentity: action('showIdentity'),
|
|
|
|
|
|
|
|
downloadNewVersion: action('downloadNewVersion'),
|
2020-12-07 20:43:19 +00:00
|
|
|
|
|
|
|
messageSizeChanged: action('messageSizeChanged'),
|
|
|
|
startCallingLobby: action('startCallingLobby'),
|
|
|
|
returnToActiveCall: action('returnToActiveCall'),
|
2021-02-18 16:40:26 +00:00
|
|
|
|
|
|
|
contactSupport: action('contactSupport'),
|
2021-04-21 16:31:12 +00:00
|
|
|
|
|
|
|
closeContactSpoofingReview: action('closeContactSpoofingReview'),
|
2021-06-01 23:30:25 +00:00
|
|
|
reviewGroupMemberNameCollision: action('reviewGroupMemberNameCollision'),
|
2021-04-21 16:31:12 +00:00
|
|
|
reviewMessageRequestNameCollision: action(
|
|
|
|
'reviewMessageRequestNameCollision'
|
|
|
|
),
|
|
|
|
|
|
|
|
onBlock: action('onBlock'),
|
2021-05-27 20:17:05 +00:00
|
|
|
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
2021-04-21 16:31:12 +00:00
|
|
|
onDelete: action('onDelete'),
|
|
|
|
onUnblock: action('onUnblock'),
|
2021-06-01 23:30:25 +00:00
|
|
|
removeMember: action('removeMember'),
|
2021-04-30 19:40:25 +00:00
|
|
|
|
|
|
|
unblurAvatar: action('unblurAvatar'),
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const renderItem = (id: string) => (
|
|
|
|
<TimelineItem
|
|
|
|
id=""
|
|
|
|
isSelected={false}
|
|
|
|
renderEmojiPicker={() => <div />}
|
|
|
|
item={items[id]}
|
|
|
|
i18n={i18n}
|
2021-03-24 22:06:12 +00:00
|
|
|
interactionMode="keyboard"
|
2020-08-26 20:31:41 +00:00
|
|
|
conversationId=""
|
|
|
|
conversationAccepted
|
2020-09-09 02:25:05 +00:00
|
|
|
renderContact={() => '*ContactName*'}
|
2021-06-01 20:45:43 +00:00
|
|
|
renderUniversalTimerNotification={() => (
|
|
|
|
<div>*UniversalTimerNotification*</div>
|
|
|
|
)}
|
2021-03-10 20:36:58 +00:00
|
|
|
renderAudioAttachment={() => <div>*AudioAttachment*</div>}
|
2020-08-26 20:31:41 +00:00
|
|
|
{...actions()}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderLastSeenIndicator = () => (
|
|
|
|
<LastSeenIndicator count={2} i18n={i18n} />
|
|
|
|
);
|
2021-04-05 23:12:00 +00:00
|
|
|
|
|
|
|
const getAbout = () => text('about', '👍 Free to chat');
|
|
|
|
const getTitle = () => text('name', 'Cayce Bollard');
|
|
|
|
const getName = () => text('name', 'Cayce Bollard');
|
|
|
|
const getProfileName = () => text('profileName', 'Cayce Bollard (profile)');
|
|
|
|
const getAvatarPath = () =>
|
|
|
|
text('avatarPath', '/fixtures/kitten-4-112-112.jpg');
|
|
|
|
const getPhoneNumber = () => text('phoneNumber', '+1 (808) 555-1234');
|
|
|
|
|
|
|
|
const renderHeroRow = () => (
|
|
|
|
<ConversationHero
|
|
|
|
about={getAbout()}
|
2021-05-07 22:21:10 +00:00
|
|
|
acceptedMessageRequest
|
2021-04-05 23:12:00 +00:00
|
|
|
i18n={i18n}
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe={false}
|
2021-04-05 23:12:00 +00:00
|
|
|
title={getTitle()}
|
|
|
|
avatarPath={getAvatarPath()}
|
|
|
|
name={getName()}
|
|
|
|
profileName={getProfileName()}
|
|
|
|
phoneNumber={getPhoneNumber()}
|
|
|
|
conversationType="direct"
|
|
|
|
sharedGroupNames={['NYC Rock Climbers', 'Dinner Party']}
|
2021-04-30 19:40:25 +00:00
|
|
|
unblurAvatar={action('unblurAvatar')}
|
2021-04-30 22:58:57 +00:00
|
|
|
updateSharedGroups={noop}
|
2021-04-05 23:12:00 +00:00
|
|
|
/>
|
|
|
|
);
|
2020-08-26 20:31:41 +00:00
|
|
|
const renderLoadingRow = () => <TimelineLoadingRow state="loading" />;
|
|
|
|
const renderTypingBubble = () => (
|
|
|
|
<TypingBubble
|
2021-05-07 22:21:10 +00:00
|
|
|
acceptedMessageRequest
|
2021-05-28 16:15:17 +00:00
|
|
|
color="crimson"
|
2020-08-26 20:31:41 +00:00
|
|
|
conversationType="direct"
|
|
|
|
phoneNumber="+18005552222"
|
|
|
|
i18n={i18n}
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe={false}
|
2020-08-26 20:31:41 +00:00
|
|
|
title="title"
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames={[]}
|
2020-08-26 20:31:41 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2020-12-01 16:42:35 +00:00
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
2020-08-26 20:31:41 +00:00
|
|
|
i18n,
|
|
|
|
|
|
|
|
haveNewest: boolean('haveNewest', overrideProps.haveNewest !== false),
|
|
|
|
haveOldest: boolean('haveOldest', overrideProps.haveOldest !== false),
|
2021-04-30 22:59:37 +00:00
|
|
|
isIncomingMessageRequest: boolean(
|
|
|
|
'isIncomingMessageRequest',
|
|
|
|
overrideProps.isIncomingMessageRequest === true
|
|
|
|
),
|
|
|
|
isLoadingMessages: boolean(
|
|
|
|
'isLoadingMessages',
|
|
|
|
overrideProps.isLoadingMessages === false
|
|
|
|
),
|
2021-04-05 23:12:00 +00:00
|
|
|
items: overrideProps.items || Object.keys(items),
|
2020-08-26 20:31:41 +00:00
|
|
|
resetCounter: 0,
|
|
|
|
scrollToIndex: overrideProps.scrollToIndex,
|
|
|
|
scrollToIndexCounter: 0,
|
|
|
|
totalUnread: number('totalUnread', overrideProps.totalUnread || 0),
|
|
|
|
oldestUnreadIndex:
|
|
|
|
number('oldestUnreadIndex', overrideProps.oldestUnreadIndex || 0) ||
|
|
|
|
undefined,
|
2021-03-03 20:09:58 +00:00
|
|
|
invitedContactsForNewlyCreatedGroup:
|
|
|
|
overrideProps.invitedContactsForNewlyCreatedGroup || [],
|
2021-04-21 16:31:12 +00:00
|
|
|
warning: overrideProps.warning,
|
2020-08-26 20:31:41 +00:00
|
|
|
|
2021-06-01 23:30:25 +00:00
|
|
|
id: uuid(),
|
2020-08-26 20:31:41 +00:00
|
|
|
renderItem,
|
|
|
|
renderLastSeenIndicator,
|
|
|
|
renderHeroRow,
|
|
|
|
renderLoadingRow,
|
|
|
|
renderTypingBubble,
|
|
|
|
typingContact: boolean(
|
|
|
|
'typingContact',
|
2021-06-02 17:27:12 +00:00
|
|
|
isBoolean(overrideProps.typingContact) ? overrideProps.typingContact : false
|
2020-08-26 20:31:41 +00:00
|
|
|
),
|
|
|
|
|
|
|
|
...actions(),
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Oldest and Newest', () => {
|
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('With active message request', () => {
|
2021-04-05 23:12:00 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
isIncomingMessageRequest: true,
|
2021-04-05 23:12:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('Without Newest Message', () => {
|
2020-08-26 20:31:41 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
haveNewest: false,
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('Without newest message, active message request', () => {
|
2020-08-26 20:31:41 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
haveOldest: false,
|
|
|
|
isIncomingMessageRequest: true,
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('Without Oldest Message', () => {
|
2020-08-26 20:31:41 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
haveOldest: false,
|
|
|
|
scrollToIndex: -1,
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('Empty (just hero)', () => {
|
2020-08-26 20:31:41 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
items: [],
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
2021-04-30 22:59:37 +00:00
|
|
|
story.add('Last Seen', () => {
|
2020-08-26 20:31:41 +00:00
|
|
|
const props = createProps({
|
2021-04-30 22:59:37 +00:00
|
|
|
oldestUnreadIndex: 13,
|
|
|
|
totalUnread: 2,
|
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Target Index to Top', () => {
|
|
|
|
const props = createProps({
|
|
|
|
scrollToIndex: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Typing Indicator', () => {
|
|
|
|
const props = createProps({
|
|
|
|
typingContact: true,
|
2020-08-26 20:31:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
2021-03-03 20:09:58 +00:00
|
|
|
|
|
|
|
story.add('With invited contacts for a newly-created group', () => {
|
|
|
|
const props = createProps({
|
|
|
|
invitedContactsForNewlyCreatedGroup: [
|
2021-05-07 22:21:10 +00:00
|
|
|
getDefaultConversation({
|
2021-03-03 20:09:58 +00:00
|
|
|
id: 'abc123',
|
|
|
|
title: 'John Bon Bon Jovi',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2021-03-03 20:09:58 +00:00
|
|
|
id: 'def456',
|
|
|
|
title: 'Bon John Bon Jovi',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
2021-03-03 20:09:58 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
2021-04-21 16:31:12 +00:00
|
|
|
|
2021-06-01 23:30:25 +00:00
|
|
|
story.add('With "same name in direct conversation" warning', () => {
|
2021-04-21 16:31:12 +00:00
|
|
|
const props = createProps({
|
|
|
|
warning: {
|
2021-06-01 23:30:25 +00:00
|
|
|
type: ContactSpoofingType.DirectConversationWithSameTitle,
|
2021-04-21 16:31:12 +00:00
|
|
|
safeConversation: getDefaultConversation(),
|
|
|
|
},
|
|
|
|
items: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|
2021-06-01 23:30:25 +00:00
|
|
|
|
|
|
|
story.add('With "same name in group conversation" warning', () => {
|
|
|
|
const props = createProps({
|
|
|
|
warning: {
|
|
|
|
type: ContactSpoofingType.MultipleGroupMembersWithSameTitle,
|
|
|
|
acknowledgedGroupNameCollisions: {},
|
|
|
|
groupNameCollisions: {
|
|
|
|
Alice: times(2, () => uuid()),
|
|
|
|
Bob: times(3, () => uuid()),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
items: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <Timeline {...props} />;
|
|
|
|
});
|