Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
240
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-240
240
Commits
2a73b4d0
Commit
2a73b4d0
authored
Nov 14, 2022
by
Malsha Rathnasiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
major changes
parent
888e41c8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
15 deletions
+27
-15
DriverApp/screens/TabOneScreen.jsx
DriverApp/screens/TabOneScreen.jsx
+9
-7
MobileApp/api/constants.js
MobileApp/api/constants.js
+1
-1
MobileApp/screens/TabOneScreen.jsx
MobileApp/screens/TabOneScreen.jsx
+12
-6
backend/backend/cms/views.py
backend/backend/cms/views.py
+5
-1
backend/db.sqlite3
backend/db.sqlite3
+0
-0
No files found.
DriverApp/screens/TabOneScreen.jsx
View file @
2a73b4d0
...
...
@@ -160,8 +160,10 @@ export default function ChatScreen({ navigation }) {
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
},
2000
);
if
(
chatDetails
)
{
loadChats
();
}
},
3000
);
return
()
=>
{
clearInterval
(
interval
);
};
...
...
@@ -171,7 +173,7 @@ export default function ChatScreen({ navigation }) {
await
getList
(
"
users
"
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
res
)
=>
{
console
.
log
({
users
:
res
});
//
console.log({ users: res });
setUsers
(
res
.
results
);
});
await
getList
(
"
conversations
"
)
...
...
@@ -179,9 +181,9 @@ export default function ChatScreen({ navigation }) {
return
res
.
json
();
})
.
then
((
res
)
=>
{
console
.
log
({
res
});
//
console.log({ res });
AsyncStorage
.
getItem
(
"
user_id
"
).
then
((
user_id
)
=>
{
console
.
log
(
"
chat details
"
,
user_id
);
//
console.log("chat details", user_id);
const
converted
=
res
.
results
.
map
((
res
)
=>
{
if
(
res
.
from_user
==
user_id
)
{
return
res
;
...
...
@@ -208,8 +210,8 @@ export default function ChatScreen({ navigation }) {
};
const
loadChats
=
()
=>
{
// setLoading(true
);
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?.
id
})
console
.
log
({
chatDetails
}
);
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?
chatDetails
.
id
:
1
})
.
then
((
res
)
=>
{
return
res
.
json
();
})
...
...
MobileApp/api/constants.js
View file @
2a73b4d0
// export const BACKEND_URL = "http://192.168.8.103:8000"
import
{
Platform
}
from
'
react-native
'
export
const
BACKEND_ADDRESS
=
Platform
.
OS
==
'
web
'
?
"
http://127.0.0.1:8000
"
:
"
https://
21a1
-112-134-220-172.ap.ngrok.io
"
export
const
BACKEND_ADDRESS
=
Platform
.
OS
==
'
web
'
?
"
http://127.0.0.1:8000
"
:
"
https://
d2e9
-112-134-220-172.ap.ngrok.io
"
export
const
BACKEND_URL
=
`
${
BACKEND_ADDRESS
}
`
MobileApp/screens/TabOneScreen.jsx
View file @
2a73b4d0
...
...
@@ -164,8 +164,10 @@ export default function ChatScreen({ navigation }) {
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
},
2000
);
if
(
chatDetails
)
{
loadChats
();
}
},
3000
);
return
()
=>
{
clearInterval
(
interval
);
};
...
...
@@ -237,13 +239,14 @@ export default function ChatScreen({ navigation }) {
};
const
loadChats
=
()
=>
{
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?.
id
})
console
.
log
({
chatDetails
});
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?
chatDetails
.
id
:
1
})
.
then
((
res
)
=>
{
return
res
.
json
();
})
.
then
((
res
)
=>
{
console
.
log
(
"
load chats
"
);
const
chats
=
res
.
results
||
[];
const
chats
=
res
.
results
.
slice
(
-
20
)
||
[];
const
sections
=
[
...
new
Set
(
chats
.
map
((
chat
)
=>
new
Date
(
chat
.
timestamp
).
setHours
(
0
,
0
,
0
,
0
))
...
...
@@ -256,7 +259,10 @@ export default function ChatScreen({ navigation }) {
),
}));
setChats
(
sectionChats
);
}).
catch
(
e
=>
{
console
.
log
(
e
)});
})
.
catch
((
e
)
=>
{
console
.
log
(
e
);
});
setLoading
(
false
);
};
...
...
@@ -273,7 +279,7 @@ export default function ChatScreen({ navigation }) {
});
setLoading
(
true
);
setInput
(
""
);
loadChats
();
//
loadChats();
}
catch
(
e
)
{
Toast
.
show
({
title
:
"
Error sending message. try again!
"
,
...
...
backend/backend/cms/views.py
View file @
2a73b4d0
...
...
@@ -163,12 +163,16 @@ class ChatViewSet(viewsets.ModelViewSet):
conv_id
=
request
.
query_params
.
get
(
"conversation"
)
if
pk
==
None
:
chats
=
Chat
.
objects
\
.
filter
(
conversation_id
=
int
(
conv_id
))
\
.
filter
(
Q
(
from_user_id
=
request
.
user
.
id
)
|
Q
(
to_user_id
=
request
.
user
.
id
))
else
:
chats
=
Chat
.
objects
.
get
(
id
=
pk
)
if
conv_id
:
chats
=
chats
.
filter
(
conversation_id
=
int
(
conv_id
))
else
:
chats
=
Chat
.
objects
.
none
()
page
=
self
.
paginate_queryset
(
chats
)
if
page
is
not
None
:
serializer
=
self
.
get_serializer
(
page
,
many
=
True
)
...
...
backend/db.sqlite3
View file @
2a73b4d0
No preview for this file type
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