mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Re-arrange updateallchat() logic re: beacon_list
This commit is contained in:
parent
d96c6a818e
commit
a0886e1937
1 changed files with 14 additions and 12 deletions
|
@ -340,16 +340,7 @@ export async function updateAllChat() {
|
||||||
})
|
})
|
||||||
.then(async function (result) {
|
.then(async function (result) {
|
||||||
for (var item of result.docs) {
|
for (var item of result.docs) {
|
||||||
if (item.type === "beacon") {
|
|
||||||
//console.log(item);
|
|
||||||
|
|
||||||
// TODO: sort beacon list .... maybe a part for a separate function
|
|
||||||
const jsonData = [item];
|
|
||||||
const dxcallsign = item.dxcallsign;
|
const dxcallsign = item.dxcallsign;
|
||||||
// Process each JSON item step by step
|
|
||||||
jsonData.forEach((jsonitem) => {
|
|
||||||
const { snr, timestamp } = item;
|
|
||||||
|
|
||||||
// Check if dxcallsign already exists as a property in the result object
|
// Check if dxcallsign already exists as a property in the result object
|
||||||
if (!chat.sorted_beacon_list[dxcallsign]) {
|
if (!chat.sorted_beacon_list[dxcallsign]) {
|
||||||
// If not, initialize it with an empty array for snr values
|
// If not, initialize it with an empty array for snr values
|
||||||
|
@ -358,14 +349,25 @@ export async function updateAllChat() {
|
||||||
snr: [],
|
snr: [],
|
||||||
timestamp: [],
|
timestamp: [],
|
||||||
};
|
};
|
||||||
|
chat.callsign_list.add(dxcallsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.type === "beacon") {
|
||||||
|
//console.log(item);
|
||||||
|
|
||||||
|
// TODO: sort beacon list .... maybe a part for a separate function
|
||||||
|
const jsonData = [item];
|
||||||
|
|
||||||
|
// Process each JSON item step by step
|
||||||
|
jsonData.forEach((jsonitem) => {
|
||||||
|
const { snr, timestamp } = item;
|
||||||
|
|
||||||
// Push the snr value to the corresponding dxcallsign's snr array
|
// Push the snr value to the corresponding dxcallsign's snr array
|
||||||
chat.sorted_beacon_list[dxcallsign].snr.push(snr);
|
chat.sorted_beacon_list[dxcallsign].snr.push(snr);
|
||||||
chat.sorted_beacon_list[dxcallsign].timestamp.push(timestamp);
|
chat.sorted_beacon_list[dxcallsign].timestamp.push(timestamp);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
chat.callsign_list.add(item.dxcallsign);
|
|
||||||
chat.unsorted_chat_list.push(item);
|
chat.unsorted_chat_list.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue