From fcc53f52782bad548209ad2e2770d7a521242426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= Date: Mon, 13 Dec 2021 15:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0websocket=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/Detail.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 6d0a09fe..a73ee8f0 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -214,6 +214,10 @@ class Detail extends Component { } } + componentWillUnmount() { + this.timerChannel && clearTimeout(this.timerChannel); + } + getProject = (num) => { const { projectsId, owner } = this.props.match.params; const url = `/${owner}/${projectsId}/simple.json`; @@ -276,7 +280,9 @@ class Detail extends Component { connected: () => { console.log("###### channel connected! ######"); }, - disconnected: () => { }, + disconnected: () => { + console.log("###### cannot connected! ######"); + }, received: data => { console.log(`###### ---received data--- ######`); console.log(data); @@ -297,10 +303,22 @@ class Detail extends Component { }); cable.subscriptions.consumer.disconnect(); } + }, + onerror:()=>{ + console.log("###### cannot connected! ######"); } - }) + }); + + this.timerChannel = setTimeout(this.reloadDetail,5000); } + reloadDetail=()=>{ + if(this.state.firstSync||this.state.secondSync){ + window.location.reload(); + } + } + + deleteProjectBack = () => { const { history } = this.props; const { projectsId, owner } = this.props.match.params;