mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-10-31 03:53:34 +00:00 
			
		
		
		
	This PR adds reply option to notifications of macOS using `node-mac-notifier` and then post the reply for to the webapp. It also fixes an issue that even though the app is focused the server that sent the notification did not focus. And it also adds parsing for mentioning. This also refactors code for notification. Fixes: #284, #381.
		
			
				
	
	
		
			32 lines
		
	
	
		
			806 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			806 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const { ipcRenderer } = require('electron');
 | |
| const ConfigUtil = require('../utils/config-util');
 | |
| const { focusCurrentServer } = require('./helpers');
 | |
| 
 | |
| const NativeNotification = window.Notification;
 | |
| class BaseNotification extends NativeNotification {
 | |
| 	constructor(title, opts) {
 | |
| 		opts.silent = true;
 | |
| 		super(title, opts);
 | |
| 
 | |
| 		this.addEventListener('click', () => {
 | |
| 			// focus to the server who sent the
 | |
| 			// notification if not focused already
 | |
| 			focusCurrentServer();
 | |
| 			ipcRenderer.send('focus-app');
 | |
| 		});
 | |
| 	}
 | |
| 
 | |
| 	static requestPermission() {
 | |
| 		return; // eslint-disable-line no-useless-return
 | |
| 	}
 | |
| 
 | |
| 	// Override default Notification permission
 | |
| 	static get permission() {
 | |
| 		return ConfigUtil.getConfigItem('showNotification') ? 'granted' : 'denied';
 | |
| 	}
 | |
| }
 | |
| 
 | |
| module.exports = BaseNotification;
 |