Restricted the banner from showing on unsupported browsers #702
Conversation
app/routes/index.js
Outdated
@@ -9,6 +9,9 @@ const app = choo(); | |||
|
|||
function body(template) { | |||
return function(state, emit) { | |||
if (state.route.startsWith('/unsupported/')) { | |||
state.promo = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will toggle the banner off for the remainder of the session, which for almost all cases is still fine because folks who end up here aren't likely to go to any other routes, but we can be more precise, so we should be.
I suggest creating a helper function called showBanner
(or something) that combines your comparison here with stuff on line 16 below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sure I'll do this
eb5b78d
to
6284430
Compare
You mean that I have made the changes but I'm afraid that I didn't quite achieve the changes you were expecting from me. I think I couldn't get the functionality right. |
I didn't explain this very well. The only page that should hide the banner is the unsupported page, all others should show it. The way you have it now is correct. |
app/routes/index.js
Outdated
@@ -7,10 +7,14 @@ const fxPromo = require('../templates/fxPromo'); | |||
|
|||
const app = choo(); | |||
|
|||
function showBanner(route) { | |||
return !route.startsWith('/unsupported/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still want to check state.promo
so state.promo &&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still want to check state.promo.
Sorry, I missed upon that in a hurry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the changes
6284430
to
2fe8d77
Compare
app/routes/index.js
Outdated
@@ -7,10 +7,14 @@ const fxPromo = require('../templates/fxPromo'); | |||
|
|||
const app = choo(); | |||
|
|||
function showBanner(state) { | |||
return !(state.promo && state.route.startsWith('/unsupported/')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters look good, but the boolean logic isn't quite what we want. For example this return true
when both are false.
The truth table we want is:
show | promo | unsupported |
---|---|---|
true | true | false |
false | true | true |
false | false | true |
false | false | false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the changes.
2fe8d77
to
6489ab6
Compare
Sorry for troubling you @dannycoates , but I have a few questions
I also meant the same. What I was trying to convey was that when I had pushed a commit for the first time where I had used the logic
But what I want to say is that (I hade also made a GIF above) besides using |
Might be because you are working in chrome. |
@shikhar-scs , read clearly what I have commented |
Yep my bad. |
It was in some cases but not others. If you were using the address bar to go to new urls, promo would get reset. If you were navigating from links on the page or the back button, promo would not get reset. Your first PR did not work as it should in the second case.
It does make a difference. In general its a bad idea to change state when unnecessary. There may be other parts of the system that are affected by it.
Yes |
@dannycoates , I am highly grateful to you for explaining me this. Thank you very much.
Thanks for this too. |
fixes : #663
Here is a GIF of the changes