From 71571b9316d11aaae910c2ebddc3421a3adcb0ee Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 17 Oct 2013 12:19:09 -0400 Subject: [PATCH] Never show preview pane in composer on mobile. --- .../javascripts/discourse/models/composer.js | 2 +- test/javascripts/models/composer_test.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js index 432d96dc6..7d5d92c46 100644 --- a/app/assets/javascripts/discourse/models/composer.js +++ b/app/assets/javascripts/discourse/models/composer.js @@ -257,7 +257,7 @@ Discourse.Composer = Discourse.Model.extend({ init: function() { this._super(); - var val = Discourse.KeyValueStore.get('composer.showPreview') || 'true'; + var val = (Discourse.Mobile.mobileView ? false : (Discourse.KeyValueStore.get('composer.showPreview') || 'true')); this.set('showPreview', val === 'true'); this.set('archetypeId', Discourse.Site.currentProp('default_archetype')); }, diff --git a/test/javascripts/models/composer_test.js b/test/javascripts/models/composer_test.js index 23de36fbf..5ed17c636 100644 --- a/test/javascripts/models/composer_test.js +++ b/test/javascripts/models/composer_test.js @@ -187,4 +187,20 @@ test('initial category when uncategorized is not allowed', function() { Discourse.SiteSettings.allow_uncategorized_topics = false; var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1}); ok(composer.get('categoryId') === undefined, "Uncategorized by default. Must choose a category."); -}); \ No newline at end of file +}); + +test('showPreview', function() { + var new_composer = function() { + return Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1}); + }; + + Discourse.Mobile.mobileView = true; + equal(new_composer().get('showPreview'), false, "Don't show preview in mobile view"); + + Discourse.KeyValueStore.set({ key: 'composer.showPreview', value: 'true' }); + equal(new_composer().get('showPreview'), false, "Don't show preview in mobile view even if KeyValueStore wants to"); + Discourse.KeyValueStore.remove('composer.showPreview'); + + Discourse.Mobile.mobileView = false; + equal(new_composer().get('showPreview'), true, "Show preview by default in desktop view"); +});