From 1054e0c51b1f56c9dc3981e8a3ef47dad78f7a91 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Mon, 22 Jul 2019 16:02:48 -0400 Subject: [PATCH] Updated list_timeline to check for new list id on to reload new list added check in componentWillReceiveProps for new params.id for updating list fixes: #53 --- .../gabsocial/features/list_timeline/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/javascript/gabsocial/features/list_timeline/index.js b/app/javascript/gabsocial/features/list_timeline/index.js index 5a860d4a..f62980f3 100644 --- a/app/javascript/gabsocial/features/list_timeline/index.js +++ b/app/javascript/gabsocial/features/list_timeline/index.js @@ -43,8 +43,22 @@ class ListTimeline extends React.PureComponent { }; componentDidMount () { + this.handleConnect(this.props.params.id); + } + + componentWillUnmount () { + this.handleDisconnect(); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.params.id !== this.props.params.id) { + this.handleDisconnect(); + this.handleConnect(nextProps.params.id); + } + } + + handleConnect(id) { const { dispatch } = this.props; - const { id } = this.props.params; dispatch(fetchList(id)); dispatch(expandListTimeline(id)); @@ -52,7 +66,7 @@ class ListTimeline extends React.PureComponent { this.disconnect = dispatch(connectListStream(id)); } - componentWillUnmount () { + handleDisconnect() { if (this.disconnect) { this.disconnect(); this.disconnect = null;