Skip to content

Commit

Permalink
navigateToSocialWall backward compatibility. (#26)
Browse files Browse the repository at this point in the history
* navigateToSocialWall backward compatibility.

* Small fix on navigateToSocialWall
  • Loading branch information
mustafa-hamza authored Mar 15, 2021
1 parent 1d5908a commit f3f457f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;');
Expand Down
1 change: 1 addition & 0 deletions control/content/js/classes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
20 changes: 16 additions & 4 deletions widget/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let breadcrumbsHistory = [];
let config;
let config = {};
let timerId;
let colorIndex = 0;
let loggedUser = null;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f3f457f

Please sign in to comment.