From 0afa28de0953ed528486a7d7ad6000f344624710 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 9 Aug 2016 09:53:22 -0400 Subject: Changed autodetection of SiteURL (#3764) * Changed autoconfiguration of SiteURL to be done on every request * Added SiteURL to system console --- webapp/stores/team_store.jsx | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'webapp/stores') diff --git a/webapp/stores/team_store.jsx b/webapp/stores/team_store.jsx index a482fa3a1..90cb66bb2 100644 --- a/webapp/stores/team_store.jsx +++ b/webapp/stores/team_store.jsx @@ -60,13 +60,7 @@ class TeamStoreClass extends EventEmitter { } getCurrentId() { - var team = this.get(this.currentTeamId); - - if (team) { - return team.id; - } - - return null; + return this.currentTeamId; } getCurrent() { @@ -80,10 +74,7 @@ class TeamStoreClass extends EventEmitter { } getCurrentTeamUrl() { - if (this.getCurrent()) { - return window.mm_config.SiteURL + '/' + this.getCurrent().name; - } - return ''; + return this.getTeamUrl(this.currentTeamId); } getCurrentTeamRelativeUrl() { @@ -97,7 +88,10 @@ class TeamStoreClass extends EventEmitter { const current = this.getCurrent(); if (current) { - return window.mm_config.SiteURL + '/signup_user_complete/?id=' + current.invite_id; + // can't call Utils.getSiteURL here because that introduces a circular dependency + const origin = window.mm_config.SiteURL || window.location.origin; + + return origin + '/signup_user_complete/?id=' + current.invite_id; } return ''; @@ -105,11 +99,15 @@ class TeamStoreClass extends EventEmitter { getTeamUrl(id) { const team = this.get(id); - if (team) { - return window.mm_config.SiteURL + '/' + team.name; + + if (!team) { + return ''; } - return ''; + // can't call Utils.getSiteURL here because that introduces a circular dependency + const origin = window.mm_config.SiteURL || window.location.origin; + + return origin + '/' + team.name; } saveTeam(team) { -- cgit v1.2.3-1-g7c22