diff --git a/pkg/interface/src/apps/links/components/link.js b/pkg/interface/src/apps/links/components/link.js index fe3a9a58e..7c8cde9af 100644 --- a/pkg/interface/src/apps/links/components/link.js +++ b/pkg/interface/src/apps/links/components/link.js @@ -30,20 +30,22 @@ export class LinkDetail extends Component { } componentDidMount() { - // if we have no preloaded data, and we aren't expecting it, get it - if (!this.state.data.title) { - this.props.api.getSubmission( - this.props.resourcePath, this.props.url, this.updateData.bind(this) - ); - } + this.componentDidUpdate(); } componentDidUpdate(prevProps) { - if (this.props.url !== prevProps.url) { - this.updateData(this.props.data); + // if we have no preloaded data, and we aren't expecting it, get it + if ((!this.state.data.title) && (this.props.api)) { + this.props.api?.getSubmission( + this.props.resourcePath, this.props.url, this.updateData.bind(this) + ); } - if (prevProps.comments && prevProps.comments['0'] && - this.props.comments && this.props.comments['0']) { + if (prevProps) { + if (this.props.url !== prevProps.url) { + this.updateData(this.props.data); + } + if (prevProps.comments && prevProps.comments['0'] && + this.props.comments && this.props.comments['0']) { const prevFirstComment = prevProps.comments['0'][0]; const thisFirstComment = this.props.comments['0'][0]; if ((prevFirstComment && prevFirstComment.udon) && @@ -56,6 +58,7 @@ export class LinkDetail extends Component { }); } } + } } } diff --git a/pkg/interface/src/apps/links/components/links-list.js b/pkg/interface/src/apps/links/components/links-list.js index 872c038a2..9636a76e4 100644 --- a/pkg/interface/src/apps/links/components/links-list.js +++ b/pkg/interface/src/apps/links/components/links-list.js @@ -26,14 +26,16 @@ export class Links extends Component { // and don't have links for it yet, // or the links we have might not be complete, // request the links for that page. - if ( (!prevProps || - linkPage !== prevProps.page || - this.props.resourcePath !== prevProps.resourcePath - ) && - !this.props.links[linkPage] || - this.props.links.local[linkPage] + if ( ((!prevProps || // first load? + linkPage !== prevProps.page || // already waiting on response? + this.props.resourcePath !== prevProps.resourcePath // new page? + ) || + (prevProps.api !== this.props.api)) // api prop instantiated? + && + !this.props.links[linkPage] || // don't have info? + this.props.links.local[linkPage] // waiting on post confirmation? ) { - this.props.api.getPage(this.props.resourcePath, this.props.page); + this.props.api?.getPage(this.props.resourcePath, this.props.page); } }