Fix missing async in Notification class; Fix too many arguments for window.open function

This commit is contained in:
schlagmichdoch 2023-11-02 01:31:31 +01:00
parent d388f7e3cd
commit c068a2e329
2 changed files with 26 additions and 24 deletions

View file

@ -2117,8 +2117,9 @@ class Notifications {
Events.on('files-transfer-request', e => this._requestNotification(e.detail.request, e.detail.peerId)); Events.on('files-transfer-request', e => this._requestNotification(e.detail.request, e.detail.peerId));
} }
_requestPermission() { async _requestPermission() {
Notification.requestPermission(permission => { await Notification.
requestPermission(permission => {
if (permission !== 'granted') { if (permission !== 'granted') {
Events.fire('notify-user', Localization.getTranslation("notifications.notifications-permissions-error")); Events.fire('notify-user', Localization.getTranslation("notifications.notifications-permissions-error"));
return; return;
@ -2159,7 +2160,7 @@ class Notifications {
const peerDisplayName = $(peerId).ui._displayName(); const peerDisplayName = $(peerId).ui._displayName();
if (/^((https?:\/\/|www)[abcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)$/.test(message.toLowerCase())) { if (/^((https?:\/\/|www)[abcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)$/.test(message.toLowerCase())) {
const notification = this._notify(Localization.getTranslation("notifications.link-received", null, {name: peerDisplayName}), message); const notification = this._notify(Localization.getTranslation("notifications.link-received", null, {name: peerDisplayName}), message);
this._bind(notification, _ => window.open(message, '_blank', null, true)); this._bind(notification, _ => window.open(message, '_blank', "noreferrer"));
} else { } else {
const notification = this._notify(Localization.getTranslation("notifications.message-received", null, {name: peerDisplayName}), message); const notification = this._notify(Localization.getTranslation("notifications.message-received", null, {name: peerDisplayName}), message);
this._bind(notification, _ => this._copyText(message, notification)); this._bind(notification, _ => this._copyText(message, notification));
@ -2235,8 +2236,8 @@ class Notifications {
notification.close(); notification.close();
} }
_copyText(message, notification) { async _copyText(message, notification) {
if (navigator.clipboard.writeText(message)) { if (await navigator.clipboard.writeText(message)) {
notification.close(); notification.close();
this._notify(Localization.getTranslation("notifications.copied-text")); this._notify(Localization.getTranslation("notifications.copied-text"));
} else { } else {

View file

@ -2119,8 +2119,9 @@ class Notifications {
Events.on('files-transfer-request', e => this._requestNotification(e.detail.request, e.detail.peerId)); Events.on('files-transfer-request', e => this._requestNotification(e.detail.request, e.detail.peerId));
} }
_requestPermission() { async _requestPermission() {
Notification.requestPermission(permission => { await Notification.
requestPermission(permission => {
if (permission !== 'granted') { if (permission !== 'granted') {
Events.fire('notify-user', Localization.getTranslation("notifications.notifications-permissions-error")); Events.fire('notify-user', Localization.getTranslation("notifications.notifications-permissions-error"));
return; return;
@ -2161,7 +2162,7 @@ class Notifications {
const peerDisplayName = $(peerId).ui._displayName(); const peerDisplayName = $(peerId).ui._displayName();
if (/^((https?:\/\/|www)[abcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)$/.test(message.toLowerCase())) { if (/^((https?:\/\/|www)[abcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)$/.test(message.toLowerCase())) {
const notification = this._notify(Localization.getTranslation("notifications.link-received", null, {name: peerDisplayName}), message); const notification = this._notify(Localization.getTranslation("notifications.link-received", null, {name: peerDisplayName}), message);
this._bind(notification, _ => window.open(message, '_blank', null, true)); this._bind(notification, _ => window.open(message, '_blank', "noreferrer"));
} else { } else {
const notification = this._notify(Localization.getTranslation("notifications.message-received", null, {name: peerDisplayName}), message); const notification = this._notify(Localization.getTranslation("notifications.message-received", null, {name: peerDisplayName}), message);
this._bind(notification, _ => this._copyText(message, notification)); this._bind(notification, _ => this._copyText(message, notification));
@ -2237,8 +2238,8 @@ class Notifications {
notification.close(); notification.close();
} }
_copyText(message, notification) { async _copyText(message, notification) {
if (navigator.clipboard.writeText(message)) { if (await navigator.clipboard.writeText(message)) {
notification.close(); notification.close();
this._notify(Localization.getTranslation("notifications.copied-text")); this._notify(Localization.getTranslation("notifications.copied-text"));
} else { } else {