All files / apps / web/src / features / conversation api.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 4/4

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              17x       9x     5x     24x    
import { messagesFixture, sidebarFixture } from './fixtures'
import type { ConversationMessages, Sidebar } from './types'
 
// shortcut: both answer from fixtures.ts, there is no conversation API before sign-in (design 4.2);
// M2 swaps each body for apiFetch with the shared schema and keeps the signatures.
 
export async function fetchSidebar(): Promise<Sidebar> {
  return Promise.resolve(sidebarFixture())
}
 
export async function fetchMessages(conversationId: string): Promise<ConversationMessages> {
  return Promise.resolve(messagesFixture(conversationId, Date.now()))
}
 
export const sidebarKey = ['sidebar'] as const
 
export function messagesKey(conversationId: string): readonly ['messages', string] {
  return ['messages', conversationId]
}