add card deletion to all boards
This commit is contained in:
parent
4e58f04e4e
commit
6dcac08953
@ -726,6 +726,47 @@ const handleRemoveMinterGroupAdmin = async (name, address) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ADDED: A simple function to effectively 'delete' an AR Board card
|
||||
// by publishing an empty card with the same identifier and prefix
|
||||
const deleteARCard = async (cardIdentifier, prefix) => {
|
||||
try {
|
||||
const confirmed = confirm("Are you sure you want to delete this card? This action cannot be undone.")
|
||||
if (!confirmed) return
|
||||
|
||||
// A minimal blank object
|
||||
const blankData = {
|
||||
header: "",
|
||||
content: "",
|
||||
links: [],
|
||||
creator: userState.accountName,
|
||||
timestamp: Date.now(),
|
||||
poll: "" // or null. This ensures it won't appear as a valid poll card
|
||||
}
|
||||
|
||||
let base64Data = await objectToBase64(blankData)
|
||||
if (!base64Data) {
|
||||
base64Data = btoa(JSON.stringify(blankData))
|
||||
}
|
||||
|
||||
await qortalRequest({
|
||||
action: "PUBLISH_QDN_RESOURCE",
|
||||
name: userState.accountName,
|
||||
service: "BLOG_POST", // same as all ARBoard content
|
||||
identifier: cardIdentifier,
|
||||
data64: base64Data,
|
||||
})
|
||||
|
||||
alert("Your card has been effectively deleted.")
|
||||
|
||||
// Now reload the existing ARBoard cards so the UI no longer shows the old card
|
||||
await loadCards(prefix)
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error deleting AR card:", error)
|
||||
alert("Failed to delete the card. Check console for details.")
|
||||
}
|
||||
}
|
||||
|
||||
const fallbackMinterCheck = async (minterName, minterGroupMembers, minterAdmins) => {
|
||||
// Ensure we have addresses
|
||||
if (!minterGroupMembers) {
|
||||
@ -924,6 +965,16 @@ const createARCardHTML = async (cardData, pollResults, cardIdentifier, commentCo
|
||||
<button class="no" onclick="voteNoOnPoll('${poll}')">NO</button>
|
||||
</div>
|
||||
</div>
|
||||
${creator === userState.accountName ? `
|
||||
<div style="margin-top: 0.8em;">
|
||||
<button
|
||||
style="padding: 10px; background: darkred; color: white; border-radius: 4px; cursor: pointer;"
|
||||
onclick="deleteARCard('${cardIdentifier}', '${addRemoveIdentifierPrefix}')"
|
||||
>
|
||||
DELETE CARD
|
||||
</button>
|
||||
</div>
|
||||
` : ''}
|
||||
<div id="comments-section-${cardIdentifier}" class="comments-section" style="display: none; margin-top: 20px;">
|
||||
<div id="comments-container-${cardIdentifier}" class="comments-container"></div>
|
||||
<textarea id="new-comment-${cardIdentifier}" placeholder="Input your comment..." style="width: 100%; margin-top: 10px;"></textarea>
|
||||
|
@ -1258,6 +1258,51 @@ const getNewestAdminCommentTimestamp = async (cardIdentifier) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ADDED: A simple function to effectively 'delete' an Admin Board card
|
||||
// by publishing an empty card with the same identifier and prefix
|
||||
const deleteAdminCard = async (cardIdentifier) => {
|
||||
try {
|
||||
const confirmed = confirm("Are you sure you want to delete this card? This action cannot be undone.")
|
||||
if (!confirmed) return
|
||||
|
||||
// A minimal blank object
|
||||
const blankData = {
|
||||
header: "",
|
||||
content: "",
|
||||
links: [],
|
||||
creator: userState.accountName,
|
||||
timestamp: Date.now(),
|
||||
poll: "" // or null. This ensures it won't appear as a valid poll card
|
||||
}
|
||||
|
||||
let base64Data = await objectToBase64(blankData)
|
||||
if (!base64Data) {
|
||||
base64Data = btoa(JSON.stringify(blankData))
|
||||
}
|
||||
|
||||
const verifiedAdminPublicKeys = await fetchAdminGroupsMembersPublicKeys()
|
||||
|
||||
await qortalRequest({
|
||||
action: "PUBLISH_QDN_RESOURCE",
|
||||
name: userState.accountName,
|
||||
service: "MAIL_PRIVATE",
|
||||
identifier: cardIdentifier,
|
||||
data64: base64Data,
|
||||
encrypt: true,
|
||||
publicKeys: verifiedAdminPublicKeys
|
||||
})
|
||||
|
||||
alert("Your card has been effectively deleted.")
|
||||
|
||||
// Now reload the existing Admin Board cards so the UI no longer shows the old card
|
||||
await fetchAllEncryptedCards(true)
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error deleting Admin card:", error)
|
||||
alert("Failed to delete the card. Check console for details.")
|
||||
}
|
||||
}
|
||||
|
||||
// Create the overall Minter Card HTML -----------------------------------------------
|
||||
const createEncryptedCardHTML = async (cardData, pollResults, cardIdentifier, commentCount) => {
|
||||
const { minterName, header, content, links, creator, timestamp, poll, topicMode } = cardData
|
||||
@ -1410,6 +1455,16 @@ const createEncryptedCardHTML = async (cardData, pollResults, cardIdentifier, co
|
||||
<button class="no" onclick="voteNoOnPoll('${poll}')">NO</button>
|
||||
</div>
|
||||
</div>
|
||||
${creator === userState.accountName ? `
|
||||
<div style="margin-top: 0.8em;">
|
||||
<button
|
||||
style="padding: 10px; background: darkred; color: white; border-radius: 4px; cursor: pointer;"
|
||||
onclick="deleteAdminCard('${cardIdentifier}')"
|
||||
>
|
||||
DELETE CARD
|
||||
</button>
|
||||
</div>
|
||||
` : ''}
|
||||
<div id="comments-section-${cardIdentifier}" class="comments-section" style="display: none; margin-top: 20px;">
|
||||
<div id="comments-container-${cardIdentifier}" class="comments-container"></div>
|
||||
<textarea id="new-comment-${cardIdentifier}" placeholder="Input your comment..." style="width: 100%; margin-top: 10px;"></textarea>
|
||||
|
@ -1903,6 +1903,47 @@ const getNewestCommentTimestamp = async (cardIdentifier) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ADDED: A simple function to effectively 'delete' a Minter Board card
|
||||
// by publishing an empty card with the same identifier and prefix
|
||||
const deleteCard = async (cardIdentifier, prefix) => {
|
||||
try {
|
||||
const confirmed = confirm("Are you sure you want to delete this card? This action cannot be undone.")
|
||||
if (!confirmed) return
|
||||
|
||||
// A minimal blank object
|
||||
const blankData = {
|
||||
header: "",
|
||||
content: "",
|
||||
links: [],
|
||||
creator: userState.accountName,
|
||||
timestamp: Date.now(),
|
||||
poll: "" // or null. This ensures it won't appear as a valid poll card
|
||||
}
|
||||
|
||||
let base64Data = await objectToBase64(blankData)
|
||||
if (!base64Data) {
|
||||
base64Data = btoa(JSON.stringify(blankData))
|
||||
}
|
||||
|
||||
await qortalRequest({
|
||||
action: "PUBLISH_QDN_RESOURCE",
|
||||
name: userState.accountName,
|
||||
service: "BLOG_POST",
|
||||
identifier: cardIdentifier,
|
||||
data64: base64Data,
|
||||
})
|
||||
|
||||
alert("Your card has been effectively deleted.")
|
||||
|
||||
// Now reload the existing Minter Board cards so the UI no longer shows the old card
|
||||
await loadCards(prefix)
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error deleting Minter card:", error)
|
||||
alert("Failed to delete the card. Check console for details.")
|
||||
}
|
||||
}
|
||||
|
||||
// Create the overall Minter Card HTML -----------------------------------------------
|
||||
const createCardHTML = async (cardData, pollResults, cardIdentifier, commentCount, cardUpdatedTime, bgColor, address) => {
|
||||
const { header, content, links, creator, timestamp, poll } = cardData
|
||||
@ -2010,6 +2051,16 @@ const createCardHTML = async (cardData, pollResults, cardIdentifier, commentCoun
|
||||
<button class="no" onclick="voteNoOnPoll('${poll}')">NO</button>
|
||||
</div>
|
||||
</div>
|
||||
${creator === userState.accountName ? `
|
||||
<div style="margin-top: 0.8em;">
|
||||
<button
|
||||
style="padding: 10px; background: darkred; color: white; border-radius: 4px; cursor: pointer;"
|
||||
onclick="deleteCard('${cardIdentifier}', '${minterCardIdentifierPrefix}')"
|
||||
>
|
||||
DELETE CARD
|
||||
</button>
|
||||
</div>
|
||||
` : ''}
|
||||
<div id="comments-section-${cardIdentifier}" class="comments-section" style="display: none; margin-top: 20px;">
|
||||
<div id="comments-container-${cardIdentifier}" class="comments-container"></div>
|
||||
<textarea id="new-comment-${cardIdentifier}" placeholder="Write a comment..." style="width: 100%; margin-top: 10px;"></textarea>
|
||||
|
Loading…
Reference in New Issue
Block a user