77import React from 'react'
88import _ from 'lodash'
99import { connect } from 'react-redux'
10- import { Redirect , withRouter , Link } from 'react-router-dom'
10+ import { withRouter , Link } from 'react-router-dom'
1111import Alert from 'react-s-alert'
1212import './DashboardContainer.scss'
1313
@@ -70,14 +70,9 @@ class DashboardContainer extends React.Component {
7070
7171 this . state = {
7272 open : false ,
73- matchesTopicUrl : null ,
74- matchesPostUrl : null ,
75- topicIdForPost : null
7673 }
7774 this . onNotificationRead = this . onNotificationRead . bind ( this )
7875 this . toggleDrawer = this . toggleDrawer . bind ( this )
79-
80- this . alertedFailedTopicRedirect = false
8176 }
8277
8378 onNotificationRead ( notification ) {
@@ -101,18 +96,6 @@ class DashboardContainer extends React.Component {
10196 } )
10297 }
10398
104- /*
105- For redirecting old urls to new urls for topics and posts
106- Old TOPIC: '/projects/{{projectId}}/#feed-{{topicId}}',
107- Old POST: '/projects/{{projectId}}/#comment-{{postId}}',
108- */
109- const matchesTopicUrl = location . hash . match ( / # f e e d - ( \d + ) / )
110- const matchesPostUrl = location . hash . match ( / # c o m m e n t - ( \d + ) / )
111- this . setState ( {
112- matchesPostUrl,
113- matchesTopicUrl
114- } )
115-
11699 // if the user is a customer and its not a direct link to a particular phase
117100 // then by default expand all phases which are active
118101 if ( _ . isEmpty ( location . hash ) && this . props . isCustomerUser ) {
@@ -130,40 +113,12 @@ class DashboardContainer extends React.Component {
130113 collapseAllProjectPhases ( )
131114 }
132115
133- componentWillReceiveProps ( nextProps ) {
134- const { isFeedsLoading } = nextProps
135- const { matchesPostUrl } = this . state
136-
137- // we need topicId for redirecting old post url (/projects/{{projectId}}/#comment-{{postId}})
138- if ( ! isFeedsLoading && matchesPostUrl && ! this . alertedFailedTopicRedirect ) {
139- const topicIdForPost = this . getTopicIdForPost ( matchesPostUrl [ 1 ] )
140- this . setState ( { topicIdForPost } )
141- this . alertFailedTopicRedirection ( matchesPostUrl , topicIdForPost , isFeedsLoading )
142- }
143- }
144-
145116 toggleDrawer ( ) {
146117 this . setState ( ( prevState ) => ( {
147118 open : ! prevState . open
148119 } ) )
149120 }
150121
151- // Get topic id corresponding to the post that we're trying to redirect to
152- getTopicIdForPost ( postId ) {
153- const { feeds} = this . props
154- const topic = feeds && feeds
155- . find ( feed => feed . posts . find ( p => p . id === Number ( postId ) ) )
156- return topic && topic . id
157- }
158-
159- // Alert user in case the post is not available / not accessible to him.
160- alertFailedTopicRedirection ( matchesPostUrl , topicIdForPost , isFeedsLoading ) {
161- if ( matchesPostUrl && ! topicIdForPost && ! isFeedsLoading ) {
162- this . alertedFailedTopicRedirect = true
163- Alert . error ( 'Couldn\'t find the post' )
164- }
165- }
166-
167122 render ( ) {
168123 const {
169124 project,
@@ -191,9 +146,6 @@ class DashboardContainer extends React.Component {
191146 location,
192147 estimationQuestion,
193148 } = this . props
194- const { matchesPostUrl, matchesTopicUrl, topicIdForPost } = this . state
195-
196-
197149 const projectTemplate = project && project . templateId && projectTemplates ? ( getProjectTemplateById ( projectTemplates , project . templateId ) ) : null
198150
199151 let template
@@ -254,9 +206,6 @@ class DashboardContainer extends React.Component {
254206 ] }
255207 />
256208
257- { matchesTopicUrl && < Redirect to = { `/projects/${ project . id } /messages/${ matchesTopicUrl [ 1 ] } ` } /> }
258- { matchesPostUrl && topicIdForPost && < Redirect to = { `/projects/${ project . id } /messages/${ topicIdForPost } #comment-${ matchesPostUrl [ 1 ] } ` } /> }
259-
260209 < TwoColsLayout . Sidebar >
261210 < MediaQuery minWidth = { SCREEN_BREAKPOINT_MD } >
262211 { ( matches ) => {
0 commit comments