2026-03-05 00:04:26 -06:00
|
|
|
export function debounce(fn, delayMs) {
|
|
|
|
|
let t;
|
|
|
|
|
return (...args) => {
|
|
|
|
|
clearTimeout(t);
|
|
|
|
|
t = setTimeout(() => fn(...args), delayMs);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function digestData(data, { page, pageSize, searchTerm, sort }) {
|
|
|
|
|
const items =
|
|
|
|
|
data.items?.map((c) => ({
|
|
|
|
|
id: c.id,
|
|
|
|
|
online: !!c.online,
|
|
|
|
|
lastSeen: c.lastSeen,
|
|
|
|
|
ping: c.pingMs,
|
|
|
|
|
host: c.host,
|
|
|
|
|
user: c.user,
|
2026-03-13 23:46:42 -05:00
|
|
|
customTag: c.customTag,
|
|
|
|
|
customTagNote: c.customTagNote,
|
2026-03-05 00:04:26 -06:00
|
|
|
version: c.version,
|
|
|
|
|
country: c.country,
|
|
|
|
|
arch: c.arch,
|
|
|
|
|
os: c.os,
|
|
|
|
|
monitors: c.monitors,
|
2026-04-08 20:59:46 -05:00
|
|
|
elevation: c.elevation,
|
2026-05-30 22:44:55 -05:00
|
|
|
bookmarked: !!c.bookmarked,
|
|
|
|
|
isAdmin: !!c.isAdmin,
|
|
|
|
|
hwid: c.hwid,
|
|
|
|
|
cpu: c.cpu,
|
|
|
|
|
gpu: c.gpu,
|
|
|
|
|
ram: c.ram,
|
|
|
|
|
batteryPercent: c.batteryPercent,
|
|
|
|
|
batteryCharging: c.batteryCharging,
|
|
|
|
|
groupId: c.groupId,
|
|
|
|
|
groupName: c.groupName,
|
|
|
|
|
groupColor: c.groupColor,
|
|
|
|
|
notificationsMuted: !!c.notificationsMuted,
|
|
|
|
|
hasThumbnail: !!c.hasThumbnail,
|
|
|
|
|
thumbnailVersion: c.thumbnailVersion,
|
2026-03-05 00:04:26 -06:00
|
|
|
})) || [];
|
|
|
|
|
return JSON.stringify({
|
|
|
|
|
page,
|
|
|
|
|
pageSize,
|
|
|
|
|
searchTerm,
|
|
|
|
|
sort,
|
|
|
|
|
total: data.total,
|
|
|
|
|
online: data.online,
|
|
|
|
|
items,
|
|
|
|
|
});
|
|
|
|
|
}
|