mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Fix: notify user that "Selected peer left." only if dialog is shown.
This commit is contained in:
parent
8d640be3a2
commit
7606fb398b
2 changed files with 26 additions and 16 deletions
|
@ -573,6 +573,10 @@ class Dialog {
|
||||||
if (this.$autoFocus) this.$autoFocus.focus();
|
if (this.$autoFocus) this.$autoFocus.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isShown() {
|
||||||
|
return !!this.$el.attributes["show"];
|
||||||
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.$el.removeAttribute('show');
|
this.$el.removeAttribute('show');
|
||||||
if (this.$autoFocus) {
|
if (this.$autoFocus) {
|
||||||
|
@ -581,10 +585,11 @@ class Dialog {
|
||||||
}
|
}
|
||||||
document.title = 'PairDrop';
|
document.title = 'PairDrop';
|
||||||
document.changeFavicon("images/favicon-96x96.png");
|
document.changeFavicon("images/favicon-96x96.png");
|
||||||
|
this.correspondingPeerId = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPeerDisconnected(peerId) {
|
_onPeerDisconnected(peerId) {
|
||||||
if (this.correspondingPeerId === peerId) {
|
if (this.isShown() && this.correspondingPeerId === peerId) {
|
||||||
this.hide();
|
this.hide();
|
||||||
Events.fire('notify-user', 'Selected peer left.')
|
Events.fire('notify-user', 'Selected peer left.')
|
||||||
}
|
}
|
||||||
|
@ -850,14 +855,14 @@ class ReceiveRequestDialog extends ReceiveDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
this._respondToFileTransferRequest(false);
|
this._respondToFileTransferRequest(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRequestFileTransfer(request, peerId) {
|
_onRequestFileTransfer(request, peerId) {
|
||||||
this._filesTransferRequestQueue.push({request: request, peerId: peerId});
|
this._filesTransferRequestQueue.push({request: request, peerId: peerId});
|
||||||
if (this.$el.attributes["show"]) return;
|
if (this.isShown()) return;
|
||||||
this._dequeueRequests();
|
this._dequeueRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +964,7 @@ class PairDeviceDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
// Timeout to prevent paste mode from getting cancelled simultaneously
|
// Timeout to prevent paste mode from getting cancelled simultaneously
|
||||||
setTimeout(_ => this._pairDeviceCancel(), 50);
|
setTimeout(_ => this._pairDeviceCancel(), 50);
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1157,7 @@ class EditPairedDevicesDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1257,7 @@ class SendTextDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onKeyDown(e) {
|
async _onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"]) {
|
if (this.isShown()) {
|
||||||
if (e.code === "Escape") {
|
if (e.code === "Escape") {
|
||||||
this.hide();
|
this.hide();
|
||||||
} else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
|
} else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
|
||||||
|
@ -1321,7 +1326,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onKeyDown(e) {
|
async _onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"]) {
|
if (this.isShown()) {
|
||||||
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
|
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
|
||||||
await this._onCopy()
|
await this._onCopy()
|
||||||
this.hide();
|
this.hide();
|
||||||
|
@ -1335,7 +1340,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
window.blop.play();
|
window.blop.play();
|
||||||
this._receiveTextQueue.push({text: text, peerId: peerId});
|
this._receiveTextQueue.push({text: text, peerId: peerId});
|
||||||
this._setDocumentTitleMessages();
|
this._setDocumentTitleMessages();
|
||||||
if (this.$el.attributes["show"]) return;
|
if (this.isShown()) return;
|
||||||
this._dequeueRequests();
|
this._dequeueRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -574,6 +574,10 @@ class Dialog {
|
||||||
if (this.$autoFocus) this.$autoFocus.focus();
|
if (this.$autoFocus) this.$autoFocus.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isShown() {
|
||||||
|
return !!this.$el.attributes["show"];
|
||||||
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.$el.removeAttribute('show');
|
this.$el.removeAttribute('show');
|
||||||
if (this.$autoFocus) {
|
if (this.$autoFocus) {
|
||||||
|
@ -582,10 +586,11 @@ class Dialog {
|
||||||
}
|
}
|
||||||
document.title = 'PairDrop';
|
document.title = 'PairDrop';
|
||||||
document.changeFavicon("images/favicon-96x96.png");
|
document.changeFavicon("images/favicon-96x96.png");
|
||||||
|
this.correspondingPeerId = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPeerDisconnected(peerId) {
|
_onPeerDisconnected(peerId) {
|
||||||
if (this.correspondingPeerId === peerId) {
|
if (this.isShown() && this.correspondingPeerId === peerId) {
|
||||||
this.hide();
|
this.hide();
|
||||||
Events.fire('notify-user', 'Selected peer left.')
|
Events.fire('notify-user', 'Selected peer left.')
|
||||||
}
|
}
|
||||||
|
@ -851,14 +856,14 @@ class ReceiveRequestDialog extends ReceiveDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
this._respondToFileTransferRequest(false);
|
this._respondToFileTransferRequest(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRequestFileTransfer(request, peerId) {
|
_onRequestFileTransfer(request, peerId) {
|
||||||
this._filesTransferRequestQueue.push({request: request, peerId: peerId});
|
this._filesTransferRequestQueue.push({request: request, peerId: peerId});
|
||||||
if (this.$el.attributes["show"]) return;
|
if (this.isShown()) return;
|
||||||
this._dequeueRequests();
|
this._dequeueRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +965,7 @@ class PairDeviceDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
// Timeout to prevent paste mode from getting cancelled simultaneously
|
// Timeout to prevent paste mode from getting cancelled simultaneously
|
||||||
setTimeout(_ => this._pairDeviceCancel(), 50);
|
setTimeout(_ => this._pairDeviceCancel(), 50);
|
||||||
}
|
}
|
||||||
|
@ -1153,7 +1158,7 @@ class EditPairedDevicesDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown(e) {
|
_onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"] && e.code === "Escape") {
|
if (this.isShown() && e.code === "Escape") {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1258,7 @@ class SendTextDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onKeyDown(e) {
|
async _onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"]) {
|
if (this.isShown()) {
|
||||||
if (e.code === "Escape") {
|
if (e.code === "Escape") {
|
||||||
this.hide();
|
this.hide();
|
||||||
} else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
|
} else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
|
||||||
|
@ -1322,7 +1327,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onKeyDown(e) {
|
async _onKeyDown(e) {
|
||||||
if (this.$el.attributes["show"]) {
|
if (this.isShown()) {
|
||||||
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
|
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
|
||||||
await this._onCopy()
|
await this._onCopy()
|
||||||
this.hide();
|
this.hide();
|
||||||
|
@ -1336,7 +1341,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
window.blop.play();
|
window.blop.play();
|
||||||
this._receiveTextQueue.push({text: text, peerId: peerId});
|
this._receiveTextQueue.push({text: text, peerId: peerId});
|
||||||
this._setDocumentTitleMessages();
|
this._setDocumentTitleMessages();
|
||||||
if (this.$el.attributes["show"]) return;
|
if (this.isShown()) return;
|
||||||
this._dequeueRequests();
|
this._dequeueRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue