MCPcopy
hub / github.com/SnapDrop/snapdrop / _notify

Method _notify

client/scripts/ui.js:423–447  ·  view source on GitHub ↗
(message, body)

Source from the content-addressed store, hash-verified

421 }
422
423 _notify(message, body) {
424 const config = {
425 body: body,
426 icon: '/images/logo_transparent_128x128.png',
427 }
428 let notification;
429 try {
430 notification = new Notification(message, config);
431 } catch (e) {
432 // Android doesn't support "new Notification" if service worker is installed
433 if (!serviceWorker || !serviceWorker.showNotification) return;
434 notification = serviceWorker.showNotification(message, config);
435 }
436
437 // Notification is persistent on Android. We have to close it manually
438 const visibilitychangeHandler = () => {
439 if (document.visibilityState === 'visible') {
440 notification.close();
441 Events.off('visibilitychange', visibilitychangeHandler);
442 }
443 };
444 Events.on('visibilitychange', visibilitychangeHandler);
445
446 return notification;
447 }
448
449 _messageNotification(message) {
450 if (document.visibilityState !== 'visible') {

Callers 4

_requestPermissionMethod · 0.95
_messageNotificationMethod · 0.95
_downloadNotificationMethod · 0.95
_copyTextMethod · 0.95

Calls 1

onMethod · 0.80

Tested by

no test coverage detected