@@ -5,42 +5,27 @@ import { useContext, useEffect, useState } from 'react';
5
5
import loader from '../../assets/images/loader.svg' ;
6
6
import threeDotsIcon from '../../assets/images/three-dots.svg' ;
7
7
import { AuthContext } from '../../context/AuthContext' ;
8
+ import { ConversationContext } from '../../context/ConversationContext' ;
8
9
import { useMainnetProvider } from '../../hooks/mainnetprovider/useMainnetProvider' ;
9
10
import { useTopLevelAlias } from '../../hooks/topLevelAlias/useTopLevelAlias' ;
10
11
import { DashboardProps } from '../../interfaces/props' ;
11
- import { ContactPreview } from '../../interfaces/utils' ;
12
12
import { GlobalContext } from '../../utils/context-utils' ;
13
- import {
14
- CacheType ,
15
- ModalStateType ,
16
- RightViewSelected ,
17
- } from '../../utils/enum-type-utils' ;
13
+ import { RightViewSelected } from '../../utils/enum-type-utils' ;
18
14
import { ContactMenu } from '../ContactMenu/ContactMenu' ;
19
- import { closeLoader , startLoader } from '../Loader/Loader' ;
20
15
import './Contacts.css' ;
21
16
import {
22
- addNewConversationFound ,
23
- fetchAndUpdateUnreadMsgCount ,
24
17
fetchMessageSizeLimit ,
25
18
onContactSelected ,
26
- resetContactListOnHide ,
27
19
setContactHeightToMaximum ,
28
- setContactIndexSelectedFromCache ,
29
- setContactList ,
30
20
showMenuInBottom ,
31
- updateContactDetailsOfNewContact ,
32
21
updateContactOnAccountChange ,
33
- updateSelectedContact ,
34
- updateUnreadMsgCount ,
35
22
} from './bl' ;
36
- import { ConversationContext } from '../../context/ConversationContext' ;
37
- import { initialState } from '../../contexts/Shared' ;
38
23
39
24
export function Contacts ( props : DashboardProps ) {
40
25
// fetches context api data
41
26
const { state, dispatch } = useContext ( GlobalContext ) ;
42
27
const { account, deliveryServiceToken } = useContext ( AuthContext ) ;
43
- const { contacts, initialized, setSelectedContact , selectedContact } =
28
+ const { contacts, initialized, setSelectedContactName , selectedContact } =
44
29
useContext ( ConversationContext ) ;
45
30
const mainnetProvider = useMainnetProvider ( ) ;
46
31
const { resolveAliasToTLD } = useTopLevelAlias ( ) ;
@@ -59,12 +44,6 @@ export function Contacts(props: DashboardProps) {
59
44
setContactHeightToMaximum ( ! isAddrEnsName ? true : false ) ;
60
45
} , [ account ?. ensName ] ) ;
61
46
62
- // handles any change in socket or session
63
- useEffect ( ( ) => {
64
- console . log ( ' initialized' , initialized ) ;
65
- console . log ( 'contacts' , contacts ) ;
66
- } , [ initialized ] ) ;
67
-
68
47
// handles change in accounts
69
48
useEffect ( ( ) => {
70
49
if (
@@ -93,19 +72,14 @@ export function Contacts(props: DashboardProps) {
93
72
//TODO add websocket listener for add conversation
94
73
} , [ state . accounts . contacts ] ) ;
95
74
96
- // handles contact selected
97
- useEffect ( ( ) => {
98
- //TODO add click handler to select contact
99
- } , [ state . accounts . selectedContact ] ) ;
100
-
101
75
// handles active contact removal
102
76
useEffect ( ( ) => {
103
77
if (
104
78
selectedContact !== null &&
105
79
state . uiView . selectedRightView !== RightViewSelected . Chat &&
106
80
state . uiView . selectedRightView !== RightViewSelected . ContactInfo
107
81
) {
108
- setSelectedContact ( undefined ) ;
82
+ setSelectedContactName ( undefined ) ;
109
83
}
110
84
} , [ state . uiView . selectedRightView ] ) ;
111
85
@@ -192,7 +166,9 @@ export function Contacts(props: DashboardProps) {
192
166
: 'contact-details-container-active'
193
167
: '' ,
194
168
) }
195
- onClick = { ( ) => setSelectedContact ( data ) }
169
+ onClick = { ( ) =>
170
+ setSelectedContactName ( data . name )
171
+ }
196
172
>
197
173
< div
198
174
className = "col-12 d-flex flex-row align-items-center
@@ -249,8 +225,8 @@ export function Contacts(props: DashboardProps) {
249
225
250
226
{ selectedContact ?. contactDetails
251
227
. account . ensName === id ? (
252
- ! state . modal . addConversation
253
- . active ? (
228
+ selectedContact . message !==
229
+ null ? (
254
230
< div >
255
231
< div className = "action-container" >
256
232
< img
0 commit comments