Prettified Code!

pull/360/head
Mashintime 2023-02-25 05:29:09 +00:00 committed by GitHub Action
parent bfb2543c05
commit b644b36fe4
1 changed files with 31 additions and 24 deletions

View File

@ -762,7 +762,10 @@ update_chat = function (obj) {
// increment callsign counter // increment callsign counter
callsign_counter++; callsign_counter++;
dxcallsigns.add(dxcallsign); dxcallsigns.add(dxcallsign);
if ((callsign_counter == 1 && selected_callsign=="") || selected_callsign == dxcallsign ) { if (
(callsign_counter == 1 && selected_callsign == "") ||
selected_callsign == dxcallsign
) {
var callsign_selected = "active show"; var callsign_selected = "active show";
//document.getElementById('chatModuleDxCall').value = dxcallsign; //document.getElementById('chatModuleDxCall').value = dxcallsign;
selected_callsign = dxcallsign; selected_callsign = dxcallsign;
@ -1497,24 +1500,26 @@ async function updateAllChat(clear) {
} }
//Ensure we create an index before running db.find //Ensure we create an index before running db.find
//We can't rely on the default index existing before we get here...... :'( //We can't rely on the default index existing before we get here...... :'(
await db.createIndex({ await db
index: { .createIndex({
fields: [{ timestamp: "asc" }], index: {
}, fields: [{ timestamp: "asc" }],
}) },
})
.then(async function (result) { .then(async function (result) {
// handle result // handle result
await db.find({ await db
selector: { .find({
$and: [{ timestamp: { $exists: true } }, { $or: chatFilter }], selector: {
//$or: chatFilter $and: [{ timestamp: { $exists: true } }, { $or: chatFilter }],
}, //$or: chatFilter
sort: [
{
timestamp: "asc",
}, },
], sort: [
}) {
timestamp: "asc",
},
],
})
.then(async function (result) { .then(async function (result) {
// handle result async // handle result async
if (typeof result !== "undefined") { if (typeof result !== "undefined") {
@ -1537,12 +1542,14 @@ async function updateAllChat(clear) {
.catch(function (err) { .catch(function (err) {
console.log(err); console.log(err);
}); });
if (clear == true && dxcallsigns.has(selected_callsign) == false) { if (clear == true && dxcallsigns.has(selected_callsign) == false) {
//Selected call sign is not visible, reset to first call sign //Selected call sign is not visible, reset to first call sign
let tmp = dxcallsigns.entries().next().value[0]; let tmp = dxcallsigns.entries().next().value[0];
selected_callsign=tmp; selected_callsign = tmp;
document.getElementById("chat-" + tmp + "-list").classList.add("active","show"); document
document.getElementById("chat-" + tmp ).classList.add("active","show"); .getElementById("chat-" + tmp + "-list")
scrollMessagesToBottom(); .classList.add("active", "show");
} document.getElementById("chat-" + tmp).classList.add("active", "show");
scrollMessagesToBottom();
}
} }