diff --git a/index.js b/index.js
index e624b97..1da1881 100644
--- a/index.js
+++ b/index.js
@@ -219,10 +219,15 @@ class MoreLoadServer {
}
_onDisconnect(sender) {
+ this._disconnect(sender);
+ }
+
+ _disconnect(sender) {
this._leaveRoom(sender, 'ip', '', true);
this._leaveAllSecretRooms(sender, true);
this._removeRoomKey(sender.roomKey);
sender.roomKey = null;
+ sender.socket.terminate();
}
_onRoomSecrets(sender, message) {
@@ -358,6 +363,7 @@ class MoreLoadServer {
const room = roomType === 'ip' ? peer.ip : roomSecret;
if (this._rooms[room] && this._rooms[room][peer.id]) {
+ // ensures that otherPeers never receive `peer-left` after `peer-joined` on reconnect.
this._leaveRoom(peer, roomType, roomSecret);
}
@@ -385,10 +391,6 @@ class MoreLoadServer {
// delete the peer
delete this._rooms[room][peer.id];
- if (roomType === 'ip') {
- peer.socket.terminate();
- }
-
//if room is empty, delete the room
if (!Object.keys(this._rooms[room]).length) {
delete this._rooms[room];
@@ -468,8 +470,7 @@ class MoreLoadServer {
peer.lastBeat = Date.now();
}
if (Date.now() - peer.lastBeat > 2 * timeout) {
- this._leaveRoom(peer);
- this._leaveAllSecretRooms(peer);
+ this._disconnect(peer);
return;
}
@@ -726,4 +727,4 @@ const cyrb53 = function(str, seed = 0) {
return 4294967296 * (2097151 & h2) + (h1>>>0);
};
-new MoreLoadServer();
+new MoreLoadServer();
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 5adf272..1067039 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "moreload",
- "version": "1.7.4",
+ "version": "1.7.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "moreload",
- "version": "1.7.4",
+ "version": "1.7.6",
"license": "ISC",
"dependencies": {
"express": "^4.18.2",
diff --git a/package.json b/package.json
index 01233fd..b34c794 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "moreload",
- "version": "1.7.4",
+ "version": "1.7.6",
"description": "",
"main": "index.js",
"scripts": {
diff --git a/public/index.html b/public/index.html
index 13b9f20..1184a30 100644
--- a/public/index.html
+++ b/public/index.html
@@ -278,7 +278,7 @@
MoreLoad
-
v1.7.4
+
v1.7.6
The easiest way to transfer files across devices
diff --git a/public/scripts/ui.js b/public/scripts/ui.js
index 6705eb3..8888615 100644
--- a/public/scripts/ui.js
+++ b/public/scripts/ui.js
@@ -1296,13 +1296,13 @@ class SendTextDialog extends Dialog {
}
async _onKeyDown(e) {
- if (this.isShown()) {
- if (e.code === "Escape") {
- this.hide();
- } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
- if (this._textInputEmpty()) return;
- this._send();
- }
+ if (!this.isShown()) return;
+
+ if (e.code === "Escape") {
+ this.hide();
+ } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
+ if (this._textInputEmpty()) return;
+ this._send();
}
}
@@ -1420,7 +1420,8 @@ class ReceiveTextDialog extends Dialog {
}
async _onCopy() {
- await navigator.clipboard.writeText(this.$text.innerText);
+ const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' ');
+ await navigator.clipboard.writeText(sanitizedText);
Events.fire('notify-user', 'Copied to clipboard');
this.hide();
}
diff --git a/public/service-worker.js b/public/service-worker.js
index d5c381a..69ba558 100644
--- a/public/service-worker.js
+++ b/public/service-worker.js
@@ -1,4 +1,4 @@
-const cacheVersion = 'v1.7.4';
+const cacheVersion = 'v1.7.6';
const cacheTitle = `moreload-cache-${cacheVersion}`;
const urlsToCache = [
'index.html',
diff --git a/public_included_ws_fallback/index.html b/public_included_ws_fallback/index.html
index 7901d91..d2f96bb 100644
--- a/public_included_ws_fallback/index.html
+++ b/public_included_ws_fallback/index.html
@@ -281,7 +281,7 @@
MoreLoad
-
v1.7.4
+
v1.7.6
The easiest way to transfer files across devices
diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js
index 15d2397..1f38d3e 100644
--- a/public_included_ws_fallback/scripts/ui.js
+++ b/public_included_ws_fallback/scripts/ui.js
@@ -1297,13 +1297,13 @@ class SendTextDialog extends Dialog {
}
async _onKeyDown(e) {
- if (this.isShown()) {
- if (e.code === "Escape") {
- this.hide();
- } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
- if (this._textInputEmpty()) return;
- this._send();
- }
+ if (!this.isShown()) return;
+
+ if (e.code === "Escape") {
+ this.hide();
+ } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
+ if (this._textInputEmpty()) return;
+ this._send();
}
}
@@ -1421,7 +1421,8 @@ class ReceiveTextDialog extends Dialog {
}
async _onCopy() {
- await navigator.clipboard.writeText(this.$text.innerText);
+ const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' ');
+ await navigator.clipboard.writeText(sanitizedText);
Events.fire('notify-user', 'Copied to clipboard');
this.hide();
}
diff --git a/public_included_ws_fallback/service-worker.js b/public_included_ws_fallback/service-worker.js
index 9badd17..aba6397 100644
--- a/public_included_ws_fallback/service-worker.js
+++ b/public_included_ws_fallback/service-worker.js
@@ -1,4 +1,4 @@
-const cacheVersion = 'v1.7.4';
+const cacheVersion = 'v1.7.6';
const cacheTitle = `moreload-included-ws-fallback-cache-${cacheVersion}`;
const urlsToCache = [
'index.html',