From 295e80eb720bd9d1ea1c752eaf72991c0cafded3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 14 Dec 2019 01:41:37 -0700 Subject: [PATCH] Add Force MetroUI labs experiment --- .../assets/js/components/PostComponent.vue | 18 ++++++++++-------- resources/assets/js/components/Profile.vue | 15 ++++++++------- resources/views/settings/labs.blade.php | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 61df5093a..2ed8b6db0 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -10,7 +10,7 @@
-
+
@@ -245,7 +245,7 @@
-
+
@@ -619,16 +619,18 @@ export default { showCaption: true, ctxEmbedPayload: false, copiedEmbed: false, + layout: this.profileLayout } }, beforeMount() { let u = new URLSearchParams(window.location.search); - if(u.has('ui') && u.get('ui') == 'moment' && this.profileLayout != 'moment') { - this.profileLayout = 'moment'; + let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true'; + if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') { + this.layout = 'metro'; } - if(u.has('ui') && u.get('ui') == 'metro' && this.profileLayout != 'metro') { - this.profileLayout = 'metro'; + if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') { + this.layout = 'moment'; } }, @@ -914,7 +916,7 @@ export default { .then(function(res) { let entity = res.data.entity; if(entity.in_reply_to_id == self.status.id) { - if(self.profileLayout == 'metro') { + if(self.layout == 'metro') { self.results.push(entity); } else { self.results.unshift(entity); @@ -973,7 +975,7 @@ export default { axios.get(url) .then(response => { let self = this; - this.results = this.profileLayout == 'metro' ? + this.results = this.layout == 'metro' ? _.reverse(response.data.data) : response.data.data; this.pagination = response.data.meta.pagination; diff --git a/resources/assets/js/components/Profile.vue b/resources/assets/js/components/Profile.vue index a33c58e9a..ecec7cc18 100644 --- a/resources/assets/js/components/Profile.vue +++ b/resources/assets/js/components/Profile.vue @@ -569,20 +569,17 @@ } }, beforeMount() { - if(window.outerWidth < 576) { - $('nav.navbar').hide(); - this.isMobile = true; - } this.fetchRelationships(); this.fetchProfile(); let u = new URLSearchParams(window.location.search); + let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true'; + if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') { + this.layout = 'metro'; + } if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') { Vue.use(VueMasonry); this.layout = 'moment'; } - if(u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') { - this.layout = 'metro'; - } if(this.layout == 'metro' && u.has('t')) { if(this.modes.indexOf(u.get('t')) != -1) { if(u.get('t') == 'bookmarks') { @@ -607,6 +604,10 @@ this.user = res.data; }); } + if(window.outerWidth < 576) { + $('nav.navbar').hide(); + this.isMobile = true; + } }, updated() { diff --git a/resources/views/settings/labs.blade.php b/resources/views/settings/labs.blade.php index 980a5dfdf..565660571 100644 --- a/resources/views/settings/labs.blade.php +++ b/resources/views/settings/labs.blade.php @@ -182,6 +182,11 @@

Show Tips on Timelines (Desktop Only)

+
+ + +

Force MetroUI layout for profiles and posts.

+

Discovery


@@ -210,6 +215,7 @@ $(document).ready(function() { let showSuggestions = localStorage.getItem('pf_metro_ui.exp.rec') == 'false' ? false : true; let showReadMore = localStorage.getItem('pf_metro_ui.exp.rm') == 'false' ? false : true; let distractionFree = localStorage.getItem('pf_metro_ui.exp.df') == 'true' ? true : false; + let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true' ? true : false; if(showSuggestions == true) { $('#show_suggestions').attr('checked', true); @@ -227,6 +233,10 @@ $(document).ready(function() { $('#show_tips').attr('checked', true); } + if(forceMetro == true) { + $('#force_metro').attr('checked', true); + } + $('#show_suggestions').on('change', function(e) { if(e.target.checked) { localStorage.removeItem('pf_metro_ui.exp.rec'); @@ -258,6 +268,14 @@ $(document).ready(function() { localStorage.removeItem('metro-tips'); } }); + + $('#force_metro').on('change', function(e) { + if(e.target.checked) { + localStorage.setItem('pf_metro_ui.exp.forceMetro', true); + } else { + localStorage.removeItem('pf_metro_ui.exp.forceMetro'); + } + }) }); @endpush \ No newline at end of file