Fix bug where dismissing onboarding would hide autocompile switch

This commit is contained in:
Alasdair Smith 2017-10-31 17:00:41 +00:00
parent 326e0dd8d1
commit 6dc0561fa7
3 changed files with 9 additions and 7 deletions

View file

@ -262,21 +262,21 @@ module.exports = ProjectController =
rolloutPercentage = 40 # Percentage of users to roll out to
if counter % 100 > rolloutPercentage
# Don't show if user is not part of roll out
return cb(null, false)
return cb(null, { enabled: false, showOnboarding: false })
userSignupDate = new Date(timestamp * 1000)
if userSignupDate > new Date("2017-10-16")
# Don't show for users who registered after it was released
return cb(null, false)
return cb(null, { enabled: true, showOnboarding: false })
timeout = setTimeout cb, 500
AnalyticsManager.getLastOccurance user_id, "shown-autocompile-onboarding", (error, event) ->
clearTimeout timeout
if error?
return cb(null, false)
return cb(null, { enabled: true, showOnboarding: false })
else if event?
return cb(null, false)
return cb(null, { enabled: true, showOnboarding: false })
else
logger.log { user_id, event }, "autocompile onboarding not shown yet to this user"
return cb(null, true)
return cb(null, { enabled: true, showOnboarding: true })
}, (err, results)->
if err?
logger.err err:err, "error getting details for project page"
@ -329,7 +329,8 @@ module.exports = ProjectController =
trackChangesState: project.track_changes
showTrackChangesOnboarding: !!showTrackChangesOnboarding
showPerUserTCNotice: !!showPerUserTCNotice
showAutoCompileOnboarding: !!showAutoCompileOnboarding
autoCompileEnabled: !!showAutoCompileOnboarding?.enabled
showAutoCompileOnboarding: !!showAutoCompileOnboarding?.showOnboarding
privilegeLevel: privilegeLevel
chatUrl: Settings.apis.chat.url
anonymous: anonymous

View file

@ -122,6 +122,7 @@ block requirejs
window.trackChangesState = data.trackChangesState;
window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding};
window.showPerUserTCNotice = #{!!showPerUserTCNotice};
window.autoCompileEnabled = #{!!autoCompileEnabled};
window.showAutoCompileOnboarding = #{!!showAutoCompileOnboarding}
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
window.requirejs = {

View file

@ -27,7 +27,7 @@ div.full-size.pdf(ng-controller="PdfController")
span.caret
ul.dropdown-menu.dropdown-menu-left
// Only show if on beta program or part of rollout
if user.betaProgram || showAutoCompileOnboarding
if user.betaProgram || autoCompileEnabled
li.dropdown-header #{translate("auto_compile")}
li
a(href, ng-click="autocompile_enabled = true")