Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Santhosh
Agile24X7-Mobile-singledb
Commits
882350b1
Commit
882350b1
authored
3 years ago
by
santhosh
Browse files
Options
Download
Email Patches
Plain Diff
added
parent
1c261184
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/CommonComponents/AdminChat.js
+94
-2
src/CommonComponents/AdminChat.js
with
94 additions
and
2 deletions
+94
-2
src/CommonComponents/AdminChat.js
View file @
882350b1
...
...
@@ -53,6 +53,82 @@ class ListItem extends Component {
}
this
.
getMessages
();
this
.
getAllMessagesLast
();
}
getAllMessagesLast
()
{
log
(
"
Info
"
,
"
getMessages(role, userToken, cropcode) is used getting task related messages
"
);
// const groupId = this.state.subtaskId;
// console.warn("getmessages");
// alert("Hello")
AsyncStorage
.
multiGet
([
"
cropcode
"
,
"
userToken
"
],
(
err
,
response
)
=>
{
const
cropcode
=
response
[
0
][
1
];
const
userToken
=
response
[
1
][
1
];
this
.
setState
({
userid
:
userToken
});
AsyncStorage
.
getItem
(
"
projectId
"
,
(
err
,
res
)
=>
{
const
projectId
=
res
;
// console.warn("userToken"+userToken)
// console.warn("cropcode"+cropcode)
NetInfo
.
fetch
().
then
(
state
=>
{
if
(
state
.
type
==
"
none
"
)
{
log
(
"
Warn
"
,
"
No internet connection
"
);
Snackbar
.
show
({
title
:
'
No Internet Connection
'
,
backgroundColor
:
'
red
'
,
duration
:
Snackbar
.
LENGTH_LONG
,
});
}
else
{
fetch
(
API
+
"
squad_chat.php
"
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
action
:
"
get_all_messages_for_display_last_msg
"
,
corp_code
:
cropcode
,
sendBy
:
userToken
,
})
})
.
then
((
response
)
=>
response
.
json
())
.
then
((
responseJson
)
=>
{
console
.
warn
(
"
Messages For chat application
"
+
JSON
.
stringify
(
responseJson
.
data
));
// alert(JSON.stringify(responseJson))
// console.warn("Messages from users" + JSON.stringify(responseJson))
// console.warn("Send By Name" + JSON.stringify(responseJson.data))
if
(
responseJson
.
status
===
'
True
'
)
{
console
.
warn
(
"
Setted Data
"
)
this
.
setState
({
dataSource3
:
responseJson
.
data
,
});
alert
(
"
Method data
"
+
dataSource3
)
}
else
{
console
.
warn
(
"
Empty Data
"
)
this
.
setState
({
dataSource
:
''
,
});
}
})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
log
(
"
Error
"
,
"
getting task related messages error
"
);
});
}
});
});
});
}
getMessages
()
{
log
(
"
Info
"
,
"
getMessages(role, userToken, cropcode) is used getting task related messages
"
);
...
...
@@ -169,11 +245,24 @@ class ListItem extends Component {
<
/TouchableOpacity
>
const
getLastMsg
=
(
message
,
emp
)
=>
{
const
groupMsg
=
message
.
filter
(
msg
=>
msg
.
sendBy
===
emp
.
id
||
msg
.
receivedBy
===
emp
.
id
).
map
((
mg
,
i
)
=>
{
return
mg
.
message
});
return
groupMsg
[
groupMsg
.
length
-
1
]
}
const
getLastMsgTime
=
(
message
,
emp
)
=>
{
const
groupMsg
=
message
.
filter
(
msg
=>
msg
.
sendBy
===
emp
.
id
||
msg
.
receivedBy
===
emp
.
id
).
map
((
mg
,
i
)
=>
{
return
mg
.
messagedTime
});
return
groupMsg
[
groupMsg
.
length
-
1
]
}
// var data1=this.state.dataSource1;
const
getMessagesCount
=
(
data1
,
id
)
=>
{
// console.warn("ids"+JSON.stringify(data1) +id)
// alert(id)
// var msg=this.state.dataSource1;
// console.warn("Datasource and id send by"+JSON.stringify(data1.sendBy))
let
msgCount
=
data1
.
filter
(
message
=>
message
.
sendBy
===
id
).
map
((
messages
,
i
)
=>
{
...
...
@@ -181,7 +270,6 @@ class ListItem extends Component {
})
// console.warn("iiiiiiii" + msgCount)
return
(
// console.warn("iiiiiiii" + msgCount),
...
...
@@ -278,6 +366,10 @@ class ListItem extends Component {
<
Text
style
=
{
styles
.
iconSend
}
>
{(
item
.
name
).
substring
(
0
,
2
).
toUpperCase
()}
<
/Text
>
<
/View
>
<
Text
style
=
{
styles
.
signUpText1
}
>
{
item
.
name
}
<
/Text
>
<
/View
>
<
View
>
{
getLastMsg
(
this
.
state
.
dataSource2
,
item
.
id
)}
<
/View
>
{
/* <View style={{ flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' }}> */
}
{
getMessagesCount
(
this
.
state
.
dataSource2
,
item
.
id
)}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment