From f7ab3b9706e15ec91d5f701d6552bc826cb22c70 Mon Sep 17 00:00:00 2001
From: Karl Prieb <karl@prieb.me>
Date: Tue, 2 Jan 2018 17:56:56 -0200
Subject: [PATCH 1/5] Fix svg render on firefox

---
 packages/rocketchat-ui/client/components/icon.html |  2 +-
 packages/rocketchat-ui/client/components/icon.js   | 11 +++++++++++
 packages/rocketchat-ui/package.js                  |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 packages/rocketchat-ui/client/components/icon.js

diff --git a/packages/rocketchat-ui/client/components/icon.html b/packages/rocketchat-ui/client/components/icon.html
index d875feb5db3e..fd29bd068e08 100644
--- a/packages/rocketchat-ui/client/components/icon.html
+++ b/packages/rocketchat-ui/client/components/icon.html
@@ -1,5 +1,5 @@
 <template name="icon">
 	<svg class="rc-icon {{block}} {{block}}--{{icon}} {{classes}}" aria-hidden="true">
-		<use xlink:href="#icon-{{icon}}"></use>
+		<use xlink:href="{{baseUrl}}#icon-{{icon}}"></use>
 	</svg>
 </template>
diff --git a/packages/rocketchat-ui/client/components/icon.js b/packages/rocketchat-ui/client/components/icon.js
new file mode 100644
index 000000000000..9b28194ee99f
--- /dev/null
+++ b/packages/rocketchat-ui/client/components/icon.js
@@ -0,0 +1,11 @@
+/* globals isFirefox */
+
+Template.icon.helpers({
+	baseUrl() {
+		if (isFirefox) {
+			return window.location.href.replace(window.location.hash, '');
+		}
+
+		return '';
+	}
+});
diff --git a/packages/rocketchat-ui/package.js b/packages/rocketchat-ui/package.js
index f23eb29a3608..2c9994250719 100644
--- a/packages/rocketchat-ui/package.js
+++ b/packages/rocketchat-ui/package.js
@@ -120,6 +120,7 @@ Package.onUse(function(api) {
 	api.addFiles('client/views/app/photoswipe.js', 'client');
 
 	api.addFiles('client/components/icon.html', 'client');
+	api.addFiles('client/components/icon.js', 'client');
 
 	api.addFiles('client/components/popupList.html', 'client');
 	api.addFiles('client/components/popupList.js', 'client');

From c9176ba88234df735e1f9fe18e95f392a8af58ba Mon Sep 17 00:00:00 2001
From: Karl Prieb <karl@prieb.me>
Date: Tue, 2 Jan 2018 17:58:34 -0200
Subject: [PATCH 2/5] add isFirefox

---
 packages/rocketchat-ui-master/client/main.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js
index 05d98df004f2..8a38e7262237 100644
--- a/packages/rocketchat-ui-master/client/main.js
+++ b/packages/rocketchat-ui-master/client/main.js
@@ -4,6 +4,8 @@ import s from 'underscore.string';
 
 RocketChat.settings.collection.find({_id:/theme-color-rc/i}, {fields:{ value: 1 }}).observe({changed: () => { DynamicCss.run(true); }});
 
+this.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
+
 Template.body.onRendered(function() {
 	new Clipboard('.clipboard');
 

From c97f2776bc3bd462429b5fb98f22b7504ab19c77 Mon Sep 17 00:00:00 2001
From: Karl Prieb <karl@prieb.me>
Date: Wed, 3 Jan 2018 14:15:28 -0200
Subject: [PATCH 3/5] fix baseUrl helper

---
 packages/rocketchat-ui/client/components/icon.js | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/packages/rocketchat-ui/client/components/icon.js b/packages/rocketchat-ui/client/components/icon.js
index 9b28194ee99f..7be7974723e7 100644
--- a/packages/rocketchat-ui/client/components/icon.js
+++ b/packages/rocketchat-ui/client/components/icon.js
@@ -1,11 +1,5 @@
 /* globals isFirefox */
 
-Template.icon.helpers({
-	baseUrl() {
-		if (isFirefox) {
-			return window.location.href.replace(window.location.hash, '');
-		}
+const baseUrl = isFirefox ? () => { FlowRouter.watchPathChange(); return `${ window.location.origin }${ FlowRouter.current().path }`; } : () => '';
 
-		return '';
-	}
-});
+Template.icon.helpers({ baseUrl });

From 3e3cbb4dc0c5319ed8a7734be904671996531362 Mon Sep 17 00:00:00 2001
From: Karl Prieb <karl@prieb.me>
Date: Wed, 3 Jan 2018 14:53:43 -0200
Subject: [PATCH 4/5] check if firefox is < 55

---
 packages/rocketchat-ui-master/client/main.js     | 2 +-
 packages/rocketchat-ui/client/components/icon.js | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js
index 8a38e7262237..74a41c42339d 100644
--- a/packages/rocketchat-ui-master/client/main.js
+++ b/packages/rocketchat-ui-master/client/main.js
@@ -4,7 +4,7 @@ import s from 'underscore.string';
 
 RocketChat.settings.collection.find({_id:/theme-color-rc/i}, {fields:{ value: 1 }}).observe({changed: () => { DynamicCss.run(true); }});
 
-this.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
+this.isFirefox = navigator.userAgent.match(/Firefox\/(\d+)\.\d/);
 
 Template.body.onRendered(function() {
 	new Clipboard('.clipboard');
diff --git a/packages/rocketchat-ui/client/components/icon.js b/packages/rocketchat-ui/client/components/icon.js
index 7be7974723e7..7797ab871935 100644
--- a/packages/rocketchat-ui/client/components/icon.js
+++ b/packages/rocketchat-ui/client/components/icon.js
@@ -1,5 +1,5 @@
 /* globals isFirefox */
 
-const baseUrl = isFirefox ? () => { FlowRouter.watchPathChange(); return `${ window.location.origin }${ FlowRouter.current().path }`; } : () => '';
+const baseUrl = isFirefox && isFirefox[1] < 55 ? () => `${ window.location.origin }${ FlowRouter.current().path }` : () => '';
 
 Template.icon.helpers({ baseUrl });

From 73f0703425dc9035445043db47de6d06dccc05f1 Mon Sep 17 00:00:00 2001
From: Karl Prieb <karl@prieb.me>
Date: Wed, 3 Jan 2018 15:09:47 -0200
Subject: [PATCH 5/5] make the code more readable

---
 packages/rocketchat-ui/client/components/icon.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/packages/rocketchat-ui/client/components/icon.js b/packages/rocketchat-ui/client/components/icon.js
index 7797ab871935..c16c92c2c1c8 100644
--- a/packages/rocketchat-ui/client/components/icon.js
+++ b/packages/rocketchat-ui/client/components/icon.js
@@ -1,5 +1,7 @@
 /* globals isFirefox */
 
-const baseUrl = isFirefox && isFirefox[1] < 55 ? () => `${ window.location.origin }${ FlowRouter.current().path }` : () => '';
+const firefoxBaseUrlFix = () => `${ window.location.origin }${ FlowRouter.current().path }`;
 
-Template.icon.helpers({ baseUrl });
+Template.icon.helpers({
+	baseUrl: isFirefox && isFirefox[1] < 55 ? firefoxBaseUrlFix : undefined
+});