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 }) {
...
@@ -160,8 +160,10 @@ export default function ChatScreen({ navigation }) {
useEffect
(()
=>
{
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
if
(
chatDetails
)
{
},
2000
);
loadChats
();
}
},
3000
);
return
()
=>
{
return
()
=>
{
clearInterval
(
interval
);
clearInterval
(
interval
);
};
};
...
@@ -171,7 +173,7 @@ export default function ChatScreen({ navigation }) {
...
@@ -171,7 +173,7 @@ export default function ChatScreen({ navigation }) {
await
getList
(
"
users
"
)
await
getList
(
"
users
"
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
res
)
=>
res
.
json
())
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
({
users
:
res
});
//
console.log({ users: res });
setUsers
(
res
.
results
);
setUsers
(
res
.
results
);
});
});
await
getList
(
"
conversations
"
)
await
getList
(
"
conversations
"
)
...
@@ -179,9 +181,9 @@ export default function ChatScreen({ navigation }) {
...
@@ -179,9 +181,9 @@ export default function ChatScreen({ navigation }) {
return
res
.
json
();
return
res
.
json
();
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
({
res
});
//
console.log({ res });
AsyncStorage
.
getItem
(
"
user_id
"
).
then
((
user_id
)
=>
{
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
)
=>
{
const
converted
=
res
.
results
.
map
((
res
)
=>
{
if
(
res
.
from_user
==
user_id
)
{
if
(
res
.
from_user
==
user_id
)
{
return
res
;
return
res
;
...
@@ -208,8 +210,8 @@ export default function ChatScreen({ navigation }) {
...
@@ -208,8 +210,8 @@ export default function ChatScreen({ navigation }) {
};
};
const
loadChats
=
()
=>
{
const
loadChats
=
()
=>
{
// setLoading(true
);
console
.
log
({
chatDetails
}
);
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?.
id
})
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?
chatDetails
.
id
:
1
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
return
res
.
json
();
return
res
.
json
();
})
})
...
...
MobileApp/api/constants.js
View file @
2a73b4d0
// export const BACKEND_URL = "http://192.168.8.103:8000"
// export const BACKEND_URL = "http://192.168.8.103:8000"
import
{
Platform
}
from
'
react-native
'
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
}
`
export
const
BACKEND_URL
=
`
${
BACKEND_ADDRESS
}
`
MobileApp/screens/TabOneScreen.jsx
View file @
2a73b4d0
...
@@ -164,8 +164,10 @@ export default function ChatScreen({ navigation }) {
...
@@ -164,8 +164,10 @@ export default function ChatScreen({ navigation }) {
useEffect
(()
=>
{
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
if
(
chatDetails
)
{
},
2000
);
loadChats
();
}
},
3000
);
return
()
=>
{
return
()
=>
{
clearInterval
(
interval
);
clearInterval
(
interval
);
};
};
...
@@ -237,13 +239,14 @@ export default function ChatScreen({ navigation }) {
...
@@ -237,13 +239,14 @@ export default function ChatScreen({ navigation }) {
};
};
const
loadChats
=
()
=>
{
const
loadChats
=
()
=>
{
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?.
id
})
console
.
log
({
chatDetails
});
getList
(
"
chats
"
,
{
conversation
:
chatDetails
?
chatDetails
.
id
:
1
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
return
res
.
json
();
return
res
.
json
();
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
(
"
load chats
"
);
console
.
log
(
"
load chats
"
);
const
chats
=
res
.
results
||
[];
const
chats
=
res
.
results
.
slice
(
-
20
)
||
[];
const
sections
=
[
const
sections
=
[
...
new
Set
(
...
new
Set
(
chats
.
map
((
chat
)
=>
new
Date
(
chat
.
timestamp
).
setHours
(
0
,
0
,
0
,
0
))
chats
.
map
((
chat
)
=>
new
Date
(
chat
.
timestamp
).
setHours
(
0
,
0
,
0
,
0
))
...
@@ -256,7 +259,10 @@ export default function ChatScreen({ navigation }) {
...
@@ -256,7 +259,10 @@ export default function ChatScreen({ navigation }) {
),
),
}));
}));
setChats
(
sectionChats
);
setChats
(
sectionChats
);
}).
catch
(
e
=>
{
console
.
log
(
e
)});
})
.
catch
((
e
)
=>
{
console
.
log
(
e
);
});
setLoading
(
false
);
setLoading
(
false
);
};
};
...
@@ -273,7 +279,7 @@ export default function ChatScreen({ navigation }) {
...
@@ -273,7 +279,7 @@ export default function ChatScreen({ navigation }) {
});
});
setLoading
(
true
);
setLoading
(
true
);
setInput
(
""
);
setInput
(
""
);
loadChats
();
//
loadChats();
}
catch
(
e
)
{
}
catch
(
e
)
{
Toast
.
show
({
Toast
.
show
({
title
:
"
Error sending message. try again!
"
,
title
:
"
Error sending message. try again!
"
,
...
...
backend/backend/cms/views.py
View file @
2a73b4d0
...
@@ -163,12 +163,16 @@ class ChatViewSet(viewsets.ModelViewSet):
...
@@ -163,12 +163,16 @@ class ChatViewSet(viewsets.ModelViewSet):
conv_id
=
request
.
query_params
.
get
(
"conversation"
)
conv_id
=
request
.
query_params
.
get
(
"conversation"
)
if
pk
==
None
:
if
pk
==
None
:
chats
=
Chat
.
objects
\
chats
=
Chat
.
objects
\
.
filter
(
conversation_id
=
int
(
conv_id
))
\
.
filter
(
Q
(
from_user_id
=
request
.
user
.
id
)
|
Q
(
.
filter
(
Q
(
from_user_id
=
request
.
user
.
id
)
|
Q
(
to_user_id
=
request
.
user
.
id
))
to_user_id
=
request
.
user
.
id
))
else
:
else
:
chats
=
Chat
.
objects
.
get
(
id
=
pk
)
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
)
page
=
self
.
paginate_queryset
(
chats
)
if
page
is
not
None
:
if
page
is
not
None
:
serializer
=
self
.
get_serializer
(
page
,
many
=
True
)
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