From f3f457f0846e67dc892941d0bfa7b9247b0b2b6e Mon Sep 17 00:00:00 2001 From: Mustafa Hamza <47627474+mh7777777@users.noreply.github.com> Date: Mon, 15 Mar 2021 16:17:12 +0100 Subject: [PATCH] navigateToSocialWall backward compatibility. (#26) * navigateToSocialWall backward compatibility. * Small fix on navigateToSocialWall --- control/content/index.html | 2 ++ control/content/js/classes/config.js | 1 + widget/app.js | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/control/content/index.html b/control/content/index.html index b7c9e6e..6b0808b 100755 --- a/control/content/index.html +++ b/control/content/index.html @@ -293,6 +293,8 @@ function init() { Config.get() .then(result => { + // This way, we will keep old instances to use PSW navigate by default (so we don't break backward compatibility) and new instances to navigate to CW by default. + if (result && !Object.keys(result.data).length) result.data.navigateToCwByDefault = true; config = new Config(result.data); querystring.value = config.querystring; bothPrivacyDiv.setAttribute('style', 'display: none;'); diff --git a/control/content/js/classes/config.js b/control/content/js/classes/config.js index bf3b7bf..e0a921d 100644 --- a/control/content/js/classes/config.js +++ b/control/content/js/classes/config.js @@ -9,6 +9,7 @@ class Config { this.contentType = dataObj.contentType || 1; this.emptyState = dataObj.emptyState || false; this.emptyStateMessage = dataObj.emptyStateMessage ||'Create your first group now!'; + this.navigateToCwByDefault = dataObj.navigateToCwByDefault || false; } static get PRIVACY() { diff --git a/widget/app.js b/widget/app.js index f9cc916..72250b7 100644 --- a/widget/app.js +++ b/widget/app.js @@ -1,5 +1,5 @@ let breadcrumbsHistory = []; -let config; +let config = {}; let timerId; let colorIndex = 0; let loggedUser = null; @@ -748,11 +748,23 @@ function clearReportsContent() { function navigateTo(topic) { const queryString = getQueryString(config.querystring, topic.id, topic.title, loggedUser ? loggedUser._id : null); - let pluginData = config.pluginData; - if (Object.keys(pluginData).length === 0) { + let pluginData = config && config.pluginData ? config.pluginData : null; + if (!pluginData || Object.keys(pluginData).length === 0) { + const navigateToCwByDefault = ( + config && !Object.keys(config).length + ? + true + : + config && config.navigateToCwByDefault + ? + config.navigateToCwByDefault + : + false + ); buildfire.navigation.navigateToSocialWall({ title: topic.title, - queryString: `wid=${topic.id}&topic_title=${topic.title}&privacy=${topic.privacy}` + queryString: `wid=${topic.id}&topic_title=${topic.title}&privacy=${topic.privacy}`, + pluginTypeOrder: navigateToCwByDefault ? ['community', 'premium_social', 'social'] : ['premium_social', 'social', 'community'] }) } else { if (topic.originalShareId) pluginData.queryString = 'wid=' + topic.originalShareId + '&privacy=' + topic.privacy;