Fixed issue with like count going out of sync with actual count
This commit is contained in:
parent
e607982c3e
commit
749bc523d6
@ -1821,24 +1821,23 @@ input{
|
|||||||
duration: 150,
|
duration: 150,
|
||||||
ease: 'easing',
|
ease: 'easing',
|
||||||
}
|
}
|
||||||
const likeCount = parseInt(getRef('like_count').textContent)
|
totalVotes++
|
||||||
const newCount = likeCount ? likeCount + 1 : 1
|
|
||||||
getRef('like_count').animate(slideOutUp, animOptions)
|
getRef('like_count').animate(slideOutUp, animOptions)
|
||||||
.onfinish = (e) => {
|
.onfinish = (e) => {
|
||||||
e.target.cancel()
|
e.target.cancel()
|
||||||
}
|
}
|
||||||
const tempCount = document.createElement('div')
|
const tempCount = document.createElement('div')
|
||||||
tempCount.classList.add('temp-count')
|
tempCount.classList.add('temp-count')
|
||||||
tempCount.textContent = newCount
|
tempCount.textContent = totalVotes
|
||||||
getRef('like_count').after(tempCount)
|
getRef('like_count').after(tempCount)
|
||||||
tempCount.animate(slideInUp, animOptions)
|
tempCount.animate(slideInUp, animOptions)
|
||||||
.onfinish = () => {
|
.onfinish = () => {
|
||||||
getRef('like_count').textContent = newCount
|
getRef('like_count').textContent = totalVotes
|
||||||
tempCount.remove()
|
tempCount.remove()
|
||||||
}
|
}
|
||||||
floCloudAPI.sendGeneralData({
|
floCloudAPI.sendGeneralData({
|
||||||
articleID: currentArticleID,
|
articleID: currentArticleID,
|
||||||
}, 'article_votes')
|
}, `article_${currentArticleID}_votes`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log('upvoted')
|
console.log('upvoted')
|
||||||
})
|
})
|
||||||
@ -1948,14 +1947,15 @@ input{
|
|||||||
<script id="onLoadStartUp">
|
<script id="onLoadStartUp">
|
||||||
let isSubAdmin = false
|
let isSubAdmin = false
|
||||||
let isLoggedIn = false
|
let isLoggedIn = false
|
||||||
|
let totalVotes = 0
|
||||||
function onLoadStartUp() {
|
function onLoadStartUp() {
|
||||||
|
|
||||||
//floDapps.addStartUpFunction('Sample', Promised Function)
|
//floDapps.addStartUpFunction('Sample', Promised Function)
|
||||||
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
||||||
floDapps.setMidStartup(() => new Promise(async (resolve, reject) => {
|
floDapps.setMidStartup(() => new Promise(async (resolve, reject) => {
|
||||||
await floCloudAPI.requestGeneralData('article_votes')
|
await floCloudAPI.requestObjectData('RMT')
|
||||||
const allVotes = floGlobals.generalData[`article_votes|${floGlobals.adminID}|${floGlobals.application}`]
|
await floCloudAPI.requestGeneralData(`article_${currentArticleID}_votes`)
|
||||||
let totalVotes = 0
|
const allVotes = floGlobals.generalData[`article_${currentArticleID}_votes|${floGlobals.adminID}|${floGlobals.application}`]
|
||||||
for (const vote in allVotes) {
|
for (const vote in allVotes) {
|
||||||
const { message: { articleID } } = allVotes[vote]
|
const { message: { articleID } } = allVotes[vote]
|
||||||
if (allVotes[vote].message.articleID === currentArticleID) {
|
if (allVotes[vote].message.articleID === currentArticleID) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user