From d576fdc88621cc6be122bc5aff496aedd4826ffe Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Apr 2016 19:03:22 +0200 Subject: [PATCH] fix bug where empty channels failed --- storage/lvl.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/lvl.js b/storage/lvl.js index 0f3954968..ff6713a0c 100644 --- a/storage/lvl.js +++ b/storage/lvl.js @@ -41,7 +41,9 @@ var insert = function (db, channelName, content, cb) { var getMessages = function (db, channelName, msgHandler, cb) { var index; nThen(function (waitFor) { - getIndex(db, channelName, waitFor(function (i) { index = i; })); + getIndex(db, channelName, waitFor(function (i) { + index = i; + })); }).nThen(function (waitFor) { var again = function (i) { db.get(channelName + '=>' + i, waitFor(function (e, out) { @@ -52,6 +54,7 @@ var getMessages = function (db, channelName, msgHandler, cb) { })); }; if (index > -1) { again(0); } + else if (cb) { cb(); } }); };