guard against a typeError

This commit is contained in:
ansuz 2019-09-12 18:06:54 +02:00
parent e3864677e2
commit 8084343705
1 changed files with 6 additions and 1 deletions

7
rpc.js
View File

@ -823,7 +823,12 @@ var resetUserPins = function (Env, publicKey, channelList, cb) {
pins[channel] = true;
});
var oldChannels = Object.keys(session.channels);
var oldChannels;
if (session.channels && typeof(session.channels) === 'object') {
oldChannels = Object.keys(session.channels);
} else {
oldChannels = [];
}
removePinned(Env, publicKey, oldChannels, () => {
addPinned(Env, publicKey, channelList, ()=>{});
});