@@ -2,6 +2,7 @@ import { Channel, DMChannelWithRecipient } from '@/types/dbtypes';
22import UserIcon from '../icons/UserIcon' ;
33import styles from '@/styles/Chat.module.css' ;
44import { useDMChannels , useSetChannel } from '@/lib/store' ;
5+ import { useEffect , useState } from 'react' ;
56
67function mapToComponentArray (
78 _map : Map < string , DMChannelWithRecipient > ,
@@ -35,7 +36,8 @@ function mapToComponentArray(
3536}
3637export default function DMessageList ( ) {
3738 const setChannel = useSetChannel ( ) ;
38- const dmChannels = Array . from ( useDMChannels ( ) . values ( ) ) ;
39+ const dmChannels = useDMChannels ( ) ;
40+ console . table ( dmChannels ) ;
3941
4042 return (
4143 < >
@@ -47,25 +49,7 @@ export default function DMessageList() {
4749 </ div >
4850 </ div >
4951 < div className = "border-t-2 mx-5 border-grey-700 flex flex-col pt-3" >
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- ) ) }
52+ { mapToComponentArray ( dmChannels , setChannel ) }
6953 </ div >
7054 </ >
7155 ) ;
0 commit comments