mirror of
https://github.com/RetroShare/RSNewWebUI.git
synced 2026-09-13 18:45:49 +05:00
30 lines
778 B
JavaScript
30 lines
778 B
JavaScript
const m = require('mithril');
|
|
const rs = require('rswebui');
|
|
const futil = require('files/files_util');
|
|
|
|
const fileProxyObj = futil.createProxy({}, () => {
|
|
m.redraw();
|
|
});
|
|
|
|
rs.events[rs.RsEventsType.FILE_TRANSFER] = {
|
|
handler: (event) => {
|
|
// if request item doesn't already exists in Object then create new item
|
|
if (!Object.prototype.hasOwnProperty.call(fileProxyObj, event.mRequestId)) {
|
|
fileProxyObj[event.mRequestId] = [];
|
|
}
|
|
|
|
event.mResults.forEach((newRes) => {
|
|
const isAlt = fileProxyObj[event.mRequestId].some(
|
|
(oldRes) => oldRes.fHash === newRes.fHash && oldRes.fName === newRes.fName
|
|
);
|
|
if (!isAlt) {
|
|
fileProxyObj[event.mRequestId].push(newRes);
|
|
}
|
|
});
|
|
},
|
|
};
|
|
|
|
module.exports = {
|
|
fileProxyObj,
|
|
};
|