CLN-04: Replaced any with unknown, proper interfaces, or concrete types across 17 files. Focus: error handlers, API responses, WebSocket data, and function parameters.
191 lines
4.6 KiB
TypeScript
191 lines
4.6 KiB
TypeScript
import { Server, DirectMessage, ChatMessage } from '../types';
|
|
|
|
const MOCK_SERVERS: Server[] = [
|
|
{
|
|
id: 's1',
|
|
name: 'Veza Official',
|
|
icon: 'https://picsum.photos/id/50/200/200',
|
|
categories: [
|
|
{
|
|
id: 'cat1',
|
|
name: 'Information',
|
|
channels: [
|
|
{
|
|
id: 'c1',
|
|
name: 'announcements',
|
|
type: 'text',
|
|
unread: 2,
|
|
isLocked: true,
|
|
},
|
|
{ id: 'c2', name: 'rules', type: 'text', isLocked: true },
|
|
],
|
|
},
|
|
{
|
|
id: 'cat2',
|
|
name: 'Community',
|
|
channels: [
|
|
{
|
|
id: 'c3',
|
|
name: 'general',
|
|
type: 'text',
|
|
topic: 'Main lobby for producers',
|
|
},
|
|
{
|
|
id: 'c4',
|
|
name: 'showcase',
|
|
type: 'text',
|
|
topic: 'Post your tracks here',
|
|
},
|
|
{
|
|
id: 'c5',
|
|
name: 'Lounge',
|
|
type: 'voice',
|
|
activeParticipants: [
|
|
{
|
|
id: 'u1',
|
|
name: 'Skrillex',
|
|
avatar: 'https://picsum.photos/id/101/50/50',
|
|
isMuted: false,
|
|
isSpeaking: true,
|
|
isScreenSharing: false,
|
|
roleColor: 'text-warning',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 's2',
|
|
name: 'Dubstep Producers',
|
|
icon: 'https://picsum.photos/id/60/200/200',
|
|
categories: [
|
|
{
|
|
id: 'cat3',
|
|
name: 'Production',
|
|
channels: [
|
|
{ id: 'c6', name: 'serum-presets', type: 'text' },
|
|
{ id: 'c7', name: 'Collab Room', type: 'voice' },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
const MOCK_DMS: DirectMessage[] = [
|
|
{
|
|
id: 'dm1',
|
|
user: {
|
|
name: 'Deadmau5',
|
|
avatar: 'https://picsum.photos/id/77/50/50',
|
|
status: 'online',
|
|
},
|
|
lastMessage: 'Sent you the stems.',
|
|
unread: 1,
|
|
timestamp: '2m',
|
|
},
|
|
{
|
|
id: 'dm2',
|
|
user: {
|
|
name: 'Grimes',
|
|
avatar: 'https://picsum.photos/id/88/50/50',
|
|
status: 'idle',
|
|
},
|
|
lastMessage: 'That AI vocal is crazy!',
|
|
unread: 0,
|
|
timestamp: '1h',
|
|
},
|
|
{
|
|
id: 'dm3',
|
|
user: {
|
|
name: 'Support',
|
|
avatar: 'https://picsum.photos/id/99/50/50',
|
|
status: 'offline',
|
|
},
|
|
lastMessage: 'Ticket #492 resolved.',
|
|
unread: 0,
|
|
timestamp: '1d',
|
|
},
|
|
];
|
|
|
|
// Mock structure differs from api Message; cast at return
|
|
const INITIAL_MESSAGES: unknown[] = [
|
|
{
|
|
id: '1',
|
|
sender: 'Neon_Dev',
|
|
senderRole: 'Admin',
|
|
roleColor: 'text-destructive',
|
|
avatar: 'https://picsum.photos/id/10/50/50',
|
|
content: 'Welcome to the new server architecture! 🚀',
|
|
timestamp: '10:42 AM',
|
|
isMe: false,
|
|
type: 'text',
|
|
reactions: [{ emoji: '🔥', count: 12, active: true }],
|
|
},
|
|
{
|
|
id: '2',
|
|
sender: 'BassHead',
|
|
senderRole: 'Producer',
|
|
roleColor: 'text-warning',
|
|
avatar: 'https://picsum.photos/id/30/50/50',
|
|
content: 'The new audio engine in Veza is insane. Zero latency.',
|
|
timestamp: '10:45 AM',
|
|
isMe: false,
|
|
type: 'text',
|
|
},
|
|
{
|
|
id: '3',
|
|
sender: 'You',
|
|
senderRole: 'Artist',
|
|
roleColor: 'text-muted-foreground',
|
|
avatar: 'https://picsum.photos/id/20/50/50',
|
|
content: 'Yeah, I just tested the collaborative mixer. Works flawlessly.',
|
|
timestamp: '10:46 AM',
|
|
isMe: true,
|
|
type: 'text',
|
|
},
|
|
];
|
|
|
|
export const chatService = {
|
|
getServers: async () => {
|
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
return MOCK_SERVERS;
|
|
},
|
|
|
|
getDMs: async () => {
|
|
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
return MOCK_DMS;
|
|
},
|
|
|
|
getMessages: async (_channelId: string) => {
|
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
return INITIAL_MESSAGES as ChatMessage[];
|
|
},
|
|
|
|
sendMessage: async (
|
|
_channelId: string,
|
|
content: { text?: string; type?: string; attachment?: string },
|
|
) => {
|
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
return {
|
|
id: Date.now().toString(),
|
|
conversation_id: _channelId,
|
|
sender_id: 'current_user',
|
|
sender: 'You',
|
|
senderRole: 'Artist',
|
|
roleColor: 'text-muted-foreground',
|
|
avatar: 'https://picsum.photos/id/20/50/50',
|
|
content: content.text || '',
|
|
created_at: new Date().toISOString(),
|
|
timestamp: new Date().toLocaleTimeString([], {
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
}),
|
|
isMe: true,
|
|
type: content.type || 'text',
|
|
attachmentUrl: content.attachment,
|
|
updated_at: new Date().toISOString(),
|
|
} as unknown as ChatMessage;
|
|
},
|
|
};
|