From a540f2983cb8425048c11fc952f439e750ff2490 Mon Sep 17 00:00:00 2001 From: Mikhail Faraponov Date: Thu, 5 Apr 2018 19:48:27 +0300 Subject: [PATCH] Added fixes --- src/components/builds/build-item.vue | 5 +++-- src/components/builds/build-page.vue | 10 ++++++---- src/components/builds/builds-page.vue | 5 +++-- src/store/modules/build.js | 3 +-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/builds/build-item.vue b/src/components/builds/build-item.vue index 17d53a9..d00d160 100644 --- a/src/components/builds/build-item.vue +++ b/src/components/builds/build-item.vue @@ -41,10 +41,11 @@ import moment from 'moment'; export default { created() { - this.connection.on(`builds:${this.id}:update`, this.update.bind(this)); + this.updateBuildStatusFn = this.update.bind(this); + this.connection.on(`builds:${this.id}:update`, this.updateBuildStatusFn); }, destroyed() { - this.connection.off(`builds:${this.id}:update`); + this.connection.off(`builds:${this.id}:update`, this.updateBuildStatusFn); }, computed: { ...mapGetters('socket', ['connection']), diff --git a/src/components/builds/build-page.vue b/src/components/builds/build-page.vue index 65b1b33..0d04a7c 100644 --- a/src/components/builds/build-page.vue +++ b/src/components/builds/build-page.vue @@ -23,12 +23,14 @@ export default { }); this.updateBuildEvent = `builds:${id}:update`; this.newLogEvent = `logs:${id}:new`; - this.connection.on(this.newLogEvent, this.log.bind(this)); - this.connection.on(this.updateBuildEvent, this.update.bind(this)); + this.newLogEventFn = this.log.bind(this); + this.updateBuildEventFn = this.update.bind(this); + this.connection.on(this.newLogEvent, this.newLogEventFn); + this.connection.on(this.updateBuildEvent, this.updateBuildEventFn); }, destroyed() { - this.connection.off(this.newLogEvent); - this.connection.off(this.updateBuildEvent); + this.connection.off(this.newLogEvent, this.newLogEventFn); + this.connection.off(this.updateBuildEvent, this.updateBuildEventFn); }, computed: { ...mapGetters('socket', [ diff --git a/src/components/builds/builds-page.vue b/src/components/builds/builds-page.vue index 91bc792..5229f80 100644 --- a/src/components/builds/builds-page.vue +++ b/src/components/builds/builds-page.vue @@ -31,10 +31,11 @@ export default { const projectId = this.$route.params.project_id; this.source = this.prefetch(projectId); this.newBuildEvent = `builds:${projectId}:new`; - this.connection.on(this.newBuildEvent, this.add.bind(this)); + this.newBuildEventFn = this.add.bind(this); + this.connection.on(this.newBuildEvent, this.newBuildEventFn); }, destroyed() { - this.connection.off(this.newBuildEvent); + this.connection.off(this.newBuildEvent, this.newBuildEventFn); }, computed: { ...mapState('builds', [ diff --git a/src/store/modules/build.js b/src/store/modules/build.js index b10d48f..4f52f33 100644 --- a/src/store/modules/build.js +++ b/src/store/modules/build.js @@ -2,7 +2,6 @@ import HTTP from '@/api'; const initialState = { build: null, - status: 'created', isLoading: false, isError: false, error: null, @@ -32,7 +31,7 @@ const mutations = { state.error = error; }, [UPDATE_BUILD](state, payload) { - state.status = payload.status; + state.build.status = payload.status; }, };