Skip to content

Instantly share code, notes, and snippets.

@banderson623
Last active January 30, 2023 21:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save banderson623/81889e7764da84f32112 to your computer and use it in GitHub Desktop.
Save banderson623/81889e7764da84f32112 to your computer and use it in GitHub Desktop.
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);
@timcharper
Copy link

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

@akaralar
Copy link

how do I use this?

@marcelo4768
Copy link

is it posible that u made the same but for gmail in fluid app please ?

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