From 58d94d8f6ad1f0fc7ec896c58426bc665e49f29b Mon Sep 17 00:00:00 2001 From: "@wwwjim" Date: Sat, 12 Sep 2020 00:40:31 -0700 Subject: [PATCH] fixes public slates for new refresh scheme --- scenes/ScenePublicSlate.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scenes/ScenePublicSlate.js b/scenes/ScenePublicSlate.js index c19177af..bf01b47a 100644 --- a/scenes/ScenePublicSlate.js +++ b/scenes/ScenePublicSlate.js @@ -11,20 +11,32 @@ export default class ScenePublicSlate extends React.Component { slate: null, }; - componentDidMount = () => { - this.renderSlate(); + componentDidMount = async () => { + await this.renderSlate(); }; - componentDidUpdate = (prevProps) => { - console.log(this.props); - console.log(prevProps); - if (this.props.data.id !== prevProps.data.id) { - this.renderSlate(); + componentDidUpdate = async (prevProps) => { + if (!this.props.data) { + return null; } + + if (this.props.data.id === prevProps.data.id) { + return null; + } + + await this.renderSlate(); }; renderSlate = async () => { for (let slate of this.props.viewer.slates) { + if (!this.props.data) { + this.props.onAction({ + type: "NAVIGATE", + value: slate.id, + }); + return; + } + if (slate.id === this.props.data.id) { this.props.onAction({ type: "NAVIGATE", @@ -33,8 +45,8 @@ export default class ScenePublicSlate extends React.Component { return; } } + let slate = await Actions.getSerializedSlate({ id: this.props.data.id }); - console.log(slate); this.setState({ slate: slate.data }); };