diff --git a/rpc.js b/rpc.js index 54faf0f2c..62a8690a2 100644 --- a/rpc.js +++ b/rpc.js @@ -762,7 +762,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, ()=>{}); });