RSNewWebUI/webui-src/app/network/network_data.js
jolavillette d5fb6a532b lint: apply eslint --fix to the new code
master gained an eslint config in 35c5c17 and the code added here predates
it, so `npm run lint` fails on this branch. This commit is the mechanical
part only, produced by `eslint app --fix` with no hand editing:
object-shorthand, quote style, trailing whitespace, prefer-const.

Twenty-two problems are left because they need a decision rather than a
rewrite rule, the two worth looking at first being real:

  boards/board_view.js:499,503  'forumId' is not defined  (no-undef)

`renderComment` calls `util.voteForPost(forumId, ...)` for the up and down
vote buttons, but no `forumId` exists in that scope - it looks like it came
over from the forums code. Voting on a board comment therefore throws
ReferenceError and silently does nothing.

The other twenty are unused bindings left behind by the refactors
(`get64Num`, `loadLobbyDetails`, `Message`, `SubscribedLobbies`,
`PublicLobbies`, `LayoutSingle` in chat.js, `closePopup` in
board_kanban.js, `bsubscribed`/`bposts`/`createDate`/`lastActivity` in
boards_util.js, `displaycomment` in channel_view.js) plus a few dead
assignments. `npm run lint` lists them all.

Drop this commit if you would rather keep the diff to your own changes.
2026-08-08 17:10:58 +02:00

91 lines
2.6 KiB
JavaScript

const rs = require('rswebui');
async function refreshIds() {
let sslIds = [];
await rs.rsJsonApiRequest('/rsPeers/getFriendList', {}, (data) => (sslIds = data.sslIds));
return sslIds;
}
async function loadSslDetails() {
const sslDetails = [];
const sslIds = await refreshIds();
await Promise.all(
sslIds.map((sslId) =>
rs.rsJsonApiRequest('/rsPeers/getPeerDetails', { sslId }, (data) => sslDetails.push(data.det))
)
);
return sslDetails;
}
const Data = {
gpgDetails: {},
};
Data.refreshGpgDetails = async function () {
const details = {};
const sslDetails = await loadSslDetails();
await Promise.all(
sslDetails.map((data) => {
let isOnline = false;
return rs
.rsJsonApiRequest(
'/rsPeers/isOnline',
{ sslId: data.id },
(stat) => (isOnline = stat.retval)
)
.then(() => {
let customState = '';
return rs
.rsJsonApiRequest(
'/rsChats/getCustomStateString',
{ peer_id: data.id },
(statusData) => {
if (statusData && statusData.retval) {
customState = statusData.retval;
}
}
)
.catch(() => {})
.then(() => {
const avatar = '';
return Promise.resolve()
.then(() => {
const gpgId = (data.gpg_id || '').toLowerCase();
const loc = {
name: data.location,
id: data.id,
lastSeen: data.lastConnect,
isOnline,
gpg_id: gpgId,
customState,
avatar,
};
if (details[gpgId] === undefined) {
details[gpgId] = {
name: data.name,
isSearched: true,
isOnline,
locations: [loc],
customState,
avatar: avatar || '',
};
} else {
details[gpgId].locations.push(loc);
if (avatar) {
details[gpgId].avatar = avatar;
}
if (!details[gpgId].customState || (isOnline && customState)) {
details[gpgId].customState = customState;
}
}
details[gpgId].isOnline = details[gpgId].isOnline || isOnline;
});
});
});
})
);
Data.gpgDetails = details;
};
module.exports = Data;