mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-28 16:10:05 +08:00
DONE.Release0.0. MISC small things. Fixed ClientRevBug
This commit is contained in:
+17
-11
@@ -1,15 +1,20 @@
|
||||
var _ = require('underscore');
|
||||
var MySnap = require('../models/Snap.js').MySnap
|
||||
var MySnap = require('../models/Snap.js').MySnap;
|
||||
var User = require('../models/User.js');
|
||||
module.exports.getAndSendRevHistory = getAndSendRevHistory;
|
||||
|
||||
|
||||
function getAndSendRevHistory(subRootId, sock){
|
||||
globalList = [];
|
||||
snapHash = {};
|
||||
timeHash = {};
|
||||
timeHash = {};
|
||||
depth = 0;
|
||||
socket = sock;
|
||||
|
||||
User.find({}, '_id google.name' , function(err, users){
|
||||
socket.emit("UserList", users);
|
||||
});
|
||||
|
||||
// subRootId = "53f10817cb52c1e31cf45d94";
|
||||
// FetchSelfAndChildrenBack(rootId, asyncLoopGetChildren);
|
||||
asyncLoopGetChildren([subRootId]);
|
||||
@@ -22,7 +27,7 @@ function updateGlobals(rootSnaps){
|
||||
//snapHash[rootId] = rootSnaps; //should be equivalent.
|
||||
|
||||
_.each(rootSnaps, function(snap){
|
||||
(timeHash[snap.timestamp] = timeHash[snap.timestamp] || []).push(snap);
|
||||
(timeHash[snap.timestamp] = timeHash[snap.timestamp] || []).push(snap);
|
||||
});
|
||||
|
||||
globalList.push(rootId);
|
||||
@@ -30,7 +35,8 @@ function updateGlobals(rootSnaps){
|
||||
|
||||
//This should only be called once per ID.
|
||||
function FetchSelfAndChildrenBack(rootId, callback){
|
||||
MySnap.find({cur_id: rootId}).populate('authorId','_id google.name' ).sort({timestamp: 1}).
|
||||
/*populate('authorId','_id google.name' ).*/
|
||||
MySnap.find({cur_id: rootId}).sort({timestamp: 1}).
|
||||
exec(function(err, rootSnaps){
|
||||
if(err){console.log("ERROR HERE")}
|
||||
|
||||
@@ -82,13 +88,13 @@ function asyncLoopGetChildren(d1Union){
|
||||
|
||||
|
||||
if(typeof d1Union == 'undefined' || d1Union.length == 0){//bottomed out recursion = end of bfs
|
||||
console.log("finished!!!!")
|
||||
console.log("snapHash");
|
||||
console.log(snapHash);
|
||||
console.log("timeHash");
|
||||
console.log(timeHash);
|
||||
console.log("globalList");
|
||||
console.log(globalList);
|
||||
// console.log("finished!!!!")
|
||||
// console.log("snapHash");
|
||||
// console.log(snapHash);
|
||||
// console.log("timeHash");
|
||||
// console.log(timeHash);
|
||||
// console.log("globalList");
|
||||
// console.log(globalList);
|
||||
|
||||
socket.emit("revHistory", [snapHash, timeHash]);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user