From 3eb8ad909239b43cad7e3c5f8d8fbf617c842aa3 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 2 Jan 2019 11:39:30 -0500 Subject: [PATCH 1/4] Fix the regexp that allows for query params on faq and download --- src/routes.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/routes.json b/src/routes.json index 0df2f55f3..cea2252ed 100644 --- a/src/routes.json +++ b/src/routes.json @@ -101,7 +101,7 @@ }, { "name": "download", - "pattern": "^/download/?(.+)?$", + "pattern": "^/download/?(\\?.*)?$", "routeAlias": "/download", "view": "download/download", "title": "Scratch Offline Editor" @@ -122,7 +122,7 @@ }, { "name": "faq", - "pattern": "^/info/faq/?(.+)?$", + "pattern": "^/info/faq/?(\\?.*)?$", "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq)/?$", "view": "faq/faq", "title": "FAQ" @@ -172,7 +172,7 @@ }, { "name": "parents", - "pattern": "^/parents/?$", + "pattern": "^/parents/?(\\?.*)?$", "routeAlias": "/parents/", "view": "parents/parents", "title": "For Parents" @@ -206,7 +206,7 @@ }, { "name": "scratch2", - "pattern": "^/download/scratch2/?$", + "pattern": "^/download/scratch2/?(\\?.*)?$", "routeAlias": "/download/scratch2", "view": "download/scratch2/download", "title": "Scratch 2.0" @@ -321,7 +321,7 @@ }, { "name": "download-redirect", - "pattern": "^/scratch2download/?$", + "pattern": "^/scratch2download/?(\\?.*)?$", "routeAlias": "/scratch2download", "redirect": "/download" }, From a2fbdf99436abd42debb56f425988ad751a7b5fb Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 2 Jan 2019 16:19:26 -0500 Subject: [PATCH 2/4] Only track green flag once --- src/views/preview/project-view.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index e2eaff047..5492d9da0 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -117,7 +117,8 @@ class Preview extends React.Component { showUsernameBlockAlert: false, projectId: parts[1] === 'editor' ? '0' : parts[1], reportOpen: false, - singleCommentId: singleCommentId + singleCommentId: singleCommentId, + greenFlagRecorded: false }; /* In the beginning, if user is on mobile and landscape, go to fullscreen */ this.setScreenFromOrientation(); @@ -357,11 +358,14 @@ class Preview extends React.Component { this.props.reportProject(this.state.projectId, formData, this.props.user.token); } handleGreenFlag () { + if (!this.state.greenFlagRecorded) { + this.props.logProjectView(this.props.projectInfo.id, this.props.authorUsername, this.props.user.token); + } this.setState({ showUsernameBlockAlert: false, - showCloudDataAlert: false + showCloudDataAlert: false, + greenFlagRecorded: true }); - this.props.logProjectView(this.props.projectInfo.id, this.props.authorUsername, this.props.user.token); } handlePopState () { const path = window.location.pathname.toLowerCase(); From f7818049da1a81e50b73d1d371e44a5dedad6e85 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 31 Jan 2019 16:48:56 -0500 Subject: [PATCH 3/4] Remove the project count request since it is no longer being used --- src/views/splash/presentation.jsx | 1 - src/views/splash/splash.jsx | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/src/views/splash/presentation.jsx b/src/views/splash/presentation.jsx index d03093073..5a4af32b5 100644 --- a/src/views/splash/presentation.jsx +++ b/src/views/splash/presentation.jsx @@ -609,7 +609,6 @@ SplashPresentation.defaultProps = { inStudiosFollowing: [], // "Projects in Studios I'm Following" lovedByFollowing: [], // "Projects Loved by Scratchers I'm Following" news: [], // gets news posts from the scratch Tumblr - projectCount: 20000000, // gets the shared project count sharedByFollowing: [] // "Projects by Scratchers I'm Following" }; diff --git a/src/views/splash/splash.jsx b/src/views/splash/splash.jsx index f9a268820..8910c0ce2 100644 --- a/src/views/splash/splash.jsx +++ b/src/views/splash/splash.jsx @@ -17,7 +17,6 @@ class Splash extends React.Component { super(props); bindAll(this, [ 'getNews', - 'getProjectCount', 'handleRefreshHomepageCache', 'getHomepageRefreshStatus', 'handleShowEmailConfirmationModal', @@ -30,7 +29,6 @@ class Splash extends React.Component { ]); this.state = { adminPanelOpen: false, - projectCount: 30000000, // gets the shared project count news: [], // gets news posts from the scratch Tumblr emailConfirmationModalOpen: false, // flag that determines whether to show banner to request email conf. refreshCacheStatus: 'notrequested' @@ -44,8 +42,6 @@ class Splash extends React.Component { this.props.getInStudiosFollowing(this.props.user.username, this.props.user.token); this.props.getLovedByFollowing(this.props.user.username, this.props.user.token); this.getNews(); - } else { - this.getProjectCount(); } } componentDidUpdate (prevProps) { @@ -62,7 +58,6 @@ class Splash extends React.Component { this.props.setRows('studios', []); this.props.setRows('activity', []); this.setState({news: []}); // eslint-disable-line react/no-did-update-set-state - this.getProjectCount(); } if (this.shouldShowEmailConfirmation()) { window.addEventListener('message', this.onMessage); @@ -82,14 +77,6 @@ class Splash extends React.Component { if (!err) return this.setState({news: body}); }); } - getProjectCount () { - api({ - uri: '/projects/count/all' - }, (err, body) => { - if (!body) return log.error('No response body'); - if (!err) return this.setState({projectCount: body.count}); - }); - } handleRefreshHomepageCache () { api({ host: '', @@ -173,7 +160,6 @@ class Splash extends React.Component { isEducator={this.props.isEducator} lovedByFollowing={this.props.loved} news={this.state.news} - projectCount={this.state.projectCount} refreshCacheStatus={homepageRefreshStatus} sessionStatus={this.props.sessionStatus} sharedByFollowing={this.props.shared} From 23adf352edffcb9717c479fea29cbed1f165c476 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 31 Jan 2019 16:48:56 -0500 Subject: [PATCH 4/4] Remove the project count request since it is no longer being used --- src/views/splash/presentation.jsx | 1 - src/views/splash/splash.jsx | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/src/views/splash/presentation.jsx b/src/views/splash/presentation.jsx index d03093073..5a4af32b5 100644 --- a/src/views/splash/presentation.jsx +++ b/src/views/splash/presentation.jsx @@ -609,7 +609,6 @@ SplashPresentation.defaultProps = { inStudiosFollowing: [], // "Projects in Studios I'm Following" lovedByFollowing: [], // "Projects Loved by Scratchers I'm Following" news: [], // gets news posts from the scratch Tumblr - projectCount: 20000000, // gets the shared project count sharedByFollowing: [] // "Projects by Scratchers I'm Following" }; diff --git a/src/views/splash/splash.jsx b/src/views/splash/splash.jsx index f9a268820..8910c0ce2 100644 --- a/src/views/splash/splash.jsx +++ b/src/views/splash/splash.jsx @@ -17,7 +17,6 @@ class Splash extends React.Component { super(props); bindAll(this, [ 'getNews', - 'getProjectCount', 'handleRefreshHomepageCache', 'getHomepageRefreshStatus', 'handleShowEmailConfirmationModal', @@ -30,7 +29,6 @@ class Splash extends React.Component { ]); this.state = { adminPanelOpen: false, - projectCount: 30000000, // gets the shared project count news: [], // gets news posts from the scratch Tumblr emailConfirmationModalOpen: false, // flag that determines whether to show banner to request email conf. refreshCacheStatus: 'notrequested' @@ -44,8 +42,6 @@ class Splash extends React.Component { this.props.getInStudiosFollowing(this.props.user.username, this.props.user.token); this.props.getLovedByFollowing(this.props.user.username, this.props.user.token); this.getNews(); - } else { - this.getProjectCount(); } } componentDidUpdate (prevProps) { @@ -62,7 +58,6 @@ class Splash extends React.Component { this.props.setRows('studios', []); this.props.setRows('activity', []); this.setState({news: []}); // eslint-disable-line react/no-did-update-set-state - this.getProjectCount(); } if (this.shouldShowEmailConfirmation()) { window.addEventListener('message', this.onMessage); @@ -82,14 +77,6 @@ class Splash extends React.Component { if (!err) return this.setState({news: body}); }); } - getProjectCount () { - api({ - uri: '/projects/count/all' - }, (err, body) => { - if (!body) return log.error('No response body'); - if (!err) return this.setState({projectCount: body.count}); - }); - } handleRefreshHomepageCache () { api({ host: '', @@ -173,7 +160,6 @@ class Splash extends React.Component { isEducator={this.props.isEducator} lovedByFollowing={this.props.loved} news={this.state.news} - projectCount={this.state.projectCount} refreshCacheStatus={homepageRefreshStatus} sessionStatus={this.props.sessionStatus} sharedByFollowing={this.props.shared}