Moved repo to new location to prevent file issues, fixed a few loading issues. Seems QDN is causing issues when people are not able to obtain the newest version of the published data.

This commit is contained in:
crowetic 2024-12-27 11:49:07 -08:00
parent 2192f7c855
commit cd033bc756
5 changed files with 133 additions and 271 deletions

View File

View File

@ -310,6 +310,12 @@ const fetchAllEncryptedCards = async () => {
// Fetch poll results
const pollResults = await fetchPollResults(decryptedCardData.poll);
if (pollResults?.error) {
console.warn(`Skipping card with non-existent poll: ${card.identifier}, poll=${decryptedCardData.poll}`);
removeEncryptedSkeleton(card.identifier);
return;
}
// const minterNameFromIdentifier = await extractCardsMinterName(card.identifier);
const encryptedCommentCount = await getEncryptedCommentCount(card.identifier);
// Generate final card HTML
@ -712,45 +718,83 @@ const displayEncryptedComments = async (cardIdentifier) => {
};
const calculateAdminBoardPollResults = async (pollData, minterGroupMembers, minterAdmins) => {
const memberAddresses = minterGroupMembers.map(member => member.member)
const minterAdminAddresses = minterAdmins.map(member => member.member)
const adminGroupsMembers = await fetchAllAdminGroupsMembers()
const groupAdminAddresses = adminGroupsMembers.map(member => member.member)
// 1) Validate pollData structure
if (!pollData || !Array.isArray(pollData.voteWeights) || !Array.isArray(pollData.votes)) {
console.warn("Poll data is missing or invalid. pollData:", pollData);
return {
adminYes: 0,
adminNo: 0,
minterYes: 0,
minterNo: 0,
totalYes: 0,
totalNo: 0,
totalYesWeight: 0,
totalNoWeight: 0
};
}
// 2) Prepare admin & minter addresses
const memberAddresses = minterGroupMembers.map(member => member.member);
const minterAdminAddresses = minterAdmins.map(member => member.member);
const adminGroupsMembers = await fetchAllAdminGroupsMembers();
const groupAdminAddresses = adminGroupsMembers.map(member => member.member);
const adminAddresses = [];
adminAddresses.push(...minterAdminAddresses,...groupAdminAddresses);
adminAddresses.push(...minterAdminAddresses, ...groupAdminAddresses);
let adminYes = 0, adminNo = 0, minterYes = 0, minterNo = 0, yesWeight = 0 , noWeight = 0
let adminYes = 0, adminNo = 0;
let minterYes = 0, minterNo = 0;
let yesWeight = 0, noWeight = 0;
// 3) Process voteWeights
pollData.voteWeights.forEach(weightData => {
if (weightData.optionName === 'Yes') {
yesWeight = weightData.voteWeight
yesWeight = weightData.voteWeight;
} else if (weightData.optionName === 'No') {
noWeight = weightData.voteWeight
noWeight = weightData.voteWeight;
}
})
});
// 4) Process votes
for (const vote of pollData.votes) {
const voterAddress = await getAddressFromPublicKey(vote.voterPublicKey)
console.log(`voter address: ${voterAddress}`)
const voterAddress = await getAddressFromPublicKey(vote.voterPublicKey);
console.log(`voter address: ${voterAddress}, optionIndex: ${vote.optionIndex}`);
if (vote.optionIndex === 0) {
adminAddresses.includes(voterAddress) ? adminYes++ : memberAddresses.includes(voterAddress) ? minterYes++ : console.log(`voter ${voterAddress} is not a minter nor an admin...Not including results...`)
if (adminAddresses.includes(voterAddress)) {
adminYes++;
} else if (memberAddresses.includes(voterAddress)) {
minterYes++;
} else {
console.log(`voter ${voterAddress} is not a minter nor an admin... Not including results...`);
}
} else if (vote.optionIndex === 1) {
adminAddresses.includes(voterAddress) ? adminNo++ : memberAddresses.includes(voterAddress) ? minterNo++ : console.log(`voter ${voterAddress} is not a minter nor an admin...Not including results...`)
if (adminAddresses.includes(voterAddress)) {
adminNo++;
} else if (memberAddresses.includes(voterAddress)) {
minterNo++;
} else {
console.log(`voter ${voterAddress} is not a minter nor an admin... Not including results...`);
}
}
}
// TODO - create a new function to calculate the weights of each voting MINTER only.
// This will give ALL weight whether voter is in minter group or not...
// until that is changed on the core we must calculate manually.
const totalYesWeight = yesWeight
const totalNoWeight = noWeight
// 5) Summaries
const totalYesWeight = yesWeight;
const totalNoWeight = noWeight;
const totalYes = adminYes + minterYes;
const totalNo = adminNo + minterNo;
const totalYes = adminYes + minterYes
const totalNo = adminNo + minterNo
return { adminYes, adminNo, minterYes, minterNo, totalYes, totalNo, totalYesWeight, totalNoWeight }
}
return {
adminYes,
adminNo,
minterYes,
minterNo,
totalYes,
totalNo,
totalYesWeight,
totalNoWeight
};
};
const toggleEncryptedComments = async (cardIdentifier) => {
const commentsSection = document.getElementById(`comments-section-${cardIdentifier}`)

View File

@ -954,57 +954,70 @@ const buildMessageHTML = async (message, fetchMessages, room, isNewMessage) => {
}
const buildReplyHtml = async (message, room) => {
if (!message.replyTo) return ""
// 1) If no replyTo, skip
if (!message.replyTo) return "";
// 2) Decide which QDN service for this room
const replyService = (room === "admins") ? "MAIL_PRIVATE" : "BLOG_POST";
const replyIdentifier = message.replyTo
const replyIdentifier = message.replyTo;
const savedRepliedToMessage = messagesById[message.replyTo];
// 3) Check if we already have a *saved* message
const savedRepliedToMessage = messagesById[replyIdentifier];
console.log("savedRepliedToMessage", savedRepliedToMessage);
// 4) If we do, try to process/decrypt it
if (savedRepliedToMessage) {
const processedMessage = await processMessageObject(savedRepliedToMessage, room)
console.log('message is saved in saved message data, returning from that',savedRepliedToMessage)
return `
<div class="reply-message" style="border-left: 2px solid #ccc; margin-bottom: 0.5vh; padding-left: 1vh;">
<div class="reply-header">
In reply to: <span class="reply-username">${processedMessage.name}</span>
<span class="reply-timestamp">${processedMessage.date}</span>
</div>
<div class="reply-content">${processedMessage.content}</div>
</div>
`;
}
try {
const replyData = await searchSimple(replyService, replyIdentifier, "", 1)
if ((!replyData) || (!replyData.name)){
// No result found. You can either return an empty string or handle differently
console.log("No data found via searchSimple. Skipping reply rendering.");
return "";
}
const replyName = await replyData.name
const replyTimestamp = await replyData.updated || await replyData.created
console.log('message not found in saved message data, using searchSimple', replyData)
// const repliedMessage = fetchMessages.find(m => m && m.identifier === message.replyTo)
// const repliedMessageIdentifier = message.replyTo
const repliedMessage = await fetchReplyData(replyService, replyName, replyIdentifier, room, replyTimestamp)
storeMessageInMap(repliedMessage)
if (!repliedMessage) return ""
if (savedRepliedToMessage) {
// We successfully processed the cached message
console.log("Using saved message data for reply:", savedRepliedToMessage);
return `
<div class="reply-message" style="border-left: 2px solid #ccc; margin-bottom: 0.5vh; padding-left: 1vh;">
<div class="reply-header">
In reply to: <span class="reply-username">${repliedMessage.name}</span> <span class="reply-timestamp">${repliedMessage.date}</span>
In reply to: <span class="reply-username">${savedRepliedToMessage.name}</span>
<span class="reply-timestamp">${savedRepliedToMessage.date}</span>
</div>
<div class="reply-content">${repliedMessage.content}</div>
<div class="reply-content">${savedRepliedToMessage.content}</div>
</div>
`
} catch (error) {
throw (error)
`;
} else {
// The cached message is invalid
console.log("Saved message found but processMessageObject returned null. Falling back...");
}
}
}
// 5) Fallback approach: If we don't have it in memory OR the cached version was invalid
try {
const replyData = await searchSimple(replyService, replyIdentifier, "", 1);
if (!replyData || !replyData.name) {
console.log("No data found via searchSimple. Skipping reply rendering.");
return "";
}
// We'll use replyData to fetch the actual message from QDN
const replyName = replyData.name;
const replyTimestamp = replyData.updated || replyData.created;
console.log("message not found in workable form, using searchSimple result =>", replyData);
// This fetches and decrypts the actual message
const repliedMessage = await fetchReplyData(replyService, replyName, replyIdentifier, room, replyTimestamp);
if (!repliedMessage) return "";
// Now store the final message in the map for next time
storeMessageInMap(repliedMessage);
// Return final HTML
return `
<div class="reply-message" style="border-left: 2px solid #ccc; margin-bottom: 0.5vh; padding-left: 1vh;">
<div class="reply-header">
In reply to: <span class="reply-username">${repliedMessage.name}</span> <span class="reply-timestamp">${repliedMessage.date}</span>
</div>
<div class="reply-content">${repliedMessage.content}</div>
</div>
`;
} catch (error) {
throw error;
}
};
const buildAttachmentHtml = async (message, room) => {
if (!message.attachments || message.attachments.length === 0) {

View File

@ -1,195 +0,0 @@
/* forum-styles.css */
.forum-main {
color: #ffffff;
background-color: #000000;
padding: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: 100vw;
box-sizing: border-box;
background-size: cover;
background-position: center;
}
.forum-header {
width: 100%;
padding: 2vh;
background-color: #000000;
color: #add8e6; /* Light blue color */
text-align: center;
font-size: 2.5rem;
font-weight: bold;
margin-bottom: 0;
}
.forum-submenu {
width: 100%;
padding: 1vh 2vh;
background: rgba(0, 0, 0, 0.8);
text-align: center;
margin-top: 0;
}
.forum-rooms {
display: flex;
justify-content: center;
gap: 2vh; /* Increased gap for better spacing */
margin-top: 0;
flex-wrap: wrap;
}
.room-button {
background-color: #317e78;
color: #ffffff;
border: 2px solid #317e78;
border-radius: 2vh;
padding: 1vh 2vh;
font-size: 1.1rem;
cursor: pointer;
}
.room-button:hover {
background-color: #19403d;
}
.forum-content {
flex-grow: 1;
width: 90%;
padding: 3vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
border: 3px solid #ffffff; /* Increased border width */
}
.room-content {
background: rgba(0, 0, 0, 0.6);
padding: 2vh;
border-radius: 1vh;
width: 100%;
box-sizing: border-box;
text-align: center;
}
.room-title {
color: #add8e6; /* Light blue color for room name */
text-align: center;
margin-bottom: 2vh;
font-size: 2rem;
}
.message-item {
background: #1c1c1c;
color: #ffffff;
padding: 1vh;
margin-bottom: 1vh;
border-radius: 0.8vh;
width: 100%;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: flex-start;
border: 1px solid #ffffff;
}
.message-header {
display: flex;
justify-content: space-between;
width: 100%;
margin-bottom: 1vh;
font-size: 1.25rem;
color: white
}
.message-header.username {
color: #228ec0;
}
.username {
font-weight: bold;
color:#228ec0
}
.timestamp {
font-style: italic;
color: rgb(157, 167, 151)
}
.message-text {
margin: 0;
font-size: 1.25rem;
}
.reply-button {
align-self: flex-end;
margin-top: 1vh;
background-color: #167089;
color: #ffffff;
border: none;
border-radius: 1vh;
padding: 0.3vh 0.6vh;
cursor: pointer;
}
.reply-button:hover {
background-color: #19403d;
}
/* forum-styles.css additions */
.message-input-section {
display: flex;
flex-direction: column;
align-items: stretch;
box-sizing: border-box;
width: 100%;
gap: 1vh; /* Spacing between toolbar and editor */
background-color: black;
padding: 1vh;
}
.ql-editor {
flex-grow: 1;
text-size: 1.25rem;
}
.message-input {
flex-grow: 1;
padding: 2vh;
border-radius: 1vh;
border: 1px solid #cccccc;
font-size: 1.25rem;
/* margin-right: 8vh; */
box-sizing: border-box;
min-height: 15vh;
}
.send-button {
background-color: #13a97c;
color: #ffffff;
border: none;
border-radius: 1vh;
padding: 2vh 4vh;
cursor: pointer;
}
.send-button:hover {
background-color: #19403d;
}
.messages-container {
width: 100%;
margin-bottom: 5vh; /* Ensure space above input section */
overflow-y: auto;
padding-bottom: 1vh;
box-sizing: border-box;
}

View File

@ -29,12 +29,12 @@
<link rel="stylesheet" href="assets/css/forum-styles.css">
<link rel="preload" href="assets/css/css.css?family=DM+Sans:100,200,300,400,500,600,700,800,900,100i,200i,300i,400i,500i,600i,700i,800i,900i&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="assets/css/css.css?family=DM+Sans:100,200,300,400,500,600,700,800,900,100i,200i,300i,400i,500i,600i,700i,800i,900i&display=swap"></noscript>
<link rel="preload" href="assets/css/space-grotesk.css?family=Space+Grotesk:300,400,500,600,700&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="assets/css/space-grotesk.css?family=Space+Grotesk:300,400,500,600,700&display=swap"></noscript>
<link href="assets/quill/quill.snow.css" rel="stylesheet">
<link rel="stylesheet" href="./assets/css/forum-styles.css">
<link rel="preload" href="./assets/css/css.css?family=DM+Sans:100,200,300,400,500,600,700,800,900,100i,200i,300i,400i,500i,600i,700i,800i,900i&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="./assets/css/css.css?family=DM+Sans:100,200,300,400,500,600,700,800,900,100i,200i,300i,400i,500i,600i,700i,800i,900i&display=swap"></noscript>
<link rel="preload" href="./assets/css/space-grotesk.css?family=Space+Grotesk:300,400,500,600,700&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="./assets/css/space-grotesk.css?family=Space+Grotesk:300,400,500,600,700&display=swap"></noscript>
<link href="./assets/quill/quill.snow.css" rel="stylesheet">
</head>
<body>
@ -329,12 +329,12 @@
</section>
<script src="assets/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/parallax/jarallax.js"></script>
<script src="assets/smoothscroll/smooth-scroll.js"></script>
<script src="assets/ytplayer/index.js"></script>
<script src="assets/dropdown/js/navbar-dropdown.js"></script>
<script src="assets/theme/js/script.js"></script>
<script src="./assets/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="./assets/parallax/jarallax.js"></script>
<script src="./assets/smoothscroll/smooth-scroll.js"></script>
<script src="./assets/ytplayer/index.js"></script>
<script src="./assets/dropdown/js/navbar-dropdown.js"></script>
<script src="./assets/theme/js/script.js"></script>
<script src="./assets/quill/quill.min.js"></script>
<script src="./assets/js/QortalApi.js"></script>