holy fuck javascript sucks

This commit is contained in:
Jeremy Kauffman 2017-01-12 23:05:43 -05:00 committed by Alex Liebowitz
parent 167541b92c
commit 4fd9828760

View file

@ -480,17 +480,21 @@ lbry._updateSubscribedFileInfoByName = function(name) {
}
fileInfo.isMine = !!this._claimIdOwnershipCache[fileInfo.claim_id];
}
this._fileInfoSubscribeCallbacks[name].forEach(function(callback) {
callback(fileInfo);
Object.keys(this._fileInfoSubscribeCallbacks[name]).forEach(function(subscribeId) {
lbry._fileInfoSubscribeCallbacks[name][subscribeId](fileInfo);
});
});
setTimeout(() => { this._updateSubscribedFileInfoByName(name) }, lbry._fileInfoSubscribeInterval);
if (Object.keys(this._fileInfoSubscribeCallbacks[name]).length) {
setTimeout(() => {
this._updateSubscribedFileInfoByName(name)
}, lbry._fileInfoSubscribeInterval);
}
}
lbry.fileInfoSubscribeByName = function(name, callback) {
if (!lbry._fileInfoSubscribeCallbacks[name])
{
lbry._fileInfoSubscribeCallbacks[name] = [];
lbry._fileInfoSubscribeCallbacks[name] = {};
}
const subscribeId = ++lbry._fileInfoSubscribeIdCounter;
@ -506,7 +510,7 @@ lbry.fileInfoSubscribeByName = function(name, callback) {
// }
lbry.fileInfoUnsubscribe = function(name, subscribeId) {
lbry._fileInfoSubscribeCallbacks[name] = lbry._fileInfoSubscribeCallbacks[name].splice(subscribeId, 1);
delete lbry._fileInfoSubscribeCallbacks[name][subscribeId];
}
export default lbry;
export default lbry;