1- import { getAllDMChannels } from '@/services/directmessage.service' ;
21import { Channel , DMChannelWithRecipient } from '@/types/dbtypes' ;
3- import { useSupabaseClient } from '@supabase/auth-helpers-react' ;
4- import { useEffect , useState } from 'react' ;
52import UserIcon from '../icons/UserIcon' ;
63import styles from '@/styles/Chat.module.css' ;
74import { useDMChannels , useSetChannel } from '@/lib/store' ;
@@ -38,7 +35,7 @@ function mapToComponentArray(
3835}
3936export default function DMessageList ( ) {
4037 const setChannel = useSetChannel ( ) ;
41- const dmChannels = useDMChannels ( ) ;
38+ const dmChannels = Array . from ( useDMChannels ( ) . values ( ) ) ;
4239
4340 return (
4441 < >
@@ -50,7 +47,25 @@ export default function DMessageList() {
5047 </ div >
5148 </ div >
5249 < div className = "border-t-2 mx-5 border-grey-700 flex flex-col pt-3" >
53- { mapToComponentArray ( dmChannels , setChannel ) }
50+ { dmChannels . map ( ( value ) => (
51+ < div
52+ key = { value . channel_id }
53+ className = "flex items-center p-2 w-full hover:bg-grey-700 rounded-md transition-colors"
54+ onClick = { ( ) => {
55+ setChannel ( {
56+ channel_id : value . channel_id ,
57+ server_id : value . server_id ,
58+ name : value . recipient . username ,
59+ is_media : false ,
60+ description : null ,
61+ created_at : null
62+ } ) ;
63+ } }
64+ >
65+ < UserIcon user = { value . recipient } className = "!w-6 !h-6" />
66+ < div > { value . recipient . username } </ div >
67+ </ div >
68+ ) ) }
5469 </ div >
5570 </ >
5671 ) ;
0 commit comments