mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-27 16:00:04 +08:00
fixing deadLock on Browser Close
This commit is contained in:
+11
-3
@@ -54,6 +54,13 @@ module.exports = {
|
||||
getAndSendRevHistory(subRootId, socket);
|
||||
});
|
||||
|
||||
socket.on('disconnect', function(){
|
||||
console.log("DISCONNECT", socket.CUR_ID);
|
||||
if(!(socket.CUR_ID == undefined)){
|
||||
io.sockets.emit("blurred", [socket.CUR_ID, null]);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
@@ -82,13 +89,13 @@ function attachLogInListeners(socket){
|
||||
});
|
||||
|
||||
//Used when a node is split...
|
||||
//Maybe set CurID
|
||||
socket.on("edit", function(data){
|
||||
var id = data[0];
|
||||
var newText = data[1];
|
||||
console.log("\n\n\n\n edit received:" + newText);
|
||||
Node.updateText(id, newText);
|
||||
socket.broadcast.emit("edit", [id, newText]);
|
||||
|
||||
socket.broadcast.emit("edit", [id, newText]);
|
||||
});
|
||||
|
||||
//This works for all ids except negative ids.
|
||||
@@ -96,11 +103,12 @@ function attachLogInListeners(socket){
|
||||
console.log("EDITING received!");
|
||||
console.log(data);
|
||||
socket.broadcast.emit("editing", data);
|
||||
socket.CUR_ID = data[0];
|
||||
});
|
||||
|
||||
|
||||
socket.on("blurred", function(data){
|
||||
console.log("BLURRED");
|
||||
console.log("BLURRED , CUR_ID", socket.CUR_ID);
|
||||
socket.broadcast.emit("blurred", data);
|
||||
|
||||
var id = data[0];
|
||||
|
||||
@@ -226,12 +226,19 @@ socket.on("editing", function(data){
|
||||
|
||||
socket.on("blurred", function(data){
|
||||
var id = data[0];
|
||||
var text = data[1];
|
||||
var author = data[2];
|
||||
|
||||
var tempModel = nodesCollection.findWhere({_id: id});
|
||||
tempModel.set("text", text);
|
||||
tempModel.set("author", author);
|
||||
// alert("blurred");
|
||||
console.log("blurred");
|
||||
console.log(data);
|
||||
if(data[1] != null){
|
||||
var text = data[1];
|
||||
var author = data[2];
|
||||
|
||||
|
||||
tempModel.set("text", text);
|
||||
tempModel.set("author", author);
|
||||
}
|
||||
|
||||
var tempViews = tempModel.get("views");
|
||||
_.each(tempViews, function(tempView){
|
||||
tempView.unlock();
|
||||
|
||||
@@ -63,4 +63,28 @@ $(function(){
|
||||
alert("Transclusion syncing with the server has not been implemented. KnownBugs:\n0.Don't make infinite loops.\n1.");
|
||||
transclude();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
// window.addEventListener("unload", function (e) {
|
||||
// var confirmationMessage = "\o/";
|
||||
// //socket.emitWrapper("blurred", [vo.thisLI, vo.thisModel.get("text"), CurrentUser]);
|
||||
// (e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
||||
// return confirmationMessage; //Webkit, Safari, Chrome etc.
|
||||
// });
|
||||
|
||||
// $(window).on("beforeunload", function(){
|
||||
// socket.emitWrapper("blurred", [vo.thisLI, vo.thisModel.get("text"), CurrentUser]);
|
||||
// return "areYouSure?"
|
||||
// });
|
||||
|
||||
// $(window).beforeunload(function(){
|
||||
// return "are you sure?"
|
||||
// });
|
||||
|
||||
// window.onbeforeunload = exitHandler;
|
||||
// function exitHandler(){
|
||||
// alert(vo);
|
||||
// socket.emitWrapper("blurred", vo.thisLI, vo.thisModel.get("text"), CurrentUser);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user