Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #927 from traPtitech/fix/many-hearbeats
Browse files Browse the repository at this point in the history
ハートビート送信中はハートビートを送信しないように close #911
  • Loading branch information
n-inja authored Jun 23, 2019
2 parents 8eda517 + 2f68824 commit da81dbb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pages/Main/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
data() {
return {
heartbeat: null,
heartbeatPending: false,
swipeEvent: {
isActive: false,
startX: Number,
Expand Down Expand Up @@ -225,6 +226,8 @@ export default {
this.heartbeat = setInterval(() => {
if (this.$store.state.channelId !== this.$store.state.directMessageId) {
if (this.heartbeatPending) return
this.heartbeatPending = true
client
.postHeartbeat(
this.getStatus(),
Expand All @@ -233,6 +236,9 @@ export default {
.then(res => {
this.$store.commit('updateHeartbeatStatus', res.data)
})
.finally(() => {
this.heartbeatPending = false
})
} else {
this.$store.commit('updateHeartbeatStatus', {
userStatuses: [
Expand Down Expand Up @@ -374,6 +380,8 @@ export default {
},
watch: {
'$route.params.channel': function() {
if (this.heartbeatPending) return
this.heartbeatPending = true
client
.postHeartbeat(
this.getStatus(),
Expand All @@ -382,6 +390,9 @@ export default {
.then(res => {
this.$store.commit('updateHeartbeatStatus', res.data)
})
.finally(() => {
this.heartbeatPending = false
})
},
nowStatus(newStatus) {
if (newStatus === 'none') {
Expand Down

0 comments on commit da81dbb

Please sign in to comment.