Skip to content
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

Merged
merged 4 commits into from
Sep 12, 2017
Merged

Simplify device type routing #950

merged 4 commits into from
Sep 12, 2017

Conversation

gigabo
Copy link
Contributor

@gigabo gigabo commented Sep 8, 2017

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.

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.
@gigabo
Copy link
Contributor Author

gigabo commented Sep 8, 2017

This addresses #883.

if (!loader && loaders[format] && mobileDetect[format]()){

// Need to disambiguate for bundleNameUtil.
route.name += '-'+format;
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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' ];
Copy link
Member

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?

Copy link
Contributor Author

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. 😳

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For once ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants