Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Use native notification center for Slack in fluid.app
var clickOverrides = function(){
// Automatically mark ALL as read and scroll to it
// when clicking on a channel (stared or normal)
$('#channel-list, #starred-list').on('click',function(){
TS.ui.forceMarkAllRead();
TS.ui.scrollMsgsSoFirstUnreadMsgIsInView();
});
};
var onMessageClick = function(){
TS.ui.forceMarkAllRead();
TS.ui.scrollMsgsSoFirstUnreadMsgIsInView();
};
// Setup and use notification center! Yay.
function wkNotify(title,content,clickCallBack) {
if (!window.Notification) {
console.log('not supported');
return;
}
if (Notification.permission === 'denied') {
console.log("Can't show notification here");
} else if (Notification.permission === 'default') {
// Get permission
Notification.requestPermission(function() {
notify();
});
} else if (Notification.permission === 'granted') {
var wkNotification = window.webkitNotifications.createNotification(null, title, content);
if(typeof clickCallBack === "function"){
wkNotification.onclick = clickCallBack;
}
// Show that thing!
try {wkNotification.show();}
catch (e) {alert('error: '+e);}
}
}
// override the growl and use notification center
// wait 10 seconds for everything to load, then do this
setTimeout(function(){
clickOverrides();
wkNotify("Loaded custom scripts","");
TS.ui.growls.show = function(title, text, a,b,c){
wkNotify(title,text,onMessageClick);
};
},10000);

are you still using this? I'm pretty upset with the native slack app performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment