Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 5x 5x 50x 5x 5x 46x 40x 6x 2x 17x 11x 11x 5x 3x | import searchEmptyState from './assets/search-empty-state.svg'
import type { ConversationMessages, ConversationSummary, Message, Person, Sidebar } from './types'
// shortcut: sample data in place of the API, which needs sign-in first (design 4.2); the M2
// tickets replace this file and the bodies of api.ts.
const ME: Person = { id: 'alex', name: 'Alex Mai', presence: 'online' }
const PEOPLE: Person[] = [
ME,
{ id: 'henry', name: 'Henry Lam', presence: 'online' },
{ id: 'tessa', name: 'Tessa Hope', presence: 'away' },
{ id: 'gabe', name: 'Gabe Diaz', presence: 'online' },
{ id: 'nina', name: 'Nina Park', presence: 'online' },
{ id: 'kai', name: 'Kai Trent', presence: 'online' },
{ id: 'hannah', name: 'Hannah Reed', presence: 'online' },
{ id: 'ben', name: 'Ben Turner', presence: 'away' },
{ id: 'lily', name: 'Lily Burke', presence: 'offline' },
{ id: 'hugo', name: 'Hugo Wells', presence: 'offline' },
]
function conversation(
id: string,
kind: ConversationSummary['kind'],
section: ConversationSummary['section'],
name: string,
rest: Partial<ConversationSummary> = {},
): ConversationSummary {
return {
id,
kind,
section,
name,
topic: '',
memberCount: 2,
memberIds: [],
peerId: null,
hasUnread: false,
mentionCount: 0,
isMuted: false,
...rest,
}
}
const CONVERSATIONS: ConversationSummary[] = [
conversation('granbull', 'channel', 'starred', 'granbull', {
topic: 'Granbull team: daily work, stand-up notes, quick questions',
memberCount: 12,
memberIds: ['henry', 'ben', 'nina'],
hasUnread: true,
mentionCount: 1,
}),
conversation('chattra-build', 'private', 'starred', 'chattra-build', { memberCount: 5 }),
conversation('general', 'channel', 'channels', 'general', {
topic: 'Company-wide announcements',
memberCount: 300,
}),
conversation('design-review', 'channel', 'channels', 'design-review', {
memberCount: 18,
hasUnread: true,
}),
conversation('random', 'channel', 'channels', 'random', { memberCount: 120, isMuted: true }),
conversation('dm-hannah', 'dm', 'dms', 'Hannah Reed', { peerId: 'hannah', hasUnread: true }),
conversation('dm-ben', 'dm', 'dms', 'Ben Turner', { peerId: 'ben' }),
conversation('dm-group', 'group', 'dms', 'Nina, Gabe, Tessa', { memberCount: 4 }),
conversation('dm-lily', 'dm', 'dms', 'Lily Burke', { peerId: 'lily' }),
conversation('dm-hugo', 'dm', 'dms', 'Hugo Wells', { peerId: 'hugo' }),
]
const DAY = 24 * 60 * 60 * 1000
function at(startOfToday: number, daysAgo: number, hour: number, minute: number): number {
return startOfToday - daysAgo * DAY + (hour * 60 + minute) * 60 * 1000
}
function message(
id: string,
authorId: string,
sentAt: number,
body: string,
rest: Partial<Message> = {},
): Message {
return {
id,
authorId,
sentAt,
body,
reactions: [],
thread: null,
attachments: [],
isPinned: false,
mentionsMe: false,
...rest,
}
}
function granbull(today: number): ConversationMessages {
return {
lastReadMessageId: 'g3',
messages: [
message(
'g1',
'henry',
at(today, 1, 17, 40),
'Spec **rev 5** is up. Data is no longer kept forever: the Owner sets message and file retention separately, default is _1 year_ each.',
{
reactions: [
{ emoji: '👍', count: 3, isMine: false },
{ emoji: '🎉', count: 1, isMine: true },
],
thread: {
replyCount: 4,
replierIds: ['ben', 'henry', 'alex', 'nina'],
lastReplyAt: at(today, 1, 18, 9),
},
isPinned: true,
},
),
message(
'g2',
'tessa',
at(today, 0, 8, 47),
'Team lunch at the café downstairs today, 12:15. Sprint review is tomorrow at 09:00 in the big room.',
),
message(
'g3',
'gabe',
at(today, 0, 8, 49),
'Sounds good. I’ll demo the prototype at the review, about 15 minutes.',
{ reactions: [{ emoji: '👍', count: 1, isMine: false }] },
),
message(
'g4',
'nina',
at(today, 0, 9, 5),
'@Alex can you check the empty state for search? Typing `cafe` should also find “café”.',
{
mentionsMe: true,
attachments: [
{
id: 'g4-image',
name: 'search-empty-state.png',
src: searchEmptyState,
width: 960,
height: 600,
},
],
},
),
message(
'g5',
'kai',
at(today, 0, 9, 9),
'Group DM limit test:\n- 9 people including me: works\n- 10th person: blocked, and it offers a private channel instead',
),
message(
'g6',
'henry',
at(today, 0, 9, 12),
'Reminder: the MVP gate is **everyone at Asoft** using Chattra for one week. Date to be agreed with the team.',
),
],
}
}
function general(today: number): ConversationMessages {
return {
lastReadMessageId: null,
messages: [
message(
'n1',
'hannah',
at(today, 2, 10, 0),
'Welcome to **Chattra**, everyone. This is the announcements channel.',
),
message(
'n2',
'hugo',
at(today, 0, 9, 30),
'The office is closed this Friday for electrical maintenance.',
),
],
}
}
export function sidebarFixture(): Sidebar {
return { workspaceName: 'Asoft', me: ME, people: PEOPLE, conversations: CONVERSATIONS }
}
// Times are built from "today" so the day dividers always read Yesterday / Today.
export function messagesFixture(conversationId: string, now: number): ConversationMessages {
const today = new Date(now).setHours(0, 0, 0, 0)
if (conversationId === 'granbull') return granbull(today)
if (conversationId === 'general') return general(today)
return { lastReadMessageId: null, messages: [] }
}
|