summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-14 17:39:52 +0800
committerWu Cheng-Han2016-10-14 17:39:52 +0800
commit912063bee410b087ff82ae7f8cdbca6e4d7f3d89 (patch)
treec80b1e13eab58b8f38f5266460aaf5bafbc048fd
parent1418b7a801ee19d8b45201c844c86366f988c5d4 (diff)
Fix client socket on delete event might not delete corresponding history record correctly
Diffstat (limited to '')
-rw-r--r--public/js/index.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 445a820b..5bddfbd0 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -57,6 +57,9 @@ var syncScrollToView = syncScroll.syncScrollToView;
var historyModule = require('./history');
var writeHistory = historyModule.writeHistory;
var deleteServerHistory = historyModule.deleteServerHistory;
+var getHistory = historyModule.getHistory;
+var saveHistory = historyModule.saveHistory;
+var removeHistory = historyModule.removeHistory;
var renderer = require('./render');
var preventXSS = renderer.preventXSS;
@@ -2292,9 +2295,17 @@ socket.on('error', function (data) {
location.href = serverurl + "/403";
});
socket.on('delete', function () {
- deleteServerHistory(noteid, function (err, data) {
- if (!err) location.href = serverurl;
- });
+ if (personalInfo.login) {
+ deleteServerHistory(noteid, function (err, data) {
+ if (!err) location.href = serverurl;
+ });
+ } else {
+ getHistory(function (notehistory) {
+ var newnotehistory = removeHistory(noteid, notehistory);
+ saveHistory(newnotehistory);
+ location.href = serverurl;
+ });
+ }
});
var retryOnDisconnect = false;
var retryTimer = null;