Disable live previews on mobile

Summary:
Fixes T1895. Now that we have on-demand prviews, we can use them on mobile. On mobile:

  - don't show live previews;
  - only save drafts every 10 seconds.

Also, show fewer remarkup buttons on mobile to try to make sure the more important ones (preview, e.g.) fit.

Test Plan:
  - Made window narrower and wider to trigger preview/no-preview behavior.
  - Used DarkConsole to verify request rate.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T1895

Differential Revision: https://secure.phabricator.com/D14856
This commit is contained in:
epriestley
2015-12-22 12:27:51 -08:00
parent f5ff10fe28
commit 8752bd4966
4 changed files with 53 additions and 13 deletions

View File

@@ -115,6 +115,10 @@ JX.behavior('comment-actions', function(config) {
}
function onresponse(response) {
if (JX.Device.getDevice() != 'desktop') {
return;
}
var panel = JX.$(config.panelID);
if (!response.xactions.length) {
JX.DOM.hide(panel);
@@ -152,7 +156,25 @@ JX.behavior('comment-actions', function(config) {
JX.DOM.listen(form_node, 'shouldRefresh', null, always_trigger);
request.start();
var ondevicechange = function() {
var panel = JX.$(config.panelID);
if (JX.Device.getDevice() == 'desktop') {
request.setRateLimit(500);
always_trigger();
} else {
// On mobile, don't show live previews and only save drafts every
// 10 seconds.
request.setRateLimit(10000);
JX.DOM.hide(panel);
}
};
ondevicechange();
JX.Stratcom.listen('phabricator-device-change', null, ondevicechange);
}
restore_draft_actions(config.drafts || []);
});