Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106_2022_02
boco-frontend
Commits
2bc96850
Commit
2bc96850
authored
2 years ago
by
Sander August Heggland Schrader
Browse files
Options
Downloads
Patches
Plain Diff
Added auto message update
parent
889b7e83
No related branches found
No related tags found
1 merge request
!119
New chat2
Pipeline
#180959
failed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/ChatComponents/ChatComponent.vue
+22
-15
22 additions, 15 deletions
src/components/ChatComponents/ChatComponent.vue
src/components/ChatComponents/ChatsComponent.vue
+1
-1
1 addition, 1 deletion
src/components/ChatComponents/ChatsComponent.vue
with
23 additions
and
16 deletions
src/components/ChatComponents/ChatComponent.vue
+
22
−
15
View file @
2bc96850
...
...
@@ -108,6 +108,20 @@ export default {
let
container
=
this
.
$el
.
querySelector
(
"
.conversation
"
);
container
.
scrollTop
=
container
.
scrollHeight
;
},
async
reloadMessages
()
{
const
token
=
this
.
$store
.
state
.
user
.
token
;
const
response
=
await
fetch
(
`
${
process
.
env
.
VUE_APP_BASEURL
}
chats/users/
${
this
.
recipientID
}
/messages`
,
{
method
:
"
GET
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
Authorization
:
`Bearer
${
token
}
`
,
},
}
);
this
.
msgs
=
await
response
.
json
();
},
async
sendMessage
()
{
if
(
!
this
.
recipient
||
this
.
message
==
null
||
this
.
message
==
""
)
return
;
this
.
canScroll
=
true
;
...
...
@@ -129,21 +143,7 @@ export default {
sender
:
parseInt
(
this
.
userid
),
recipient
:
this
.
recipientID
,
});
this
.
reloadMessages
();
},
async
reloadMessages
()
{
const
token
=
this
.
$store
.
state
.
user
.
token
;
const
response
=
await
fetch
(
`
${
process
.
env
.
VUE_APP_BASEURL
}
chats/users/
${
this
.
recipientID
}
/messages`
,
{
method
:
"
GET
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
Authorization
:
`Bearer
${
token
}
`
,
},
}
);
this
.
msgs
=
await
response
.
json
();
await
this
.
reloadMessages
();
},
async
reloadRents
()
{
const
token
=
this
.
$store
.
state
.
user
.
token
;
...
...
@@ -188,12 +188,19 @@ export default {
await
this
.
reloadMessages
();
await
this
.
getRecipient
();
await
this
.
reloadRents
();
ws
.
on
(
"
NEW_MESSAGE
"
,
()
=>
{
this
.
reloadMessages
();
},
"
chat
"
);
},
updated
()
{
if
(
this
.
canScroll
)
this
.
scroll
();
this
.
canScroll
=
false
;
this
.
scrollBehavior
=
"
smooth
"
;
},
unmounted
()
{
ws
.
end
(
"
NEW_MESSAGE
"
,
"
chat
"
);
}
};
</
script
>
...
...
This diff is collapsed.
Click to expand it.
src/components/ChatComponents/ChatsComponent.vue
+
1
−
1
View file @
2bc96850
...
...
@@ -89,7 +89,7 @@ export default {
this
.
conversations
=
await
conResponse
.
json
();
ws
.
on
(
"
NEW_MESSAGE
"
,
()
=>
{
this
.
reloadMessages
();
//
this.reloadMessages();
},
"
chats
"
);
this
.
recipientID
=
(
this
.
$route
.
query
?.
userID
||
null
)
if
(
!
this
.
recipientID
)
this
.
hambugerDisplay
=
"
block
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment