document/tab title: Show number of received messages and move '- PairDrop' to the end

This commit is contained in:
schlagmichdoch 2023-03-02 15:30:25 +01:00
parent a3b348d9b6
commit 7220e85422
2 changed files with 26 additions and 6 deletions

View file

@ -639,7 +639,9 @@ class ReceiveFileDialog extends ReceiveDialog {
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback); this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
this.createPreviewElement(files[0]).finally(_ => { this.createPreviewElement(files[0]).finally(_ => {
document.title = `PairDrop - ${files.length} Files received`; document.title = files.length === 1
? 'File received - PairDrop'
: `(${files.length}) Files received - PairDrop`;
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'}) Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
@ -722,7 +724,7 @@ class ReceiveRequestDialog extends ReceiveDialog {
this.$previewBox.appendChild(element) this.$previewBox.appendChild(element)
} }
document.title = 'PairDrop - File Transfer Requested'; document.title = 'File Transfer Requested - PairDrop';
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
} }
@ -1077,6 +1079,7 @@ class ReceiveTextDialog extends Dialog {
_onText(text, peerId) { _onText(text, peerId) {
window.blop.play(); window.blop.play();
this._receiveTextQueue.push({text: text, peerId: peerId}); this._receiveTextQueue.push({text: text, peerId: peerId});
this._setDocumentTitleMessages();
if (this.$el.attributes["show"]) return; if (this.$el.attributes["show"]) return;
this._dequeueRequests(); this._dequeueRequests();
} }
@ -1100,11 +1103,18 @@ class ReceiveTextDialog extends Dialog {
} else { } else {
this.$text.textContent = text; this.$text.textContent = text;
} }
document.title = 'PairDrop - Message Received'; this._setDocumentTitleMessages();
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
} }
_setDocumentTitleMessages() {
document.title = !this._receiveTextQueue.length
? 'Message Received - PairDrop'
: `(${this._receiveTextQueue.length + 1}) Messages Received - PairDrop`;
}
async _onCopy() { async _onCopy() {
await navigator.clipboard.writeText(this.$text.textContent); await navigator.clipboard.writeText(this.$text.textContent);
Events.fire('notify-user', 'Copied to clipboard'); Events.fire('notify-user', 'Copied to clipboard');

View file

@ -640,7 +640,9 @@ class ReceiveFileDialog extends ReceiveDialog {
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback); this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
this.createPreviewElement(files[0]).finally(_ => { this.createPreviewElement(files[0]).finally(_ => {
document.title = `PairDrop - ${files.length} Files received`; document.title = files.length === 1
? 'File received - PairDrop'
: `(${files.length}) Files received - PairDrop`;
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'}) Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
@ -723,7 +725,7 @@ class ReceiveRequestDialog extends ReceiveDialog {
this.$previewBox.appendChild(element) this.$previewBox.appendChild(element)
} }
document.title = 'PairDrop - File Transfer Requested'; document.title = 'File Transfer Requested - PairDrop';
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
} }
@ -1078,6 +1080,7 @@ class ReceiveTextDialog extends Dialog {
_onText(text, peerId) { _onText(text, peerId) {
window.blop.play(); window.blop.play();
this._receiveTextQueue.push({text: text, peerId: peerId}); this._receiveTextQueue.push({text: text, peerId: peerId});
this._setDocumentTitleMessages();
if (this.$el.attributes["show"]) return; if (this.$el.attributes["show"]) return;
this._dequeueRequests(); this._dequeueRequests();
} }
@ -1101,11 +1104,18 @@ class ReceiveTextDialog extends Dialog {
} else { } else {
this.$text.textContent = text; this.$text.textContent = text;
} }
document.title = 'PairDrop - Message Received'; this._setDocumentTitleMessages();
document.changeFavicon("images/favicon-96x96-notification.png"); document.changeFavicon("images/favicon-96x96-notification.png");
this.show(); this.show();
} }
_setDocumentTitleMessages() {
document.title = !this._receiveTextQueue.length
? 'Message Received - PairDrop'
: `(${this._receiveTextQueue.length + 1}) Messages Received - PairDrop`;
}
async _onCopy() { async _onCopy() {
await navigator.clipboard.writeText(this.$text.textContent); await navigator.clipboard.writeText(this.$text.textContent);
Events.fire('notify-user', 'Copied to clipboard'); Events.fire('notify-user', 'Copied to clipboard');