-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify device type routing #950
Conversation
The mobile-detect package is large. We shouldn't send it to the browser. This change uses mobile-detect on the server only. It associates a device type with the request and sends only that pre-determined value to the browser. This eliminates the "mobile" route target, which was previously the union of "phone" and "tablet". These two must be specified individually going forward (though they may route to the same page class). It also adds a "desktop" route target. The `getMobileDetect()` method on the request context is eliminated, and replaced with a `getDeviceType()` method that returns a string. This is a breaking change.
This addresses #883. |
if (!loader && loaders[format] && mobileDetect[format]()){ | ||
|
||
// Need to disambiguate for bundleNameUtil. | ||
route.name += '-'+format; |
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.
Do we not need this route.name override thing anymore for some reason?
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 guess maybe it's a product of eliminating mobile
?
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.
Oh, nice catch. We use it for stat partitioning. I'll reintroduce that.
@@ -1070,6 +1071,17 @@ function getNonInternalConfigs() { | |||
return nonInternal; | |||
} | |||
|
|||
function getDeviceType(req) { | |||
var md = new MobileDetect(req.get('user-agent')); | |||
var types = [ 'phone', 'tablet', 'mobile' ]; |
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 still includes mobile
, but the PR comments say we're eliminating that. Can it be removed here?
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.
Thank goodness you're reviewing this carefully. 😳
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.
For once ;)
The mobile-detect package is large. We shouldn't send it to the browser.
This change uses mobile-detect on the server only. It associates a device type with the request and sends only that pre-determined value to the browser.
This eliminates the "mobile" route target, which was previously the union of "phone" and "tablet". These two must be specified individually going forward (though they may route to the same page class). It also adds a "desktop" route target.
The
getMobileDetect()
method on the request context is eliminated, and replaced with agetDeviceType()
method that returns a string.This is a breaking change.