- commit
- 90cb722eb56df01cfd1c62af86f566bcbaa0725e
- parent
- 0b2607c0e504345f5ce7eac688bdbcef30453e56
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-05-04 06:08
buffer changes on connection error
Diffstat
| M | static/index.js | 11 | +++++++++-- |
1 files changed, 9 insertions, 2 deletions
diff --git a/static/index.js b/static/index.js
@@ -8,6 +8,7 @@ var el = document.querySelector('textarea');
8 8 var old = el.value;
9 9
10 10 var localChanges = [];
-1 11 var stagedChanges = [];
11 12
12 13 document.title += ' - ' + room;
13 14
@@ -48,9 +49,15 @@ signal.listen(room, function(msg) {
48 49 });
49 50
50 51 setInterval(function() {
51 -1 if (localChanges.length) {
52 -1 signal.post(room, {sender: id, type: 'changes', data: localChanges});
-1 52 if (localChanges.length && !stagedChanges.length) {
-1 53 stagedChanges = localChanges;
53 54 localChanges = [];
-1 55 var msg = {sender: id, type: 'changes', data: stagedChanges};
-1 56 signal.post(room, msg).catch(() => {
-1 57 localChanges = stagedChanges.concat(localChanges);
-1 58 }).finally(() => {
-1 59 stagedChanges = [];
-1 60 });
54 61 }
55 62 }, 500);
56 63