load user pins in the database worker
This commit is contained in:
@@ -156,7 +156,6 @@ var getMultipleFileSize = function (Env, channels, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
const batchUserPins = BatchRead("LOAD_USER_PINS");
|
||||
var loadUserPins = function (Env, safeKey, cb) {
|
||||
var session = Core.getSession(Env.Sessions, safeKey);
|
||||
|
||||
@@ -164,23 +163,14 @@ var loadUserPins = function (Env, safeKey, cb) {
|
||||
return cb(session.channels);
|
||||
}
|
||||
|
||||
batchUserPins(safeKey, cb, function (done) {
|
||||
var ref = {};
|
||||
var lineHandler = Pins.createLineHandler(ref, function (label, data) {
|
||||
Env.Log.error(label, {
|
||||
log: safeKey,
|
||||
data: data,
|
||||
});
|
||||
});
|
||||
|
||||
// if channels aren't in memory. load them from disk
|
||||
// TODO replace with readMessagesBin
|
||||
Env.pinStore.getMessages(safeKey, lineHandler, function () {
|
||||
// no more messages
|
||||
|
||||
// only put this into the cache if it completes
|
||||
session.channels = ref.pins;
|
||||
done(ref.pins); // FIXME no error handling?
|
||||
Env.batchUserPins(safeKey, cb, function (done) {
|
||||
Env.getPinState(safeKey, function (err, value) {
|
||||
if (!err) {
|
||||
// only put this into the cache if it completes
|
||||
session.channels = value;
|
||||
}
|
||||
session.channels = value;
|
||||
done(value);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user