Browse Source

Add tabs service icon loading (slack)

pull/1160/head
Maxime Myers 8 years ago
parent
commit
d80de2a610
  1. 32
      app/util/IconLoader.js
  2. 11
      app/ux/WebView.js

32
app/util/IconLoader.js

@ -0,0 +1,32 @@
/**
* Singleton class to handle the global unread counter.
*/
Ext.define('Rambox.util.IconLoader', {
singleton: true,
constructor: function(config) {
config = config || {};
/**
* Sets the icon for a specific service.
*
* @param {*} id Id of the service
*/
this.loadServiceIconUrl = function (service, webview) {
switch (service.type) {
case 'slack':
webview.executeJavaScript("(()=>{let a=document.querySelector('.team_icon');if(!a){const d=document.querySelector('#team_menu');d&&(d.click(),a=document.querySelector('.team_icon'))}if(!a)return!1;const{style:{backgroundImage:b}}=a,c=document.createEvent('MouseEvents');return c.initEvent('mousedown',!0,!0),document.querySelector('.client_channels_list_container').dispatchEvent(c),b.slice(5,-2)})();",
false,
function (backgroundImage) {
if (backgroundImage) {
service.fireEvent('iconchange', service, backgroundImage, service.icon);
}
}
);
break;
}
};
}
});

11
app/ux/WebView.js

@ -8,7 +8,8 @@ Ext.define('Rambox.ux.WebView',{
,requires: [
'Rambox.util.Format'
,'Rambox.util.Notifier'
,'Rambox.util.UnreadCounter'
,'Rambox.util.UnreadCounter'
,'Rambox.util.IconLoader'
]
// private
@ -250,11 +251,13 @@ Ext.define('Rambox.ux.WebView',{
Rambox.app.setTotalServicesLoaded( Rambox.app.getTotalServicesLoaded() + 1 );
// Apply saved zoom level
webview.setZoomLevel(me.record.get('zoomLevel'));
webview.setZoomLevel(me.record.get('zoomLevel'));
Rambox.util.IconLoader.loadServiceIconUrl(me, webview);
});
// Open links in default browser
webview.addEventListener('new-window', function(e) {
webview.addEventListener('new-window', function(e) {
switch ( me.type ) {
case 'skype':
// hack to fix multiple browser tabs on Skype link click, re #11
@ -343,7 +346,7 @@ Ext.define('Rambox.ux.WebView',{
e.preventDefault();
});
webview.addEventListener("dom-ready", function(e) {
webview.addEventListener("dom-ready", function(e) {
// Mute Webview
if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true);

Loading…
Cancel
Save